Module agora.flash.OnionPacket
Contains the routing path encoding structure.
An origin node which wishes to make a payment to a destination node needs to find a route to the destination node. Once it does, it needs to be able to encode this in a single structure so it may forward it to the first hop in the payment route, which in turn forwards it to the next hop, and so on..
Consider payment of A to D via A -> B -> C -> D:
The origin node must encode the payment route for each hop (B, C, D). It must do it in a way that each hop node only knows where to forward the packet to next, but may not know the entire route path.
NOTE
See https://github.com/lightningnetwork/lightning-rfc/blob/master/04-onion-routing.md
NOTE
See https://medium.com/softblocks/lightning-network-in-depth-part-2-htlc-and-payment-routing-db46aea445a8
Functions
Name | Description |
---|---|
createOnionPacket(amount, path, total_amount, use_lock_height, shared_secrets)
|
Create an onion packet for the given path. Each hop will contain an ephemeral public key to derive a common secret with which the hop's payload will be encrypted and may later be decrypted by the hop node which owns their private key. |
decryptPayload(encrypted, our_key, ephemeral_pk, payload, shared_secret)
|
Decrypt an encrypted payload with the shared secret generated from the ephemeral public key and the target node's private key. |
encryptPayload(payload, ephemeral_kp, target_pk, shared_secret)
|
Encrypt the payload with the shared secret generated from the ephemeral key-pair and the target node's public key. |
generateSharedSecret(is_sender, our_secret, their_pubkey)
|
Generate a shared secret to encrypt / decrypt a payload between two parties. |
nextPacket(packet)
|
Create the next packet for routing (if the next channel ID is not empty) |
obfuscate(error, secret)
|
Obfuscate/deobfuscate an OnionError with the given secret. |
Structs
Name | Description |
---|---|
EncryptedPayload
|
Contains the encrypted payload and the nonce used to encrypt it |
OnionError
|
Routing failure packet |
OnionPacket
|
Per-hop onion packet |
Payload
|
Decrypted Payload which is originally stored encrypted in the OnionPacket |
Manifest constants
Name | Type | Description |
---|---|---|
MaxPathLength
|
Upper bound on the path length | |
OnionVersion
|
Onion protocol version |
Aliases
Name | Type | Description |
---|---|---|
PaymentRouter
|
void delegate(in ref PublicKey, in ref geod24
|
OnionPacket payment router |