Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

integrate sphinx for onion message obfuscation #181

Merged
merged 3 commits into from
Sep 29, 2024

Conversation

doitian
Copy link
Member

@doitian doitian commented Sep 23, 2024

See more in the sphinx implementation repo https://github.com/cryptape/fiber-sphinx

What's changed?

  • Replace

    fiber/src/fiber/types.rs

    Lines 2718 to 2737 in 5685f40

    // TODO: replace this with real OnionPacket implementation
    #[serde_as]
    #[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
    pub struct OnionInfo {
    pub payment_hash: Hash256,
    // this is only specified in the last hop in the keysend mode
    pub preimage: Option<Hash256>,
    pub tlc_hash_algorithm: HashAlgorithm,
    pub amount: u128,
    pub expiry: u64,
    pub next_hop: Option<Pubkey>,
    #[serde_as(as = "Option<EntityHex>")]
    pub channel_outpoint: Option<OutPoint>,
    }
    // TODO: replace this with real OnionPacket implementation
    #[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
    pub struct OnionPacket {
    pub hop_data: Vec<OnionInfo>,
    }
    with sphinx

@doitian doitian marked this pull request as draft September 23, 2024 07:56
@doitian doitian linked an issue Sep 27, 2024 that may be closed by this pull request
@doitian doitian marked this pull request as ready for review September 29, 2024 07:56
@chenyukang chenyukang self-assigned this Sep 29, 2024
let mut peeled_packet_bytes: Option<Vec<u8>> = None;

if !add_tlc.onion_packet.is_empty() {
// TODO: Here we call network actor to peel the onion packet. Indeed, this message is forwarded from
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or we passing the private_key to channel state when creating channel actor, i'm not sure which way is better.

Comment on lines +146 to +149
// SendPaymentOnionPacket(peeled_packet_buf, previous_tlc),
// The first parameter is the peeled onion in binary via `PeeledOnionPacket::serialize`. `PeeledOnionPacket::current`
// is for the current node.
SendPaymentOnionPacket(Vec<u8>, Option<(Hash256, u64)>),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

better comment style in line 151~152 .

@chenyukang chenyukang merged commit 832a403 into nervosnetwork:main Sep 29, 2024
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Integrate fiber-sphinx to route payment request
2 participants