FailurePacket

object FailurePacket

An onion-encrypted failure packet from an intermediate node: +----------------+----------------------------------+-----------------+----------------------+-----+ | HMAC(32 bytes) | failure message length (2 bytes) | failure message | pad length (2 bytes) | pad | +----------------+----------------------------------+-----------------+----------------------+-----+ with failure message length + pad length = 256

Functions

create
Link copied to clipboard
common
fun create(sharedSecret: ByteVector32, failure: FailureMessage): ByteArray

Create a failure packet that will be returned to the sender. Each intermediate hop will add a layer of encryption and forward to the previous hop. Note that malicious intermediate hops may drop the packet or alter it (which breaks the mac).

decode
Link copied to clipboard
common
fun decode(input: ByteArray, macKey: ByteVector32): Try<FailureMessage>
decrypt
Link copied to clipboard
common
fun decrypt(packet: ByteArray, sharedSecrets: SharedSecrets): Try<DecryptedFailurePacket>

Decrypt a failure packet. Node shared secrets are applied until the packet's MAC becomes valid, which means that it was sent by the corresponding node. Note that malicious nodes in the route may have altered the packet, triggering a decryption failure.

encode
Link copied to clipboard
common
fun encode(failure: FailureMessage, macKey: ByteVector32): ByteArray
wrap
Link copied to clipboard
common
fun wrap(packet: ByteArray, sharedSecret: ByteVector32): ByteArray

Wrap the given packet in an additional layer of onion encryption for the previous hop.