bolt4

Onion routing protocol, per BOLT #4 (docs.ppad.tech/bolt4).
git clone git://git.ppad.tech/bolt4.git
Log | Files | Refs | README | LICENSE

04-onion-routing.md (155433B)


      1 # BOLT #4: Onion Routing Protocol
      2 
      3 ## Overview
      4 
      5 This document describes the construction of an onion routed packet that is
      6 used to route a payment from an _origin node_ to a _final node_. The packet
      7 is routed through a number of intermediate nodes, called _hops_.
      8 
      9 The routing schema is based on the [Sphinx][sphinx] construction and is
     10 extended with a per-hop payload.
     11 
     12 Intermediate nodes forwarding the message can verify the integrity of
     13 the packet and can learn which node they should forward the
     14 packet to. They cannot learn which other nodes, besides their
     15 predecessor or successor, are part of the packet's route; nor can they learn
     16 the length of the route or their position within it. The packet is
     17 obfuscated at each hop, to ensure that a network-level attacker cannot
     18 associate packets belonging to the same route (i.e. packets belonging
     19 to the same route do not share any correlating information). Notice that this
     20 does not preclude the possibility of packet association by an attacker
     21 via traffic analysis.
     22 
     23 The route is constructed by the origin node, which knows the public
     24 keys of each intermediate node and of the final node. Knowing each node's public key
     25 allows the origin node to create a shared secret (using ECDH) for each
     26 intermediate node and for the final node. The shared secret is then
     27 used to generate a _pseudo-random stream_ of bytes (which is used to obfuscate
     28 the packet) and a number of _keys_ (which are used to encrypt the payload and
     29 compute the HMACs). The HMACs are then in turn used to ensure the integrity of
     30 the packet at each hop.
     31 
     32 Each hop along the route only sees an ephemeral key for the origin node, in
     33 order to hide the sender's identity. The ephemeral key is blinded by each
     34 intermediate hop before forwarding to the next, making the onions unlinkable
     35 along the route.
     36 
     37 This specification describes _version 0_ of the packet format and routing
     38 mechanism.
     39 
     40 A node:
     41   - upon receiving a higher version packet than it implements:
     42     - MUST report a route failure to the origin node.
     43     - MUST discard the packet.
     44 
     45 # Table of Contents
     46 
     47   * [Conventions](#conventions)
     48   * [Key Generation](#key-generation)
     49   * [Pseudo Random Byte Stream](#pseudo-random-byte-stream)
     50   * [Packet Structure](#packet-structure)
     51     * [Payload Format](#payload-format)
     52     * [Basic Multi-Part Payments](#basic-multi-part-payments)
     53   * [Route Blinding](#route-blinding)
     54     * [Inside encrypted_recipient_data: encrypted_data_tlv](#Inside-encrypted_recipient_data-encrypted_data_tlv)
     55   * [Accepting and Forwarding a Payment](#accepting-and-forwarding-a-payment)
     56     * [Payload for the Last Node](#payload-for-the-last-node)
     57     * [Non-strict Forwarding](#non-strict-forwarding)
     58   * [Shared Secret](#shared-secret)
     59   * [Blinding Ephemeral Onion Keys](#blinding-ephemeral-onion-keys)
     60   * [Packet Construction](#packet-construction)
     61   * [Onion Decryption](#onion-decryption)
     62   * [Filler Generation](#filler-generation)
     63   * [Returning Errors](#returning-errors)
     64     * [Failure Messages](#failure-messages)
     65     * [Receiving Failure Codes](#receiving-failure-codes)
     66   * [Successful Payments](#successful-payments)
     67   * [Onion Messages](#onion-messages)
     68   * [`max_htlc_cltv` Selection](#max_htlc_cltv-selection)
     69   * [Test Vector](#test-vector)
     70     * [Returning Errors](#returning-errors)
     71   * [References](#references)
     72   * [Authors](#authors)
     73 
     74 # Conventions
     75 
     76 There are a number of conventions adhered to throughout this document:
     77 
     78  - HMAC: the integrity verification of the packet is based on Keyed-Hash
     79    Message Authentication Code, as defined by the [FIPS 198
     80    Standard][fips198]/[RFC 2104][RFC2104], and using a `SHA256` hashing
     81    algorithm.
     82  - Elliptic curve: for all computations involving elliptic curves, the Bitcoin
     83    curve is used, as specified in [`secp256k1`][sec2]
     84  - Pseudo-random stream: [`ChaCha20`][rfc8439] is used to generate a
     85    pseudo-random byte stream. For its generation, a fixed 96-bit null-nonce
     86    (`0x000000000000000000000000`) is used, along with a key derived from a shared
     87    secret and with a `0x00`-byte stream of the desired output size as the
     88    message.
     89  - The terms _origin node_ and _final node_ refer to the initial packet sender
     90    and the final packet recipient, respectively.
     91  - The terms _hop_ and _node_ are sometimes used interchangeably, but a _hop_
     92    usually refers to an intermediate node in the route rather than an end node.
     93         _origin node_ --> _hop_ --> ... --> _hop_ --> _final node_
     94  - The term _processing node_ refers to the specific node along the route that is
     95    currently processing the forwarded packet.
     96  - The term _peers_ refers only to hops that are direct neighbors (in the
     97    overlay network): more specifically, _sending peers_ forward packets
     98    to _receiving peers_.
     99  - Each hop in the route has a variable length `hop_payload`.
    100     - The variable length `hop_payload` is prefixed with a `bigsize` encoding
    101       the length in bytes, excluding the prefix and the trailing HMAC.
    102  - These `hop_payload`s are used to build the combined payload in the packet,
    103    also referred to as `hop_payloads` or the mix-header.
    104 
    105 # Key Generation
    106 
    107 A number of encryption and verification keys are derived from the shared secret:
    108 
    109  - _rho_: used as key when generating the pseudo-random byte stream that is used
    110    to obfuscate the per-hop information
    111  - _mu_: used during the HMAC generation
    112  - _um_: used during error reporting
    113  - _pad_: use to generate random filler bytes for the starting mix-header
    114    packet
    115 
    116 The key generation function takes a key-type (_rho_=`0x72686F`, _mu_=`0x6d75`, 
    117 _um_=`0x756d`, or _pad_=`0x706164`) and a 32-byte secret as inputs and returns
    118 a 32-byte key.
    119 
    120 Keys are generated by computing an HMAC (with `SHA256` as hashing algorithm)
    121 using the appropriate key-type (i.e. _rho_, _mu_, _um_, or _pad_) as HMAC-key
    122 and the 32-byte shared secret as the message. The resulting HMAC is then
    123 returned as the key.
    124 
    125 Notice that the key-type does not include a C-style `0x00`-termination-byte,
    126 e.g. the length of the _rho_ key-type is 3 bytes, not 4.
    127 
    128 # Pseudo Random Byte Stream
    129 
    130 The pseudo-random byte stream is used to obfuscate the packet at each hop of the
    131 path, so that each hop may only recover the address and HMAC of the next hop.
    132 The pseudo-random byte stream is generated by encrypting (using `ChaCha20`) a
    133 `0x00`-byte stream, of the required length, which is initialized with a key
    134 derived from the shared secret and a 96-bit zero-nonce (`0x000000000000000000000000`).
    135 
    136 The use of a fixed nonce is safe, since the keys are never reused.
    137 
    138 # Packet Structure
    139 
    140 The packet consists of four sections:
    141 
    142  - a `version` byte
    143  - a 33-byte compressed `secp256k1` `public_key`, used during the shared secret
    144    generation
    145  - a 1300-byte `hop_payloads` consisting of multiple, variable length,
    146    `hop_payload` payloads
    147  - a 32-byte `hmac`, used to verify the packet's integrity
    148 
    149 The network format of the packet consists of the individual sections
    150 serialized into one contiguous byte-stream and then transferred to the packet
    151 recipient. Due to the fixed size of the packet, it need not be prefixed by its
    152 length when transferred over a connection.
    153 
    154 The overall structure of the packet is as follows:
    155 
    156 1. type: `onion_packet`
    157 2. data:
    158    * [`byte`:`version`]
    159    * [`point`:`public_key`]
    160    * [`1300*byte`:`hop_payloads`]
    161    * [`32*byte`:`hmac`]
    162 
    163 For this specification (_version 0_), `version` has a constant value of `0x00`.
    164 
    165 The `hop_payloads` field is a structure that holds obfuscated routing information, and associated HMAC.
    166 It is 1300 bytes long and has the following structure:
    167 
    168 1. type: `hop_payloads`
    169 2. data:
    170    * [`bigsize`:`length`]
    171    * [`length*byte`:`payload`]
    172    * [`32*byte`:`hmac`]
    173    * ...
    174    * `filler`
    175 
    176 Where, the `length`, `payload`, and `hmac` are repeated for each hop;
    177 and where, `filler` consists of obfuscated, deterministically-generated padding, as detailed in [Filler Generation](#filler-generation).
    178 Additionally, `hop_payloads` is incrementally obfuscated at each hop.
    179 
    180 Using the `payload` field, the origin node is able to specify the path and structure of the HTLCs forwarded at each hop.
    181 As the `payload` is protected under the packet-wide HMAC, the information it contains is fully authenticated with each pair-wise relationship between the HTLC sender (origin node) and each hop in the path.
    182 
    183 Using this end-to-end authentication, each hop is able to cross-check the HTLC
    184 parameters with the `payload`'s specified values and to ensure that the
    185 sending peer hasn't forwarded an ill-crafted HTLC.
    186 
    187 Since no `payload` TLV value can ever be shorter than 2 bytes, `length` values of 0 and 1 are reserved.  (`0` indicated a legacy format no longer supported, and `1` is reserved for future use).
    188 
    189 ### `payload` format
    190 
    191 This is formatted according to the Type-Length-Value format defined in [BOLT #1](01-messaging.md#type-length-value-format).
    192 
    193 1. `tlv_stream`: `payload`
    194 2. types:
    195     1. type: 2 (`amt_to_forward`)
    196     2. data:
    197         * [`tu64`:`amt_to_forward`]
    198     1. type: 4 (`outgoing_cltv_value`)
    199     2. data:
    200         * [`tu32`:`outgoing_cltv_value`]
    201     1. type: 6 (`short_channel_id`)
    202     2. data:
    203         * [`short_channel_id`:`short_channel_id`]
    204     1. type: 8 (`payment_data`)
    205     2. data:
    206         * [`32*byte`:`payment_secret`]
    207         * [`tu64`:`total_msat`]
    208     1. type: 10 (`encrypted_recipient_data`)
    209     2. data:
    210         * [`...*byte`:`encrypted_recipient_data`]
    211     1. type: 12 (`current_path_key`)
    212     2. data:
    213         * [`point`:`path_key`]
    214     1. type: 16 (`payment_metadata`)
    215     2. data:
    216         * [`...*byte`:`payment_metadata`]
    217     1. type: 18 (`total_amount_msat`)
    218     2. data:
    219         * [`tu64`:`total_msat`]
    220 
    221 `short_channel_id` is the ID of the outgoing channel used to route the
    222 message; the receiving peer should operate the other end of this channel.
    223 
    224 `amt_to_forward` is the amount, in millisatoshis, to forward to the
    225 next receiving peer specified within the routing information, or for
    226 the final destination.
    227 
    228 For non-final nodes, this includes the origin node's computed _fee_ for the
    229 receiving peer, calculated according to the receiving peer's advertised fee
    230 schema (as described in [BOLT #7](07-routing-gossip.md#htlc-fees)).
    231 
    232 `outgoing_cltv_value` is the CLTV value that the _outgoing_ HTLC
    233 carrying the packet should have.  Inclusion of this field allows a hop
    234 to both authenticate the information specified by the origin node, and
    235 the parameters of the HTLC forwarded, and ensure the origin node is
    236 using the current `cltv_expiry_delta` value.
    237 
    238 If the values don't correspond, this indicates that either a
    239 forwarding node has tampered with the intended HTLC values or that the
    240 origin node has an obsolete `cltv_expiry_delta` value.
    241 
    242 The requirements ensure consistency in responding to an unexpected
    243 `outgoing_cltv_value`, whether it is the final node or not, to avoid
    244 leaking its position in the route.
    245 
    246 ### Requirements
    247 
    248 The creator of `encrypted_recipient_data` (usually, the recipient of payment):
    249 
    250   - MUST create `encrypted_data_tlv` for each node in the blinded route (including itself).
    251   - MUST include `encrypted_data_tlv.payment_relay` for each non-final node.
    252   - MUST include exactly one of `encrypted_data_tlv.short_channel_id` or `encrypted_data_tlv.next_node_id` for each non-final node.
    253   - MUST set `encrypted_data_tlv.payment_constraints` for each non-final node and MAY set it for the final node:
    254     - `max_cltv_expiry` to the largest block height at which the route is allowed to be used, starting
    255        from the final node's chosen `max_cltv_expiry` height at which the route should expire, adding 
    256        the final node's `min_final_cltv_expiry_delta` and then adding 
    257        `encrypted_data_tlv.payment_relay.cltv_expiry_delta` at each hop.
    258     - `htlc_minimum_msat` to the largest minimum HTLC value the nodes will allow.
    259   - If it sets `encrypted_data_tlv.allowed_features`:
    260     - MUST set it to an empty array.
    261   - MUST compute the total fees and CLTV delta of the route as follows and communicate them to the sender:
    262     - `total_fee_base_msat(n+1) = (fee_base_msat(n+1) * 1000000 + total_fee_base_msat(n) * (1000000 + fee_proportional_millionths(n+1)) + 1000000 - 1) / 1000000`
    263     - `total_fee_proportional_millionths(n+1) = ((total_fee_proportional_millionths(n) + fee_proportional_millionths(n+1)) * 1000000 + total_fee_proportional_millionths(n) * fee_proportional_millionths(n+1) + 1000000 - 1) / 1000000`
    264     - `total_cltv_delta = cltv_delta(0) + cltv_delta(1) + ... + cltv_delta(n) + min_final_cltv_expiry_delta`
    265   - MUST create the `encrypted_recipient_data` from the `encrypted_data_tlv` as required in [Route Blinding](#route-blinding).
    266 
    267 The writer of the TLV `payload`:
    268 
    269   - For every node inside a blinded route:
    270     - MUST include the `encrypted_recipient_data` provided by the recipient
    271     - For the first node in the blinded route:
    272       - MUST include the `path_key` provided by the recipient in `current_path_key`
    273     - If it is the final node:
    274       - MUST include `amt_to_forward`, `outgoing_cltv_value` and `total_amount_msat`.
    275       - The value set for `outgoing_cltv_value`: 
    276         - MUST use the current block height as a baseline value. 
    277         - if a [random offset](07-routing-gossip.md#recommendations-for-routing) was added to improve privacy:
    278           - SHOULD add the offset to the baseline value.
    279     - MUST NOT include any other tlv field.
    280   - For every node outside of a blinded route:
    281     - MUST include `amt_to_forward` and `outgoing_cltv_value`.
    282     - For every non-final node:
    283       - MUST include `short_channel_id`
    284       - MUST NOT include `payment_data`
    285     - For the final node:
    286       - MUST NOT include `short_channel_id`
    287       - if the recipient provided `payment_secret`:
    288         - MUST include `payment_data`
    289         - MUST set `payment_secret` to the one provided
    290         - MUST set `total_msat` to the total amount it will send
    291       - if the recipient provided `payment_metadata`:
    292         - MUST include `payment_metadata` with every HTLC
    293         - MUST not apply any limits to the size of `payment_metadata` except the limits implied by the fixed onion size
    294 
    295 The reader:
    296 
    297   - If `encrypted_recipient_data` is present:
    298     - If `path_key` is set in the incoming `update_add_htlc`:
    299       - MUST return an error if `current_path_key` is present.
    300       - MUST use that `path_key` as `path_key` for decryption.
    301     - Otherwise:
    302       - MUST return an error if `current_path_key` is not present.
    303       - MUST use that `current_path_key` as the `path_key` for decryption.
    304       - SHOULD add a random delay before returning errors.
    305     - MUST return an error if `encrypted_recipient_data` does not decrypt using the
    306       `path_key` as described in [Route Blinding](#route-blinding).
    307     - If `payment_constraints` is present:
    308       - MUST return an error if:
    309         - the expiry is greater than `encrypted_recipient_data.payment_constraints.max_cltv_expiry`.
    310         - the amount is below `encrypted_recipient_data.payment_constraints.htlc_minimum_msat`.
    311     - If `allowed_features` is missing:
    312       - MUST process the message as if it were present and contained an empty array.
    313     - MUST return an error if:
    314       - `encrypted_recipient_data.allowed_features.features` contains an unknown feature bit (even if it is odd).
    315       - `encrypted_recipient_data` contains both `short_channel_id` and `next_node_id`.
    316       - the payment uses a feature not included in `encrypted_recipient_data.allowed_features.features`.
    317     - If it is not the final node:
    318       - MUST return an error if the payload contains other tlv fields than `encrypted_recipient_data` and `current_path_key`.
    319       - MUST return an error if `encrypted_recipient_data` does not contain either `short_channel_id` or `next_node_id`.
    320       - MUST return an error if `encrypted_recipient_data` does not contain `payment_relay`.
    321       - MUST use values from `encrypted_recipient_data.payment_relay` to calculate `amt_to_forward` and `outgoing_cltv_value` as follows:
    322         - `amt_to_forward = ((amount_msat - fee_base_msat) * 1000000 + 1000000 + fee_proportional_millionths - 1) / (1000000 + fee_proportional_millionths)`
    323         - `outgoing_cltv_value = cltv_expiry - payment_relay.cltv_expiry_delta`
    324     - If it is the final node:
    325       - MUST return an error if the payload contains other tlv fields than `encrypted_recipient_data`, `current_path_key`, `amt_to_forward`, `outgoing_cltv_value` and `total_amount_msat`.
    326       - MUST return an error if `amt_to_forward`, `outgoing_cltv_value` or `total_amount_msat` are not present.
    327       - MUST return an error if `amt_to_forward` is below what it expects for the payment.
    328       - MUST return an error if incoming `cltv_expiry` < `outgoing_cltv_value`.
    329       - MUST return an error if incoming `cltv_expiry` < `current_block_height` + `min_final_cltv_expiry_delta`.
    330   - Otherwise (it is not part of a blinded route):
    331     - MUST return an error if `path_key` is set in the incoming `update_add_htlc` or `current_path_key` is present.
    332     - MUST return an error if `amt_to_forward` or `outgoing_cltv_value` are not present.
    333     - if it is not the final node:
    334       - MUST return an error if:
    335         - `short_channel_id` is not present,
    336         - it cannot forward the HTLC to the peer indicated by the channel `short_channel_id`.
    337         - incoming `amount_msat` - `fee` < `amt_to_forward` (where `fee` is the advertised fee as described in [BOLT #7](07-routing-gossip.md#htlc-fees))
    338         - `cltv_expiry` - `cltv_expiry_delta` < `outgoing_cltv_value`
    339   - If it is the final node:
    340     - MUST return an error if:
    341       - `total_msat` is not present
    342       - incoming `amount_msat` < `amt_to_forward`.
    343       - incoming `cltv_expiry` < `outgoing_cltv_value`.
    344       - incoming `cltv_expiry` < `current_block_height` + `min_final_cltv_expiry_delta`.
    345 
    346 Additional requirements are specified [here](#basic-multi-part-payments) for
    347 multi-part payments, and [here](#route-blinding) for blinded payments.
    348 
    349 ### Basic Multi-Part Payments
    350 
    351 An HTLC may be part of a larger "multi-part" payment: such
    352 "base" atomic multipath payments will use the same `payment_hash` for
    353 all paths.
    354 
    355 Note that `amt_to_forward` is the amount for this HTLC only: a
    356 `total_msat` field containing a greater value is a promise by the
    357 ultimate sender that the rest of the payment will follow in succeeding
    358 HTLCs; we call these outstanding HTLCs which have the same preimage,
    359 an "HTLC set".
    360 
    361 Note that there are two distinct tlv fields that can be used to transmit
    362 `total_msat`. The last one, `total_amount_msat`, was introduced with
    363 blinded paths for which the `payment_secret` doesn't make sense.
    364 
    365 `payment_metadata` is to be included in every payment part, so that
    366 invalid payment details can be detected as early as possible.
    367 
    368 #### Requirements
    369 
    370 The writer:
    371   - if the invoice offers the `basic_mpp` feature:
    372     - MAY send more than one HTLC to pay the invoice.
    373     - MUST use the same `payment_hash` on all HTLCs in the set.
    374     - SHOULD send all payments at approximately the same time.
    375     - SHOULD try to use diverse paths to the recipient for each HTLC.
    376     - SHOULD retry and/or re-divide HTLCs which fail.
    377     - if the invoice specifies an `amount`:
    378        - MUST set `total_msat` to at least that `amount`, and less
    379          than or equal to twice `amount`.
    380     - otherwise:
    381       - MUST set `total_msat` to the amount it wishes to pay.
    382     - MUST ensure that the total `amt_to_forward` of the HTLC set which arrives
    383       at the payee is equal to or greater than `total_msat`.
    384     - MUST NOT send another HTLC if the total `amt_to_forward` of the HTLC set
    385       is already greater or equal to `total_msat`.
    386     - MUST include `payment_secret`.
    387   - otherwise:
    388     - MUST set `total_msat` equal to `amt_to_forward`.
    389 
    390 The final node:
    391   - MUST fail the HTLC if dictated by Requirements under [Failure Messages](#failure-messages)
    392     - Note: "amount paid" specified there is the `total_msat` field.
    393   - if it does not support `basic_mpp`:
    394     - MUST fail the HTLC if `total_msat` is not exactly equal to `amt_to_forward`.
    395   - otherwise, if it supports `basic_mpp`:
    396     - MUST add it to the HTLC set corresponding to that `payment_hash`.
    397     - SHOULD fail the entire HTLC set if `total_msat` is not the same for
    398       all HTLCs in the set.
    399     - if the total `amt_to_forward` of this HTLC set is equal to or greater
    400       than `total_msat`:
    401       - SHOULD fulfill all HTLCs in the HTLC set
    402     - otherwise, if the total `amt_to_forward` of this HTLC set is less than
    403       `total_msat`:
    404       - MUST NOT fulfill any HTLCs in the HTLC set
    405       - MUST fail all HTLCs in the HTLC set after some reasonable timeout.
    406         - SHOULD wait for at least 60 seconds after the initial HTLC.
    407         - SHOULD use `mpp_timeout` for the failure message.
    408       - MUST require `payment_secret` for all HTLCs in the set.
    409     - if it fulfills any HTLCs in the HTLC set:
    410        - MUST fulfill the entire HTLC set.
    411 
    412 #### Rationale
    413 
    414 If `basic_mpp` is present it causes a delay to allow other partial
    415 payments to combine.  The total amount must be sufficient for the
    416 desired payment, just as it must be for single payments.  But this must
    417 be reasonably bounded to avoid a denial-of-service.
    418 
    419 Because invoices do not necessarily specify an amount, and because
    420 payers can add noise to the final amount, the total amount must be
    421 sent explicitly.  The requirements allow exceeding this slightly, as
    422 it simplifies adding noise to the amount when splitting, as well as
    423 scenarios in which the senders are genuinely independent (friends
    424 splitting a bill, for example).
    425 
    426 Because a node may need to pay more than its desired amount (due to the
    427 `htlc_minimum_msat` value of channels in the desired path), nodes are allowed
    428 to pay more than the `total_msat` they specified. Otherwise, nodes would be
    429 constrained in which paths they can take when retrying payments along specific
    430 paths. However, no individual HTLC may be for less than the difference between
    431 the total paid and `total_msat`.
    432 
    433 The restriction on sending an HTLC once the set is over the agreed total prevents the preimage being released before all
    434 the partial payments have arrived: that would allow any intermediate
    435 node to immediately claim any outstanding partial payments.
    436 
    437 An implementation may choose not to fulfill an HTLC set which
    438 otherwise meets the amount criterion (eg. some other failure, or
    439 invoice timeout), however if it were to fulfill only some of them,
    440 intermediary nodes could simply claim the remaining ones.
    441 
    442 ## Route Blinding
    443 
    444 1. subtype: `blinded_path`
    445 2. data:
    446    * [`sciddir_or_pubkey`:`first_node_id`]
    447    * [`point`:`first_path_key`]
    448    * [`byte`:`num_hops`]
    449    * [`num_hops*blinded_path_hop`:`path`]
    450 
    451 1. subtype: `blinded_path_hop`
    452 2. data:
    453     * [`point`:`blinded_node_id`]
    454     * [`u16`:`enclen`]
    455     * [`enclen*byte`:`encrypted_recipient_data`]
    456 
    457 A blinded path consists of:
    458 1. an initial introduction point (`first_node_id`)
    459 2. an initial key to share a secret with the first node_id (`first_path_key`)
    460 3. a series of tweaked node ids (`path.blinded_node_id`)
    461 4. a series of binary blobs encrypted to the nodes (`path.encrypted_recipient_data`)
    462    to tell them the next hop.
    463 
    464 For example, Dave wants Alice to reach him via public node Bob then
    465 Carol.  He creates a chain of public keys ("path_keys") for Bob, Carol
    466 and finally himself, so he can share a secret with each of them.  These
    467 keys are a simple chain, so each node can derive the next `path_key` without
    468 having to be told explicitly.
    469 
    470 From these shared secrets, Dave creates and encrypts three `encrypted_data_tlv`s:
    471 1. encrypted_data_bob: For Bob to tell him to forward to Carol
    472 2. encrypted_data_carol: For Carol to tell her to forward to him
    473 3. encrypted_data_dave: For himself to indicate the path was used, and any metadata he wants.
    474 
    475 To mask the node ids, he also derives three blinding factors from the
    476 shared secrets, which turn Bob into Bob', Carol into Carol' and Dave
    477 into Dave'.
    478 
    479 So this is the `blinded_path` he hands to Alice.
    480 
    481 1. `first_node_id`: Bob
    482 2. `first_path_key`: the first path key for Bob 
    483 3. `path`: [Bob', encrypted_data_bob], [Carol', encrypted_data_carol], [Dave', encrypted_data_dave]
    484 
    485 There are two different ways for Alice to construct an onion which gets to Bob (since he's probably not a direct peer of hers) which are described in the requirements below.
    486 
    487 But after Bob the path is always the same: he will send Carol the `path_key` he derived, along with the onion.  She will use the `path_key` to derive the tweak for the onion (which Alice encrypted for Carol' not Carol) so she can decrypt it, and also to derive the key to decrypt `encrypted_data_tlv` which will tell her to forward to Dave (and possibly additional restrictions Dave specified).
    488 
    489 ### Requirements
    490 
    491 Note that the creator of the blinded path (i.e. the recipient) is creating it for the sender to use to create an onion, and for the intermediate nodes to read the instructions, hence there are two reader sections here.
    492 
    493 The writer of a `blinded_path`:
    494 
    495 - MUST create a viable path to itself ($`N_r`$) i.e. $`N_0 \rightarrow N_1 \rightarrow ... \rightarrow N_r`$.
    496 - MUST set `first_node_id` to $`N_0`$
    497 - MUST create a series of ECDH shared secrets for each node in the route using the following algorithm:
    498   - $`e_0 \leftarrow \{0;1\}^{256}`$ ($`e_0`$ SHOULD be obtained via CSPRNG)
    499   - $`E_0 = e_0 \cdot G`$
    500   - For every node in the route:
    501     - let $`N_i = k_i * G`$ be the `node_id` ($`k_i`$ is $`N_i`$'s private key)
    502     - $`ss_i = SHA256(e_i * N_i) = SHA256(k_i * E_i)`$ (ECDH shared secret known only by $`N_r`$ and $`N_i`$)
    503     - $`rho_i = HMAC256(\text{"rho"}, ss_i)`$ (key used to encrypt `encrypted_recipient_data` for $`N_i`$ by $`N_r`$)
    504     - $`e_{i+1} = SHA256(E_i || ss_i) * e_i`$ (ephemeral private path key, only known by $`N_r`$)
    505     - $`E_{i+1} = SHA256(E_i || ss_i) * E_i`$ (`path_key`. NB: $`N_i`$ MUST NOT learn $`e_i`$)
    506 - MUST set `first_path_key` to $`E_0`$
    507 - MUST create a series of blinded node IDs $`B_i`$ for each node using the following algorithm:
    508   - $`B_i = HMAC256(\text{"blinded\_node\_id"}, ss_i) * N_i`$ (blinded `node_id` for $`N_i`$, private key known only by $`N_i`$)
    509   - MUST set `blinded_node_id` for each `blinded_path_hop` in `path` to $`B_i`$
    510 - MAY replace $`E_{i+1}`$ with a different value, but if it does:
    511   - MUST set `encrypted_data_tlv[i].next_path_key_override` to $`E_{i+1}`$
    512 - MAY store private data in `encrypted_data_tlv[r].path_id` to verify that the route is used in the right context and was created by them
    513 - SHOULD add padding data to ensure all `encrypted_data_tlv[i]` have the same length
    514 - MUST encrypt each `encrypted_data_tlv[i]` with ChaCha20-Poly1305 using the corresponding $`rho_i`$ key and an all-zero nonce to produce `encrypted_recipient_data[i]`
    515 - MAY add additional "dummy" hops at the end of the path (which it will ignore on receipt) to obscure the path length.
    516 
    517 The reader of the `blinded_path`:
    518 - MUST prepend its own onion payloads to reach the `first_node_id`
    519 - MUST include the corresponding `encrypted_recipient_data` in each onion payload within `path`
    520 - For the first entry in `path`:
    521   - if it is sending a payment:
    522     - SHOULD create an unblinded onion payment to `first_node_id`, and include `first_path_key` as `current_path_key`.
    523   - otherwise:
    524     - MUST encrypt the first blinded path onion to the first `blinded_node_id`.
    525     - MUST set `next_path_key_override` in the prior onion payload to `first_path_key`.
    526 - For each successive entry in `path`:
    527   - MUST encrypt the onion to the corresponding `blinded_node_id`.
    528 
    529 The reader of the `encrypted_recipient_data`:
    530 
    531 - MUST compute:
    532   - $`ss_i = SHA256(k_i * E_i)`$ (standard ECDH)
    533   - $`b_i = HMAC256(\text{"blinded\_node\_id"}, ss_i) * k_i`$
    534   - $`rho_i = HMAC256(\text{"rho"}, ss_i)`$
    535 - MUST decrypt the `encrypted_recipient_data` field using $`rho_i`$ as a key using ChaCha20-Poly1305 and an all-zero nonce key.
    536 - If the `encrypted_recipient_data` field is missing, cannot be decrypted into an `encrypted_data_tlv` or contains unknown even fields:
    537   - MUST return an error
    538 - If the `encrypted_data_tlv` contains a `next_path_key_override`:
    539   - MUST use it as the next `path_key`.
    540 - Otherwise:
    541   - MUST use $`E_{i+1} = SHA256(E_i || ss_i) * E_i`$ as the next `path_key`
    542 - MUST forward the onion and include the next `path_key` in the lightning
    543   message for the next node
    544 - If it is the final recipient:
    545   - MUST ignore the message if the `path_id` does not match the blinded route it
    546     created for this purpose
    547 
    548 ### Rationale
    549 
    550 Route blinding is a lightweight technique to provide recipient anonymity.
    551 It's more flexible than rendezvous routing because it simply replaces the public
    552 keys of the nodes in the route with random public keys while letting senders
    553 choose what data they put in the onion for each hop. Blinded routes are also
    554 reusable in some cases (e.g. onion messages).
    555 
    556 Each node in the blinded route needs to receive $`E_i`$ to be able to decrypt
    557 the onion and the `encrypted_recipient_data` payload.
    558 
    559 When concatenating two blinded routes generated by different nodes, the
    560 last node of the first route needs to know the first `path_key` of the
    561 second route: the `next_path_key_override` field must be used to transmit this
    562 information.  In theory this method could be used for payments (not just
    563 onion messages), but we recommend using an unblinded path to reach the 
    564 `first_node_id` and using `current_path_key` there: this means that the
    565 node can tell it is being used as an introductory point, but also does
    566 not require blinded path support on the nodes to reach that point, and
    567 gives meaningful errors on the unblinded part of the payment.
    568 
    569 The final recipient must verify that the blinded route is used in the right
    570 context (e.g. for a specific payment) and was created by them. Otherwise a
    571 malicious sender could create different blinded routes to all the nodes that
    572 they suspect could be the real recipient and try them until one accepts the
    573 message. The recipient can protect against that by storing $`E_r`$ and the
    574 context (e.g. a `payment_hash`), and verifying that they match when receiving
    575 the onion. Otherwise, to avoid additional storage cost, it can put some private
    576 context information in the `path_id` field (e.g. the `payment_preimage`) and
    577 verify that when receiving the onion. Note that it's important to use private
    578 information in that case, that senders cannot have access to.
    579 
    580 Whenever the introduction point receives a failure from the blinded route, it
    581 should add a random delay before forwarding the error. Failures are likely to
    582 be probing attempts and message timing may help the attacker infer its distance
    583 to the final recipient.
    584 
    585 Note that nodes in the blinded route return failures through `update_fail_malformed_htlc` and therefore do not and can
    586 not provide timing information via attribution data to the sender.
    587 
    588 The `padding` field can be used to ensure that all `encrypted_recipient_data` have the
    589 same length. It's particularly useful when adding dummy hops at the end of a
    590 blinded route, to prevent the sender from figuring out which node is the final
    591 recipient.
    592 
    593 When route blinding is used for payments, the recipient specifies the fees and
    594 expiry that blinded nodes should apply to the payment instead of letting the
    595 sender configure them. The recipient also adds additional constraints to the
    596 payments that can go through that route to protect against probing attacks that
    597 would let malicious nodes unblind the identity of the blinded nodes. It should
    598 set `payment_constraints.max_cltv_expiry` to restrict the lifetime of a blinded
    599 route and reduce the risk that an intermediate node updates its fees and rejects
    600 payments (which could be used to unblind nodes inside the route).
    601 
    602 ### Inside `encrypted_recipient_data`: `encrypted_data_tlv`
    603 
    604 The `encrypted_recipient_data` is a TLV stream, encrypted for a given blinded node, that
    605 may contain the following TLV fields:
    606 
    607 1. `tlv_stream`: `encrypted_data_tlv`
    608 2. types:
    609     1. type: 1 (`padding`)
    610     2. data:
    611         * [`...*byte`:`padding`]
    612     1. type: 2 (`short_channel_id`)
    613     2. data:
    614         * [`short_channel_id`:`short_channel_id`]
    615     1. type: 4 (`next_node_id`)
    616     2. data:
    617         * [`point`:`node_id`]
    618     1. type: 6 (`path_id`)
    619     2. data:
    620         * [`...*byte`:`data`]
    621     1. type: 8 (`next_path_key_override`)
    622     2. data:
    623         * [`point`:`path_key`]
    624     1. type: 10 (`payment_relay`)
    625     2. data:
    626         * [`u16`:`cltv_expiry_delta`]
    627         * [`u32`:`fee_proportional_millionths`]
    628         * [`tu32`:`fee_base_msat`]
    629     1. type: 12 (`payment_constraints`)
    630     2. data:
    631         * [`u32`:`max_cltv_expiry`]
    632         * [`tu64`:`htlc_minimum_msat`]
    633     1. type: 14 (`allowed_features`)
    634     2. data:
    635         * [`...*byte`:`features`]
    636 
    637 #### Rationale
    638 
    639 Encrypted recipient data is created by the final recipient to give to the
    640 sender, containing instructions for the node on how to handle the message (it can also be created by the sender themselves: the node forwarding cannot tell).  It's used
    641 in both payment onions and onion messages onions.  See [Route Blinding](#route-blinding).
    642 
    643 
    644 # Accepting and Forwarding a Payment
    645 
    646 Once a node has decoded the payload it either accepts the payment locally, or forwards it to the peer indicated as the next hop in the payload.
    647 
    648 ## Non-strict Forwarding
    649 
    650 A node MAY forward an HTLC along an outgoing channel other than the one
    651 specified by `short_channel_id`, so long as the receiver has the same node
    652 public key intended by `short_channel_id`. Thus, if `short_channel_id` connects
    653 nodes A and B, the HTLC can be forwarded across any channel connecting A and B.
    654 Failure to adhere will result in the receiver being unable to decrypt the next
    655 hop in the onion packet.
    656 
    657 ### Rationale
    658 
    659 In the event that two peers have multiple channels, the downstream node will be
    660 able to decrypt the next hop payload regardless of which channel the packet is
    661 sent across.
    662 
    663 Nodes implementing non-strict forwarding are able to make real-time assessments
    664 of channel bandwidths with a particular peer, and use the channel that is
    665 locally-optimal.
    666 
    667 For example, if the channel specified by `short_channel_id` connecting A and B
    668 does not have enough bandwidth at forwarding time, then A is able use a
    669 different channel that does. This can reduce payment latency by preventing the
    670 HTLC from failing due to bandwidth constraints across `short_channel_id`, only
    671 to have the sender attempt the same route differing only in the channel between
    672 A and B.
    673 
    674 Non-strict forwarding allows nodes to make use of private channels connecting
    675 them to the receiving node, even if the channel is not known in the public
    676 channel graph.
    677 
    678 ### Recommendation
    679 
    680 Implementations using non-strict forwarding should consider applying the same
    681 fee schedule to all channels with the same peer, as senders are likely to select
    682 the channel which results in the lowest overall cost. Having distinct policies
    683 may result in the forwarding node accepting fees based on the most optimal fee
    684 schedule for the sender, even though they are providing aggregate bandwidth
    685 across all channels with the same peer.
    686 
    687 Alternatively, implementations may choose to apply non-strict forwarding only to
    688 like-policy channels to ensure their expected fee revenue does not deviate by
    689 using an alternate channel.
    690 
    691 ## Payload for the Last Node
    692 
    693 When building the route, the origin node MUST use a payload for
    694 the final node with the following values:
    695 
    696 * `payment_secret`: set to the payment secret specified by the recipient (e.g.
    697   `payment_secret` from a [BOLT #11](11-payment-encoding.md) payment invoice)
    698 * `outgoing_cltv_value`: set to the final expiry specified by the recipient (e.g.
    699   `min_final_cltv_expiry_delta` from a [BOLT #11](11-payment-encoding.md) payment invoice)
    700 * `amt_to_forward`: set to the final amount specified by the recipient (e.g. `amount`
    701   from a [BOLT #11](11-payment-encoding.md) payment invoice)
    702 
    703 This allows the final node to check these values and return errors if needed,
    704 but it also eliminates the possibility of probing attacks by the second-to-last
    705 node. Such attacks could, otherwise, attempt to discover if the receiving peer is the
    706 last one by re-sending HTLCs with different amounts/expiries.
    707 The final node will extract its onion payload from the HTLC it has received and
    708 compare its values against those of the HTLC. See the
    709 [Returning Errors](#returning-errors) section below for more details.
    710 
    711 If not for the above, since it need not forward payments, the final node could
    712 simply discard its payload.
    713 
    714 # Shared Secret
    715 
    716 The origin node establishes a shared secret with each hop along the route using
    717 Elliptic-curve Diffie-Hellman between the sender's ephemeral key at that hop and
    718 the hop's node ID key. The resulting curve point is serialized to the
    719 compressed format and hashed using `SHA256`. The hash output is used
    720 as the 32-byte shared secret.
    721 
    722 Elliptic-curve Diffie-Hellman (ECDH) is an operation on an EC private key and
    723 an EC public key that outputs a curve point. For this protocol, the ECDH
    724 variant implemented in `libsecp256k1` is used, which is defined over the
    725 `secp256k1` elliptic curve. During packet construction, the sender uses the
    726 ephemeral private key and the hop's public key as inputs to ECDH, whereas
    727 during packet forwarding, the hop uses the ephemeral public key and its own
    728 node ID private key. Because of the properties of ECDH, they will both derive
    729 the same value.
    730 
    731 # Blinding Ephemeral Onion Keys
    732 
    733 In order to ensure multiple hops along the route cannot be linked by the
    734 ephemeral public keys they see, the key is blinded at each hop. The blinding is
    735 done in a deterministic way that allows the sender to compute the
    736 corresponding blinded private keys during packet construction.
    737 
    738 The blinding of an EC public key is a single scalar multiplication of
    739 the EC point representing the public key with a 32-byte blinding factor. Due to
    740 the commutative property of scalar multiplication, the blinded private key is
    741 the multiplicative product of the input's corresponding private key with the
    742 same blinding factor.
    743 
    744 The blinding factor itself is computed as a function of the ephemeral public key
    745 and the 32-byte shared secret. Concretely, it is the `SHA256` hash value of the
    746 concatenation of the public key serialized in its compressed format and the
    747 shared secret.
    748 
    749 # Packet Construction
    750 
    751 In the following example, it's assumed that a _sending node_ (origin node),
    752 `n_0`, wants to route a packet to a _receiving node_ (final node), `n_r`.
    753 First, the sender computes a route `{n_0, n_1, ..., n_{r-1}, n_r}`, where `n_0`
    754 is the sender itself and `n_r` is the final recipient. All nodes `n_i` and
    755 `n_{i+1}` MUST be peers in the overlay network route. The sender then gathers the
    756 public keys for `n_1` to `n_r` and generates a random 32-byte `sessionkey`.
    757 Optionally, the sender may pass in _associated data_, i.e. data that the
    758 packet commits to but that is not included in the packet itself. Associated
    759 data will be included in the HMACs and must match the associated data provided
    760 during integrity verification at each hop. The `payment_hash` is commonly used for
    761 this purpose.
    762 
    763 To construct the onion, the sender initializes the ephemeral private key for the
    764 first hop `ek_1` to the `sessionkey` and derives from it the corresponding
    765 ephemeral public key `epk_1` by multiplying with the `secp256k1` base point. For
    766 each of the `k` hops along the route, the sender then iteratively computes the
    767 shared secret `ss_k` and ephemeral key for the next hop `ek_{k+1}` as follows:
    768 
    769  - The sender executes ECDH with the hop's public key and the ephemeral private
    770  key to obtain a curve point, which is hashed using `SHA256` to produce the
    771  shared secret `ss_k`.
    772  - The blinding factor is the `SHA256` hash of the concatenation between the
    773  ephemeral public key `epk_k` and the shared secret `ss_k`.
    774  - The ephemeral private key for the next hop `ek_{k+1}` is computed by
    775  multiplying the current ephemeral private key `ek_k` by the blinding factor.
    776  - The ephemeral public key for the next hop `epk_{k+1}` is derived from the
    777  ephemeral private key `ek_{k+1}` by multiplying with the base point.
    778 
    779 Once the sender has all the required information above, it can construct the
    780 packet. Constructing a packet routed over `r` hops requires `r` 32-byte
    781 ephemeral public keys, `r` 32-byte shared secrets, `r` 32-byte blinding factors,
    782 and `r` variable length `hop_payload` payloads.
    783 The construction returns a single 1366-byte packet along with the first receiving peer's address.
    784 
    785 The packet construction is performed in the reverse order of the route, i.e.
    786 the last hop's operations are applied first.
    787 
    788 The packet is initialized with 1300 _random_ bytes derived from a CSPRNG
    789 (ChaCha20). The _pad_ key referenced above is used to extract additional random
    790 bytes from a ChaCha20 stream, using it as a CSPRNG for this purpose.  Once the
    791 `paddingKey` has been obtained, ChaCha20 is used with an all zero nonce, to
    792 generate 1300 random bytes. Those random bytes are then used as the starting
    793 state of the mix-header to be created.
    794 
    795 A filler is generated (see [Filler Generation](#filler-generation)) using the
    796 shared secret.
    797 
    798 For each hop in the route, in reverse order, the sender applies the
    799 following operations:
    800 
    801  - The _rho_-key and _mu_-key are generated using the hop's shared secret.
    802  - `shift_size` is defined as the length of the `hop_payload` plus the bigsize encoding of the length and the length of that HMAC. Thus if the payload length is `l` then the `shift_size` is `1 + l + 32` for `l < 253`, otherwise `3 + l + 32` due to the bigsize encoding of `l`.
    803  - The `hop_payloads` field is right-shifted by `shift_size` bytes, discarding the last `shift_size`
    804  bytes that exceed its 1300-byte size.
    805  - The bigsize-serialized length, serialized `hop_payload` and `hmac` are copied into the `shift_size` bytes as the
    806    beginning of the mix-header.
    807  - The _rho_-key is used to generate a 1300 byte pseudo-random stream
    808    which is then applied, with `XOR`, to the `hop_payloads` field.
    809  - If this is the last hop, i.e. the first iteration, then the tail of the
    810  `hop_payloads` field is overwritten with the routing information `filler`.
    811  - The next HMAC is computed (with the _mu_-key as HMAC-key) over the
    812  concatenated `hop_payloads` and associated data.
    813 
    814 The resulting final HMAC value is the HMAC that will be used by the first
    815 receiving peer in the route.
    816 
    817 The packet generation returns a serialized packet that contains the `version`
    818 byte, the ephemeral pubkey for the first hop, the HMAC for the first hop, and
    819 the obfuscated `hop_payloads`.
    820 
    821 The following Go code is an example implementation of the packet construction:
    822 
    823 ```Go
    824 const RoutingInfoSize int32 = 1300
    825 
    826 func NewOnionPacket(paymentPath []*btcec.PublicKey, sessionKey *btcec.PrivateKey,
    827 	hopsData []HopData, assocData []byte) (*OnionPacket, error) {
    828 
    829 	numHops := len(paymentPath)
    830 	hopSharedSecrets := make([][sha256.Size]byte, numHops)
    831 
    832 	// Initialize ephemeral key for the first hop to the session key.
    833 	var ephemeralKey big.Int
    834 	ephemeralKey.Set(sessionKey.D)
    835 
    836 	for i := 0; i < numHops; i++ {
    837 		// Perform ECDH and hash the result.
    838 		ecdhResult := scalarMult(paymentPath[i], ephemeralKey)
    839 		hopSharedSecrets[i] = sha256.Sum256(ecdhResult.SerializeCompressed())
    840 
    841 		// Derive ephemeral public key from private key.
    842 		ephemeralPrivKey := btcec.PrivKeyFromBytes(btcec.S256(), ephemeralKey.Bytes())
    843 		ephemeralPubKey := ephemeralPrivKey.PubKey()
    844 
    845 		// Compute blinding factor.
    846 		sha := sha256.New()
    847 		sha.Write(ephemeralPubKey.SerializeCompressed())
    848 		sha.Write(hopSharedSecrets[i])
    849 
    850 		var blindingFactor big.Int
    851 		blindingFactor.SetBytes(sha.Sum(nil))
    852 
    853 		// Blind ephemeral key for next hop.
    854 		ephemeralKey.Mul(&ephemeralKey, &blindingFactor)
    855 		ephemeralKey.Mod(&ephemeralKey, btcec.S256().Params().N)
    856 	}
    857 
    858 	// Generate the padding, called "filler strings" in the paper.
    859 	filler := generateHeaderPadding(numHops, hopSharedSecrets)
    860 
    861 	// Allocate and initialize fields to zero-filled slices
    862 	var mixHeader [RoutingInfoSize]byte
    863 	var nextHmac [32]byte
    864         
    865   // Our starting packet needs to be filled out with random bytes, we
    866   // generate some deterministically using the session private key.
    867   paddingKey := generateKey("pad", sessionKey.Serialize())
    868   paddingBytes := generateCipherStream(paddingKey, RoutingInfoSize)
    869   copy(mixHeader[:], paddingBytes)
    870 
    871 	// Compute the routing information for each hop along with a
    872 	// MAC of the routing information using the shared key for that hop.
    873 	for i := numHops - 1; i >= 0; i-- {
    874 		rhoKey := generateKey("rho", hopSharedSecrets[i])
    875 		muKey := generateKey("mu", hopSharedSecrets[i])
    876 
    877 		hopsData[i].HMAC = nextHmac
    878 
    879 		// Shift and obfuscate routing information
    880 		streamBytes := generateCipherStream(rhoKey, RoutingInfoSize)
    881 
    882 		rightShift(mixHeader[:], hopDataSize)
    883 		buf := &bytes.Buffer{}
    884 		hopsData[i].Encode(buf)
    885 		copy(mixHeader[:], buf.Bytes())
    886 		xor(mixHeader[:], mixHeader[:], streamBytes[:RoutingInfoSize])
    887 
    888 		// These need to be overwritten, so every node generates a correct padding
    889 		if i == numHops-1 {
    890 			copy(mixHeader[len(mixHeader)-len(filler):], filler)
    891 		}
    892 
    893 		packet := append(mixHeader[:], assocData...)
    894 		nextHmac = calcMac(muKey, packet)
    895 	}
    896 
    897 	packet := &OnionPacket{
    898 		Version:      0x00,
    899 		EphemeralKey: sessionKey.PubKey(),
    900 		RoutingInfo:  mixHeader,
    901 		HeaderMAC:    nextHmac,
    902 	}
    903 	return packet, nil
    904 }
    905 ```
    906 
    907 # Onion Decryption
    908 
    909 There are two kinds of `onion_packet` we use:
    910 
    911 1. `onion_routing_packet` in `update_add_htlc` for payments, which contains a `payload` TLV (see [Adding an HTLC](02-peer-protocol.md#adding-an-htlc-update_add_htlc))
    912 2. `onion_message_packet` in `onion_message` for messages, which contains an `onionmsg_tlv` TLV (see [Onion Messages](#onion-messages))
    913 
    914 Those sections specify the `associated_data` to use, the `path_key` (if any), the extracted payload format and handling (including how to determine the next peer, if any), and how to handle errors.  The processing itself is identical.
    915 
    916 ## Requirements
    917 
    918 A reader:
    919   - if `version` is not 0:
    920     - MUST abort processing the packet and fail.
    921   - if `public_key` is not a valid pubkey:
    922     - MUST abort processing the packet and fail.
    923   - if the onion is for a payment:
    924     - if `hmac` has previously been received:
    925       - if the preimage is known:
    926         - MAY immediately redeem the HTLC using the preimage.
    927       - otherwise:
    928         - MUST abort processing the packet and fail.
    929   - if `path_key` is specified:
    930     - Calculate the `blinding_ss` as ECDH(`path_key`, `node_privkey`).
    931     - Either:
    932       - Tweak `public_key` by multiplying by $`HMAC256(\text{"blinded\_node\_id"}, blinding\_ss)`$.
    933     - or (equivalently):
    934       - Tweak its own `node_privkey` below by multiplying by $`HMAC256(\text{"blinded\_node\_id"}, blinding\_ss)`$.
    935   - Derive the shared secret `ss` as ECDH(`public_key`, `node_privkey`) (see [Shared Secret](#shared-secret)).
    936   - Derive `mu` as $`HMAC256(\text{"mu"}, ss)`$ (see [Key Generation](#key-generation)).
    937   - Derive the HMAC as $`HMAC256(mu, hop\_payloads || associated\_data)`$.
    938   - MUST use a constant time comparison of the computed HMAC and `hmac`.
    939   - If the computed HMAC and `hmac` differ:
    940     - MUST abort processing the packet and fail.
    941   - Derive `rho` as $`HMAC256(\text{"rho"}, ss)`$ (see [Key Generation](#key-generation)).
    942   - Derive `bytestream` of twice the length of `hop_payloads` using `rho` (see [Pseudo Random Byte Stream](pseudo-random-byte-stream)).
    943   - Set `unwrapped_payloads` to the XOR of `hop_payloads` and `bytestream`.
    944   - Remove a `bigsize` from the front of `unwrapped_payloads` as `payload_length`.  If that is malformed:
    945     - MUST abort processing the packet and fail.
    946   - If the `payload_length` is less than two:
    947     - MUST abort processing the packet and fail.
    948   - If there are fewer than `payload_length` bytes remaining in `unwrapped_payloads`:
    949     - MUST abort processing the packet and fail.
    950   - Remove `payload_length` bytes from the front of `unwrapped_payloads`, as the current `payload`.
    951   - If there are fewer than 32 bytes remaining in `unwrapped_payloads`:
    952     - MUST abort processing the packet and fail.
    953   - Remove 32 bytes as `next_hmac` from the front of `unwrapped_payloads`.
    954   - If `unwrapped_payloads` is smaller than `hop_payloads`:
    955     - MUST abort processing the packet and fail.
    956   - If `next_hmac` is not all-zero (not the final node):
    957     - Derive `blinding_tweak` as $`SHA256(public\_key || ss)`$ (see [Blinding Ephemeral Onion Keys](#blinding-ephemeral-onion-keys)).
    958     - SHOULD forward an onion to the next peer with:
    959       - `version` set to 0.
    960       - `public_key` set to the incoming `public_key` multiplied by `blinding_tweak`.
    961       - `hop_payloads` set to the `unwrapped_payloads`, truncated to the incoming `hop_payloads` size.
    962       - `hmac` set to `next_hmac`.
    963     - If it cannot forward:
    964       - MUST fail.
    965   - Otherwise (all-zero `next_hmac`):
    966     - This is the final destination of the onion.
    967 
    968 ## Rationale
    969 
    970 In the case where blinded paths are used, the sender did not actually encrypt this onion for our `node_id`, but for a tweaked version: we can derive the tweak used from `path_key` which is given alongside the onion.  Then we either tweak our node private key the same way to decrypt the onion, or tweak to the onion ephemeral key which is mathematically equivalent.
    971 
    972 # Filler Generation
    973 
    974 Upon receiving a packet, the processing node extracts the information destined
    975 for it from the route information and the per-hop payload.
    976 The extraction is done by deobfuscating and left-shifting the field.
    977 This would make the field shorter at each hop, allowing an attacker to deduce the
    978 route length. For this reason, the field is pre-padded before forwarding.
    979 Since the padding is part of the HMAC, the origin node will have to pre-generate an
    980 identical padding (to that which each hop will generate) in order to compute the
    981 HMACs correctly for each hop.
    982 The filler is also used to pad the field-length, in the case that the selected
    983 route is shorter than 1300 bytes.
    984 
    985 Before deobfuscating the `hop_payloads`, the processing node pads it with 1300
    986 `0x00`-bytes, such that the total length is `2*1300`.
    987 It then generates the pseudo-random byte stream, of matching length, and applies
    988 it with `XOR` to the `hop_payloads`.
    989 This deobfuscates the information destined for it, while simultaneously
    990 obfuscating the added `0x00`-bytes at the end.
    991 
    992 In order to compute the correct HMAC, the origin node has to pre-generate the
    993 `hop_payloads` for each hop, including the incrementally obfuscated padding added
    994 by each hop. This incrementally obfuscated padding is referred to as the
    995 `filler`. Keep in mind that while the mix-header is generated in reverse-route order,
    996 the filler is generated in route order.
    997 
    998 The following example code shows how the filler is generated in Go:
    999 
   1000 ```Go
   1001 const (
   1002   // The mix-header in Lightning is a max of 1300 bytes
   1003   NumMaxHops int = 20
   1004   HopSize = 65
   1005 )
   1006 
   1007 func generateFiller(numHops int, sharedSecrets [][sharedSecretSize]byte) []byte {
   1008 	fillerSize := uint((NumMaxHops + 1) * HopSize)
   1009 	filler := make([]byte, fillerSize)
   1010 
   1011 	// The last hop does not obfuscate, it's not forwarding anymore.
   1012 	for i := 0; i < numHops-1; i++ {
   1013 
   1014 		// Left-shift the field
   1015 		copy(filler[:], filler[HopSize:])
   1016 
   1017 		// Zero-fill the last hop
   1018 		copy(filler[len(filler)-HopSize:], bytes.Repeat([]byte{0x00}, HopSize))
   1019 
   1020 		// Generate pseudo-random byte stream
   1021 		streamKey := generateKey("rho", sharedSecrets[i])
   1022 		streamBytes := generateCipherStream(streamKey, fillerSize)
   1023 
   1024 		// Obfuscate
   1025 		xor(filler, filler, streamBytes)
   1026 	}
   1027 
   1028 	// Cut filler down to the correct length (numHops+1)*HopSize
   1029 	// bytes will be prepended by the packet generation.
   1030 	return filler[(NumMaxHops-numHops+2)*HopSize:]
   1031 }
   1032 ```
   1033 
   1034 Note that this example implementation is for demonstration purposes only; the
   1035 `filler` can be generated much more efficiently.
   1036 The last hop need not obfuscate the `filler`, since it won't forward the packet
   1037 any further and thus need not extract an HMAC either.
   1038 
   1039 # Returning Errors
   1040 
   1041 The onion routing protocol includes a mechanism for returning encrypted
   1042 error messages to the origin node.
   1043 The returned error messages may be failures reported by any hop, including the
   1044 final node.
   1045 The format of the forward packet is not usable for the return path, since no hop
   1046 besides the origin has access to the information required for its generation.
   1047 Note that these error messages are not reliable, as they are not placed on-chain
   1048 due to the possibility of hop failure.
   1049 
   1050 Return packets are limited to 32768 bytes (32 KiB), leaving room in `update_fail_htlc` for `attribution_data` and future
   1051 extensions. Earlier versions permitted larger return packets, so intermediate nodes truncate them to their first 32768
   1052 bytes instead of rejecting the corresponding message.
   1053 
   1054 Intermediate hops store the shared secret from the forward path and reuse it to
   1055 authenticate and obfuscate any corresponding return packet during each hop.
   1056 In addition, each node locally stores data regarding its own sending peer in the
   1057 route, so it knows where to return-forward any eventual return packets.
   1058 
   1059 ## Erring node
   1060 
   1061 The node generating the error message builds a _return packet_
   1062 consisting of the following fields:
   1063 
   1064 1. data:
   1065    * [`32*byte`:`hmac`]
   1066    * [`u16`:`failure_len`]
   1067    * [`failure_len*byte`:`failuremsg`]
   1068    * [`u16`:`pad_len`]
   1069    * [`pad_len*byte`:`pad`]
   1070 
   1071 Where `hmac` is an HMAC authenticating the remainder of the packet, with a key
   1072 generated using the above process, with key type `um`, `failuremsg` as defined
   1073 below, and `pad` as the extra bytes used to conceal length.
   1074 
   1075 The erring node then generates a new key, using the key type `ammag`.
   1076 This key is then used to generate a pseudo-random stream, which is in turn
   1077 applied to the packet using `XOR`.
   1078 
   1079 Error handling for HTLCs with `path_key` is particularly fraught,
   1080 since differences in implementations (or versions) may be leveraged to
   1081 de-anonymize elements of the blinded path. Thus the decision turn every
   1082 error into `invalid_onion_blinding` which will be converted to a normal
   1083 onion error by the introduction point.
   1084 
   1085 ### Initialization of `attribution_data`
   1086 
   1087 For the layout of `attribution data`, see [Removing an HTLC: `update_fulfill_htlc`, `update_fail_htlc`, and
   1088 `update_fail_malformed_htlc`](02-peer-protocol.md#removing-an-htlc-update_fulfill_htlc-update_fail_htlc-and-update_fail_malformed_htlc).
   1089 
   1090 The `htlc_hold_times` field specifies the htlc hold time for each hop in units of 100 milliseconds. For example, a value
   1091 of 3 represents 300 ms. Nodes along the path that lack accurate timing information may report a value of zero.
   1092 
   1093 The erring node puts its hold time at the start of this array and zeroes out the rest. The size of the field is based on
   1094 the maximum supported number of hops in a route (20).
   1095 
   1096 The field `truncated_hmacs` contains truncated authentication codes series for each hop, with the same `um` key that is
   1097 used for `hmac` in the return packet. Regular 32 byte HMACs are truncated to the first 4 bytes to save space.
   1098 
   1099 In theory this truncation makes it possible for malicious nodes to guess the HMAC. However, game theory is against them
   1100 because a wrong guess will get them penalized in future pathfinding.
   1101 
   1102 The size of the field is based on the maximum number of hops in a route (20) and the truncated HMAC size (4 bytes). Each
   1103 hop adds 20 HMACs, one for each possible position that the hop could be at in the path. This is necessary because only
   1104 the sender knows the position of each hop in the path.
   1105 
   1106 It is not required to store all 20 * 20 = 400 HMACs. The node in position 0 needs to store an HMAC for every one of the
   1107 20 positions. For the node in position 1, the maximum remaining route length is only 19. For that position just 19 HMACs
   1108 need to be kept, and so on. This makes for a total number of HMACs of 20+19+18+...+1 = 210 HMACs.
   1109 
   1110 The layout of the `hmacs` field is shown below. The actual format is much longer, but for readability the format is
   1111 described as if the maximum route length would be just three hops.
   1112 
   1113 `hmac_0_2` | `hmac_0_1`| `hmac_0_0`| `hmac_1_1`| `hmac_1_0`| `hmac_2_0`
   1114 
   1115 `hmac_x_y` is the hmac added by node `x` (counted from the node that is currently handling the failure message) assuming
   1116 that this node is `y` hops away from the erring node.
   1117 
   1118 Each HMAC is computed from the combination of the following elements, concatenated in the specified order.
   1119 
   1120 * The return packet before applying the pseudo-random byte stream.
   1121 
   1122 * The concatenation of the first `y+1` hold times in `htlc_hold_times`. For example, `hmac_0_2` would cover
   1123   all three hold times.
   1124 
   1125 * The concatenation of `y` downstream hmacs that correspond to downstream node positions relative to `x`. For example,
   1126   `hmac_0_2` would cover `hmac_1_1` and `hmac_2_0`.
   1127 
   1128 The erring node stores its 20 HMACs at the start of the array and zeroes out the rest. Strictly speaking the erring node
   1129 would only need to add the single `hmac_0_0` here, because there is no downstream data to cover. However, for
   1130 verification efficiency at the origin node, we still require all HMACs to be calculated. The redundant HMACs will cover
   1131 portions of the zero-initialized data.
   1132 
   1133 Finally a new key is generated, using the key type `ammagext`. This key is then used to generate a pseudo-random stream,
   1134 which is in turn applied to the `attribution_data` field using `XOR`.
   1135 
   1136 ### Requirements
   1137 
   1138 The _erring node_:
   1139   - MUST construct the return packet such that its total length is no more than 32768 bytes (32 KiB).
   1140   - MUST set `pad` such that the `failure_len` plus `pad_len` is at least 256.
   1141   - SHOULD set `pad` such that the `failure_len` plus `pad_len` is equal to
   1142     256. Deviating from this may cause older nodes to be unable to parse the
   1143     return message.
   1144   - if `option_attribution_data` is advertised:
   1145     - if `path_key` is not set in the incoming `update_add_htlc`:
   1146       - MUST initialize `attribution_data` and include it in `update_fail_htlc`
   1147 
   1148 ## Intermediate nodes
   1149 
   1150 ### Transformation of the return packet
   1151 
   1152 Generate the node's `ammag` key, generate the pseudo-random byte streams, and apply the result to obfuscate the return
   1153 packet. This is then stored as the `reason` field of the `update_htlc_fail` message.
   1154 
   1155   This obfuscation step is identical to the obfuscation steps that the erring node carries out.
   1156 
   1157 ### Transformation of `attribution_data`  
   1158 
   1159 * Shift all existing hold times to the right (4 bytes).
   1160 
   1161 * Shift and prune all existing HMACs.
   1162 
   1163   At each step backwards, one HMAC for every hop can be pruned. When HMACs for all 20 positions are present, and it
   1164   turns out that there is another hop upstream, each existing HMAC that now corresponds to position 21 due to the
   1165   preceding hop becomes obsolete.
   1166 
   1167   For the simplified three-hop layout above, the shift/prune operation would apply a transformation that results in:
   1168 
   1169   `-` | `-` | `-` | `hmac_0'_1` | `hmac_0'_0` | `hmac_1'_0`
   1170 
   1171   The former `hmac_x'_y` now becomes `hmac_x+1_y`. The left-most HMAC for
   1172   each hop is discarded.
   1173 
   1174 ### Update of `attribution_data`
   1175 
   1176 * Put the node's hold time at the start of `htlc_hold_times`. The shift operation above has opened up a slot for that.
   1177 
   1178 * Calculate its own 20 truncated HMACs and put them at the start of `hmacs` in the
   1179   newly opened slots.
   1180 
   1181 * Generate the node's `ammagext` key, generate the pseudo-random byte stream, and apply the result to obfuscate the
   1182   `attribution_data` field. This obfuscation step is identical to the obfuscation steps that the erring node carries out.
   1183 
   1184 ### Requirements
   1185 
   1186 The _intermediate node_:
   1187   - if the return packet received from downstream is longer than 32768 bytes:
   1188     - MUST truncate it to its first 32768 bytes before transforming the return packet or updating `attribution_data`
   1189   - if `option_attribution_data` is advertised:
   1190     - if `path_key` is not set in the incoming `update_add_htlc`:
   1191       - if `attribution_data` is received from downstream:
   1192         - MUST transform `attribution_data` as described above
   1193       - otherwise:
   1194         - MUST instantiate an all-zeroes `attribution_data` block
   1195       - MUST update `attribution_data` as described above
   1196   - MUST transform the return packet as described above.
   1197   - MUST return-forward the `update_htlc_fail` message
   1198 
   1199 ## Origin node
   1200 
   1201 The origin node is able to detect that it's the intended final recipient of the return message, because of course, it
   1202 was the originator of the corresponding forward packet. When an origin node receives an `update_htlc_fail` message
   1203 matching a transfer it initiated (i.e. it cannot return-forward the error any further) it generates the `ammag`,
   1204 `ammagext` and `um` keys for each hop in the route.
   1205 
   1206 It then iteratively decrypts the message, using each hop's `ammag` and `ammagext` keys. At each hop, the following steps
   1207 are carried out:
   1208 
   1209 For origin nodes supporting `option_attribution_data`:
   1210 
   1211 * Verify the HMAC in `attribution_data` that corresponds to the hop's position in the path using the hop's `um` key. If
   1212   the HMAC is invalid, processing of the message can stop and the node should penalize this hop for future path selection. This is what
   1213   makes the failure 'attributable'.
   1214 
   1215   Because HMACs cover all data including HMACs added by downstream nodes, it is not possible for a malicious node to
   1216   tamper with the message without revealing themselves. Blame is still only assignable to a pair of nodes though,
   1217   because it is impossible to know whether sender or receiver modified the message. This is true for other failure cases
   1218   in Lightning too.
   1219 
   1220   When not every path node supports `option_attribution_data`, the origin node will still have attribution data up to the first node
   1221   downstream without support.
   1222 
   1223 * Record the reported htlc hold time for this hop.
   1224 
   1225   The origin node can use this information to score nodes on latency. When a zero hold time is reported, the origin node
   1226   should distribute any potential latency penalty across multiple nodes. This encourages path nodes to provide timing
   1227   data to avoid being held responsible for the high latency of other nodes.
   1228 
   1229 For all nodes:
   1230 
   1231 * Compute the HMAC for the return packet, using the hop's `um` key.
   1232 
   1233 * When the computed HMAC matches `hmac` in the return packet, the origin node will know that the current hop is the sender of
   1234   the failure. They can then parse `failuremsg`.
   1235 
   1236 The association between the forward and return packets is handled outside of this onion routing protocol, e.g. via
   1237 association with an HTLC in a payment channel.
   1238 
   1239 ### Requirements
   1240 
   1241 The _origin node_:
   1242   - once the return message has been decrypted:
   1243     - SHOULD store a copy of the message.
   1244     - SHOULD continue decrypting, until the loop has been repeated 27 times
   1245     (maximum route length of tlv payload type).
   1246     - SHOULD use constant `ammag` and `um` keys to obfuscate the route length.
   1247   - When the failure source cannot be identified from the return packet AND `attribution_data` is present:
   1248     - SHOULD use `attribution_data` to identify the failure source
   1249 
   1250 ### Rationale
   1251 
   1252 The requirements for the _origin node_ should help hide the payment sender.
   1253 By continuing decrypting 27 times (dummy decryption cycles after the error is found)
   1254 the erroring node cannot learn its relative position in the route by performing
   1255 a timing analysis if the sender were to retry the same route multiple times.
   1256 
   1257 ## Failure Messages
   1258 
   1259 The failure message encapsulated in `failuremsg` has an identical format as
   1260 a normal message: a 2-byte type `failure_code` followed by data applicable
   1261 to that type. The message data is followed by an optional
   1262 [TLV stream](01-messaging.md#type-length-value-format).
   1263 
   1264 Below is a list of the currently supported `failure_code`
   1265 values, followed by their use case requirements.
   1266 
   1267 Notice that the `failure_code`s are not of the same type as other message types,
   1268 defined in other BOLTs, as they are not sent directly on the transport layer
   1269 but are instead wrapped inside return packets.
   1270 The numeric values for the `failure_code` may therefore reuse values, that are
   1271 also assigned to other message types, without any danger of causing collisions.
   1272 
   1273 The top byte of `failure_code` can be read as a set of flags:
   1274 * 0x8000 (BADONION): unparsable onion encrypted by sending peer
   1275 * 0x4000 (PERM): permanent failure (otherwise transient)
   1276 * 0x2000 (NODE): node failure (otherwise channel)
   1277 * 0x1000 (UPDATE): channel forwarding parameter was violated
   1278 
   1279 The following `failure_code`s are defined:
   1280 
   1281 1. type: NODE|2 (`temporary_node_failure`)
   1282 
   1283 General temporary failure of the processing node.
   1284 
   1285 1. type: PERM|NODE|2 (`permanent_node_failure`)
   1286 
   1287 General permanent failure of the processing node.
   1288 
   1289 1. type: PERM|NODE|3 (`required_node_feature_missing`)
   1290 
   1291 The processing node has a required feature which was not in this onion.
   1292 
   1293 1. type: BADONION|PERM|4 (`invalid_onion_version`)
   1294 2. data:
   1295    * [`sha256`:`sha256_of_onion`]
   1296 
   1297 The `version` byte was not understood by the processing node.
   1298 
   1299 1. type: BADONION|PERM|5 (`invalid_onion_hmac`)
   1300 2. data:
   1301    * [`sha256`:`sha256_of_onion`]
   1302 
   1303 The HMAC of the onion was incorrect when it reached the processing node.
   1304 
   1305 1. type: BADONION|PERM|6 (`invalid_onion_key`)
   1306 2. data:
   1307    * [`sha256`:`sha256_of_onion`]
   1308 
   1309 The ephemeral key was unparsable by the processing node.
   1310 
   1311 1. type: UPDATE|7 (`temporary_channel_failure`)
   1312 2. data:
   1313    * [`u16`:`len`]
   1314    * [`len*byte`:`channel_update`]
   1315 
   1316 The channel from the processing node was unable to handle this HTLC,
   1317 but may be able to handle it, or others, later.
   1318 
   1319 1. type: PERM|8 (`permanent_channel_failure`)
   1320 
   1321 The channel from the processing node is unable to handle any HTLCs.
   1322 
   1323 1. type: PERM|9 (`required_channel_feature_missing`)
   1324 
   1325 The channel from the processing node requires features not present in
   1326 the onion.
   1327 
   1328 1. type: PERM|10 (`unknown_next_peer`)
   1329 
   1330 The onion specified a `short_channel_id` which doesn't match any
   1331 leading from the processing node.
   1332 
   1333 1. type: UPDATE|11 (`amount_below_minimum`)
   1334 2. data:
   1335    * [`u64`:`htlc_msat`]
   1336    * [`u16`:`len`]
   1337    * [`len*byte`:`channel_update`]
   1338 
   1339 The HTLC amount was below the `htlc_minimum_msat` of the channel from
   1340 the processing node.
   1341 
   1342 1. type: UPDATE|12 (`fee_insufficient`)
   1343 2. data:
   1344    * [`u64`:`htlc_msat`]
   1345    * [`u16`:`len`]
   1346    * [`len*byte`:`channel_update`]
   1347 
   1348 The fee amount was below that required by the channel from the
   1349 processing node.
   1350 
   1351 1. type: UPDATE|13 (`incorrect_cltv_expiry`)
   1352 2. data:
   1353    * [`u32`:`cltv_expiry`]
   1354    * [`u16`:`len`]
   1355    * [`len*byte`:`channel_update`]
   1356 
   1357 The `cltv_expiry` does not comply with the `cltv_expiry_delta` required by
   1358 the channel from the processing node: it does not satisfy the following
   1359 requirement:
   1360 
   1361         cltv_expiry - cltv_expiry_delta >= outgoing_cltv_value
   1362 
   1363 1. type: UPDATE|14 (`expiry_too_soon`)
   1364 2. data:
   1365    * [`u16`:`len`]
   1366    * [`len*byte`:`channel_update`]
   1367 
   1368 The CLTV expiry is too close to the current block height for safe
   1369 handling by the processing node.
   1370 
   1371 1. type: PERM|15 (`incorrect_or_unknown_payment_details`)
   1372 2. data:
   1373    * [`u64`:`htlc_msat`]
   1374    * [`u32`:`height`]
   1375 
   1376 The `payment_hash` is unknown to the final node, the `payment_secret` doesn't
   1377 match the `payment_hash`, the amount for that `payment_hash` is too low,
   1378 the CLTV expiry of the htlc is too close to the current block height for safe
   1379 handling or `payment_metadata` isn't present while it should be.
   1380 
   1381 The `htlc_msat` parameter is superfluous, but left in for backwards
   1382 compatibility. The value of `htlc_msat` is required to be at least the value
   1383 specified in the final hop onion payload. It therefore does not have any
   1384 substantial informative value to the sender (though may indicate the
   1385 penultimate node took a lower fee than expected). A penultimate hop sending an
   1386 amount or an expiry that is too low for the htlc is handled through
   1387 `final_incorrect_cltv_expiry` and `final_incorrect_htlc_amount`.
   1388 
   1389 The `height` parameter is set by the final node to the best known block height
   1390 at the time of receiving the htlc. This can be used by the sender to distinguish
   1391 between sending a payment with the wrong final CLTV expiry and an intermediate
   1392 hop delaying the payment so that the receiver's invoice CLTV delta requirement
   1393 is no longer met.
   1394 
   1395 Note: Originally PERM|16 (`incorrect_payment_amount`) and 17
   1396 (`final_expiry_too_soon`) were used to differentiate incorrect htlc parameters
   1397 from unknown payment hash. Sadly, sending this response allows for probing
   1398 attacks whereby a node which receives an HTLC for forwarding can check guesses
   1399 as to its final destination by sending payments with the same hash but much
   1400 lower values or expiry heights to potential destinations and check the response.
   1401 Care must be taken by implementations to differentiate the previously
   1402 non-permanent case for `final_expiry_too_soon` (17) from the other, permanent
   1403 failures now represented by `incorrect_or_unknown_payment_details` (PERM|15).
   1404 
   1405 1. type: 18 (`final_incorrect_cltv_expiry`)
   1406 2. data:
   1407    * [`u32`:`cltv_expiry`]
   1408 
   1409 The CLTV expiry in the HTLC is less than the value in the onion.
   1410 
   1411 1. type: 19 (`final_incorrect_htlc_amount`)
   1412 2. data:
   1413    * [`u64`:`incoming_htlc_amt`]
   1414 
   1415 The amount in the HTLC is less than the value in the onion.
   1416 
   1417 1. type: UPDATE|20 (`channel_disabled`)
   1418 2. data:
   1419    * [`u16`:`disabled_flags`]
   1420    * [`u16`:`len`]
   1421    * [`len*byte`:`channel_update`]
   1422 
   1423 The channel from the processing node has been disabled.
   1424 No flags for `disabled_flags` are currently defined, thus it is currently
   1425 always two zero bytes.
   1426 
   1427 1. type: 21 (`expiry_too_far`)
   1428 
   1429 The CLTV expiry in the HTLC is too far in the future.
   1430 
   1431 1. type: PERM|22 (`invalid_onion_payload`)
   1432 2. data:
   1433    * [`bigsize`:`type`]
   1434    * [`u16`:`offset`]
   1435 
   1436 The decrypted onion per-hop payload was not understood by the processing node
   1437 or is incomplete. If the failure can be narrowed down to a specific tlv type in
   1438 the payload, the erring node may include that `type` and its byte `offset` in
   1439 the decrypted byte stream.
   1440 
   1441 1. type: 23 (`mpp_timeout`)
   1442 
   1443 The complete amount of the multi-part payment was not received within a
   1444 reasonable time.
   1445 
   1446 1. type: BADONION|PERM|24 (`invalid_onion_blinding`)
   1447 2. data:
   1448    * [`sha256`:`sha256_of_onion`]
   1449 
   1450 An error occurred within the blinded path.
   1451 
   1452 ### Requirements
   1453 
   1454 An _erring node_:
   1455   - if `path_key` is set in the incoming `update_add_htlc`:
   1456     - MUST return an `invalid_onion_blinding` error.
   1457   - if `current_path_key` is set in the onion payload and it is not the
   1458     final node:
   1459     - MUST return an `invalid_onion_blinding` error.
   1460   - otherwise:
   1461     - MUST select one of the above error codes when creating an error message.
   1462     - MUST include the appropriate data for that particular error type.
   1463     - if there is more than one error:
   1464       - SHOULD select the first error it encounters from the list above.
   1465 
   1466 An _erring node_ MAY:
   1467   - if the per-hop payload in the onion is invalid (e.g. it is not a valid tlv stream)
   1468   or is missing required information (e.g. the amount was not specified):
   1469     - return an `invalid_onion_payload` error.
   1470   - if an otherwise unspecified transient error occurs for the entire node:
   1471     - return a `temporary_node_failure` error.
   1472   - if an otherwise unspecified permanent error occurs for the entire node:
   1473     - return a `permanent_node_failure` error.
   1474   - if a node has requirements advertised in its `node_announcement` `features`,
   1475   which were NOT included in the onion:
   1476     - return a `required_node_feature_missing` error.
   1477 
   1478 A _forwarding node_ MUST:
   1479   - if `path_key` is set in the incoming `update_add_htlc`:
   1480     - return an `invalid_onion_blinding` error.
   1481   - if `current_path_key` is set in the onion payload:
   1482     - return an `invalid_onion_blinding` error.
   1483   - otherwise:
   1484     - select one of the above error codes when creating an error message.
   1485 
   1486 A _forwarding node_ MAY, but a _final node_ MUST NOT:
   1487   - if during forwarding to its receiving peer, an otherwise unspecified,
   1488   transient error occurs in the outgoing channel (e.g. channel capacity reached,
   1489   too many in-flight HTLCs, etc.):
   1490     - return a `temporary_channel_failure` error.
   1491   - if an otherwise unspecified, permanent error occurs during forwarding to its
   1492   receiving peer (e.g. channel recently closed):
   1493     - return a `permanent_channel_failure` error.
   1494   - if the outgoing channel has requirements advertised in its
   1495   `channel_announcement`'s `features`, which were NOT included in the onion:
   1496     - return a `required_channel_feature_missing` error.
   1497   - if the receiving peer specified by the onion is NOT known:
   1498     - return an `unknown_next_peer` error.
   1499   - if the HTLC amount is less than the currently specified minimum amount:
   1500     - report the amount of the outgoing HTLC and the current channel setting for
   1501     the outgoing channel.
   1502     - return an `amount_below_minimum` error.
   1503   - if the HTLC does NOT pay a sufficient fee:
   1504     - report the amount of the incoming HTLC and the current channel setting for
   1505     the outgoing channel.
   1506     - return a `fee_insufficient` error.
   1507  -  if the incoming `cltv_expiry` minus the `outgoing_cltv_value` is below the
   1508     `cltv_expiry_delta` for the outgoing channel:
   1509     - report the `cltv_expiry` of the outgoing HTLC and the current channel setting for the outgoing
   1510     channel.
   1511     - return an `incorrect_cltv_expiry` error.
   1512   - if the `cltv_expiry` is unreasonably near the present:
   1513     - report the current channel setting for the outgoing channel.
   1514     - return an `expiry_too_soon` error.
   1515   - if the `cltv_expiry` is more than `max_htlc_cltv` in the future:
   1516     - return an `expiry_too_far` error.
   1517   - if the channel is disabled:
   1518     - report the current channel setting for the outgoing channel.
   1519     - return a `channel_disabled` error.
   1520 
   1521 A _forwarding node_ and a _final node_ MAY:
   1522   - if the onion `version` byte is unknown:
   1523     - return an `invalid_onion_version` error.
   1524   - if the onion HMAC is incorrect:
   1525     - return an `invalid_onion_hmac` error.
   1526   - if the ephemeral key in the onion is unparsable:
   1527     - return an `invalid_onion_key` error.
   1528 
   1529 A _forwarding node_ MUST NOT, but a _final node_ MUST:
   1530   - if the payment hash has already been paid:
   1531     - MAY treat the payment hash as unknown.
   1532     - MAY succeed in accepting the HTLC.
   1533   - if the `payment_secret` doesn't match the expected value for that `payment_hash`,
   1534     or the `payment_secret` is required and is not present:
   1535     - MUST fail the HTLC.
   1536     - MUST return an `incorrect_or_unknown_payment_details` error.
   1537   - if the amount paid is less than the amount expected:
   1538     - MUST fail the HTLC.
   1539     - MUST return an `incorrect_or_unknown_payment_details` error.
   1540   - if the payment hash is unknown:
   1541     - MUST fail the HTLC.
   1542     - MUST return an `incorrect_or_unknown_payment_details` error.
   1543   - if the amount paid is more than twice the amount expected:
   1544     - SHOULD fail the HTLC.
   1545     - SHOULD return an `incorrect_or_unknown_payment_details` error.
   1546       - Note: this allows the origin node to reduce information leakage by
   1547       altering the amount while not allowing for accidental gross overpayment.
   1548   - if the `cltv_expiry` value is unreasonably near the present:
   1549     - MUST fail the HTLC.
   1550     - MUST return an `incorrect_or_unknown_payment_details` error.
   1551   - if the `cltv_expiry` from the final node's HTLC is below `outgoing_cltv_value`:
   1552     - MUST return `final_incorrect_cltv_expiry` error.
   1553   - if `amount_msat` from the final node's HTLC is below `amt_to_forward`:
   1554     - MUST return a `final_incorrect_htlc_amount` error.
   1555   - if it returns a `channel_update`:
   1556     - MUST set `short_channel_id` to the `short_channel_id` used by the incoming onion.
   1557 
   1558 ### Rationale
   1559 
   1560 In the case of multiple short_channel_id aliases, the `channel_update`
   1561 `short_channel_id` should refer to the one the original sender is
   1562 expecting, to both avoid confusion and to avoid leaking information
   1563 about other aliases (or the real location of the channel UTXO).
   1564 
   1565 The `channel_update` field used to be mandatory in messages whose `failure_code`
   1566 includes the `UPDATE` flag. However, because nodes applying an update contained
   1567 in the onion to their gossip data is a massive fingerprinting vulnerability,
   1568 the `channel_update` field is no longer mandatory and nodes are expected to
   1569 transition away from including it. Nodes which do not provide a
   1570 `channel_update` are expected to set the `channel_update` `len` field to zero.
   1571 
   1572 Some nodes may still use the `channel_update` for retries of the same payment,
   1573 however.
   1574 
   1575 ## Receiving Failure Codes
   1576 
   1577 ### Requirements
   1578 
   1579 The _origin node_:
   1580   - MUST ignore any extra bytes in `failuremsg`.
   1581   - if the _final node_ is returning the error:
   1582     - if the PERM bit is set:
   1583       - SHOULD fail the payment.
   1584     - otherwise:
   1585       - if the error code is understood and valid:
   1586         - MAY retry the payment. In particular, `final_expiry_too_soon` can
   1587         occur if the block height has changed since sending, and in this case
   1588         `temporary_node_failure` could resolve within a few seconds.
   1589   - otherwise, an _intermediate hop_ is returning the error:
   1590     - if the NODE bit is set:
   1591       - SHOULD remove all channels connected with the erring node from
   1592       consideration.
   1593     - if the PERM bit is NOT set:
   1594       - SHOULD restore the channels as it receives new `channel_update`s from
   1595         its peers.
   1596     - otherwise:
   1597       - if UPDATE is set, AND the `channel_update` is valid and more recent
   1598         than the `channel_update` used to send the payment:
   1599         - MAY consider the `channel_update` when calculating routes to retry
   1600           the payment which failed
   1601       - MUST NOT expose the `channel_update` to third-parties in any other
   1602         context, including applying the `channel_update` to the local network
   1603         graph, send the `channel_update` to peers as gossip, etc.
   1604     - SHOULD then retry routing and sending the payment.
   1605   - MAY use the data specified in the various failure types for debugging
   1606   purposes.
   1607 
   1608 # Successful Payments
   1609 
   1610 The `update_fulfill_htlc` message contains an optional `attribution_data` field, identical to the one used in the
   1611 failure case described above. With attribution data, the sender can obtain hold times as reported and committed to by
   1612 each hop along the payment path.
   1613 
   1614 In addition, the final node can return data to the origin node in an optional `fulfillment_payload` field. It is the
   1615 success counterpart of the failure message that an erring node returns in the `reason` field of `update_fail_htlc`. The
   1616 final node builds the plaintext as a `fulfillment_payload_tlvs` [TLV stream](01-messaging.md#type-length-value-format):
   1617 
   1618 1. `tlv_stream`: `fulfillment_payload_tlvs`
   1619 2. types:
   1620     1. type: 1 (`padding`)
   1621     2. data:
   1622         * [`...*byte`:`padding`]
   1623 
   1624 `padding` conceals the length of the conveyed data and is ignored by the origin. Apart from `padding`, no record types
   1625 are defined yet.
   1626 
   1627 The final node generates a key using key type `fulfillment` and its shared secret with the origin node, then encrypts
   1628 this plaintext with ChaCha20-Poly1305 using that key and an all-zero nonce, as for `encrypted_recipient_data` in route
   1629 blinding. The ciphertext and its 16-byte tag are the `fulfillment_payload`. Each intermediate node then obfuscates the
   1630 `fulfillment_payload` with its `ammag` key, exactly as it obfuscates a failure return packet; the final node does not,
   1631 as the ciphertext is already confidential and forms the innermost layer. The
   1632 `attribution_data` HMACs added by intermediate nodes, which already cover the hold times, now additionally cover the
   1633 `fulfillment_payload`. For each intermediate HMAC, the covered fields are, in order: the `fulfillment_payload` as
   1634 received from the downstream node, before the current node applies its own `ammag` obfuscation; the hold times; and the
   1635 downstream HMACs. The final node's `attribution_data` HMACs do not cover the `fulfillment_payload`. With no payload
   1636 present, there is nothing extra for intermediate nodes to cover. The final node still initializes and updates
   1637 `attribution_data`, and the origin still verifies the final node's `attribution_data` HMACs for its reported hold time.
   1638 
   1639 A successful payment is relayed back with `update_fulfill_htlc`, so a `fulfillment_payload` propagates back through
   1640 every hop, even a blinded path: a blinded final node can originate it, and blinded hops obfuscate and relay it. The
   1641 origin can still recover it, because it shares a secret with every hop, blinded ones included, computed from each hop's
   1642 public key (the blinded public key for a blinded hop) when it built the onion. Returning a `fulfillment_payload` is
   1643 therefore not gated by the `path_key` condition that applies to `attribution_data`.
   1644 
   1645 The origin knows the number of hops in the path, so the final node is its last hop: the origin peels each intermediate
   1646 hop's `ammag` obfuscation, including obfuscation for blinded hops whose blinded public keys it used when constructing
   1647 the route, and decrypts the `fulfillment_payload` with the last hop's `fulfillment` key, one operation per hop. The
   1648 origin verifies the final node's `attribution_data` HMACs without a `fulfillment_payload` input. For each intermediate
   1649 hop, the origin removes that hop's `ammag` obfuscation from the `fulfillment_payload` and verifies the hop's
   1650 `attribution_data` HMACs over the resulting `fulfillment_payload` bytes. A recipient that conceals its position with
   1651 dummy hops in a blinded path must therefore originate the `fulfillment_payload` as though it were the last hop, applying
   1652 the obfuscation for the concealed hops itself, so that this decoding succeeds without revealing its position.
   1653 
   1654 The two integrity checks cover different extents. The Poly1305 tag is verified end-to-end and detects tampering by any
   1655 hop, blinded or not. The `attribution_data` HMACs are contributed only by hops with `path_key` not set, so they
   1656 provide per-hop attribution where available, as in the failure case. This split is intentional: `attribution_data` is
   1657 per-hop data for scoring path nodes, which the origin cannot do for blinded hops it cannot identify and whose hold times
   1658 would aid de-anonymization, whereas a `fulfillment_payload` is end-to-end data that reveals nothing about the
   1659 intermediate hops.
   1660 
   1661 Like return packets, `fulfillment_payload` is limited to 32768 bytes (32 KiB) to leave room for `attribution_data` and
   1662 future extensions. Because `fulfillment_payload` was introduced with this limit, receiving a larger payload is a
   1663 protocol violation as specified in [BOLT #2](02-peer-protocol.md#removing-an-htlc-update_fulfill_htlc-update_fail_htlc-and-update_fail_malformed_htlc).
   1664 
   1665 ## Requirements
   1666 
   1667 `attribution_data` is initialized, transformed, updated and verified exactly as in the failure case.
   1668 
   1669 The _final node_:
   1670   - if `option_attribution_data` is advertised:
   1671     - MAY include a `fulfillment_payload`, even when reached through a blinded path
   1672   - if it includes a `fulfillment_payload`:
   1673     - MUST ensure the `fulfillment_payload` is no more than 32768 bytes (32 KiB)
   1674     - MUST set `fulfillment_payload_tlvs` to a serialized TLV stream
   1675     - MUST pad with `padding` such that the serialized `fulfillment_payload_tlvs` stream is at least 256 bytes and a
   1676       multiple of 256 bytes, excluding the 16-byte Poly1305 tag. The size calculation includes the type and length
   1677       bytes of the `padding` record; this can require padding to the next multiple of 256 bytes
   1678     - SHOULD pad such that the serialized `fulfillment_payload_tlvs` stream is exactly 256 bytes if possible
   1679     - MUST encrypt the plaintext with ChaCha20-Poly1305 as above
   1680     - MUST NOT include the `fulfillment_payload` in its `attribution_data` HMACs
   1681     - MUST still initialize and update `attribution_data` for its reported hold time
   1682 
   1683 An _intermediate node_:
   1684   - if it receives a `fulfillment_payload` from the downstream node:
   1685     - MUST obfuscate it with its `ammag` key and include it in the outgoing `update_fulfill_htlc`, as it transforms a
   1686       return packet
   1687     - MUST include the `fulfillment_payload` as received from the downstream node in its `attribution_data` HMACs
   1688 
   1689 The _origin node_:
   1690   - MUST recover a `fulfillment_payload` by peeling each intermediate hop's `ammag` obfuscation and decrypting it with
   1691     the last hop's `fulfillment` key
   1692   - MUST verify the final node's `attribution_data` HMACs as in the failure case, except that the HMAC input excludes
   1693     the `fulfillment_payload`, and process its reported hold time
   1694   - MUST remove an intermediate hop's `ammag` obfuscation from the `fulfillment_payload` before verifying that hop's
   1695     `attribution_data` HMACs over the resulting `fulfillment_payload` bytes
   1696   - MUST ignore a `fulfillment_payload` whose Poly1305 tag is invalid, or whose decrypted `fulfillment_payload_tlvs`
   1697     stream has malformed lengths, duplicate or unordered types, or unknown even types
   1698   - MUST ignore `padding` records in a valid `fulfillment_payload_tlvs` stream
   1699 
   1700 # Onion Messages
   1701 
   1702 Onion messages allow peers to use existing connections to query for
   1703 invoices (see [BOLT 12](12-offer-encoding.md)).  Like gossip messages,
   1704 they are not associated with a particular local channel.  Like HTLCs,
   1705 they use [onion messages](#onion-messages) protocol for
   1706 end-to-end encryption.
   1707 
   1708 Onion messages use the same form as HTLC `onion_packet`, with a
   1709 slightly more flexible format: instead of 1300 byte payloads, the
   1710 payload length is implied by the total length (minus 66 bytes for the
   1711 header and trailing bytes).  The `onionmsg_payloads` themselves are the same
   1712 as the `hop_payloads` format, except there is no "legacy" length: a 0
   1713 `length` would mean an empty `onionmsg_payload`.
   1714 
   1715 Onion messages are unreliable: in particular, they are designed to
   1716 be cheap to process and require no storage to forward.  As a result,
   1717 there is no error returned from intermediary nodes.
   1718 
   1719 For consistency, all onion messages use [Route Blinding](#route-blinding).
   1720 
   1721 ## The `onion_message` Message
   1722 
   1723 1. type: 513 (`onion_message`) (`option_onion_messages`)
   1724 2. data:
   1725     * [`point`:`path_key`]
   1726     * [`u16`:`len`]
   1727     * [`len*byte`:`onion_message_packet`]
   1728 
   1729 1. type: `onion_message_packet`
   1730 2. data:
   1731    * [`byte`:`version`]
   1732    * [`point`:`public_key`]
   1733    * [`...*byte`:`onionmsg_payloads`]
   1734    * [`32*byte`:`hmac`]
   1735 
   1736 1. type: `onionmsg_payloads`
   1737 2. data:
   1738    * [`bigsize`:`length`]
   1739    * [`length*u8`:`onionmsg_tlv`]
   1740    * [`32*byte`:`hmac`]
   1741    * ...
   1742    * `filler`
   1743 
   1744 The `onionmsg_tlv` itself is a TLV: an intermediate node expects an
   1745 `encrypted_recipient_data` which it can decrypt into an `encrypted_data_tlv`
   1746 using the `path_key` which it is handed along with the onion message.
   1747 
   1748 Field numbers 64 and above are reserved for payloads for the final
   1749 hop.
   1750 
   1751 1. `tlv_stream`: `onionmsg_tlv`
   1752 2. types:
   1753     1. type: 2 (`reply_path`)
   1754     2. data:
   1755         * [`blinded_path`:`path`]
   1756     1. type: 4 (`encrypted_recipient_data`)
   1757     2. data:
   1758         * [`...*byte`:`encrypted_recipient_data`]
   1759     1. type: 64 (`invoice_request`)
   1760     2. data:
   1761         * [`tlv_invoice_request`:`invreq`]
   1762     1. type: 66 (`invoice`)
   1763     2. data:
   1764         * [`tlv_invoice`:`inv`]
   1765     1. type: 68 (`invoice_error`)
   1766     2. data:
   1767         * [`tlv_invoice_error`:`inverr`]
   1768 
   1769 #### Requirements
   1770 
   1771 The creator of `encrypted_recipient_data` (usually, the recipient of the onion):
   1772 
   1773   - MUST create the `encrypted_recipient_data` from the `encrypted_data_tlv` as required in [Route Blinding](#route-blinding).
   1774   - MUST NOT include `payment_relay` or `payment_constraints` in any `encrypted_data_tlv`
   1775   - MUST include either `next_node_id` or `short_channel_id` in the `encrypted_data_tlv` for each non-final node.
   1776 
   1777 The writer:
   1778 
   1779 - MUST set the `onion_message_packet` `version` to 0.
   1780 - MUST construct the `onion_message_packet` `onionmsg_payloads` as detailed above using Sphinx.
   1781 - MUST NOT use any `associated_data` in the Sphinx construction.
   1782 - SHOULD set `onion_message_packet` `len` to 1366 or 32834.
   1783 - SHOULD retry via a different path if it expects a response and doesn't receive one after a reasonable period.
   1784 - For the non-final nodes' `onionmsg_tlv`:
   1785   - MUST NOT set fields other than `encrypted_recipient_data`.
   1786 - For the final node's `onionmsg_tlv`:
   1787   - if the final node is permitted to reply:
   1788     - MUST set `reply_path` `path_key` to the initial path key for the `first_node_id`
   1789     - MUST set `reply_path` `first_node_id` to the unblinded node id of the first node in the reply path.
   1790     - For every `reply_path` `path`:
   1791       - MUST set `blinded_node_id` to the blinded node id to encrypt the onion hop for.
   1792       - MUST set `encrypted_recipient_data` to a valid encrypted `encrypted_data_tlv` stream which meets the requirements of the `onionmsg_tlv` when used by the recipient.
   1793       - MAY use `path_id` to contain a secret so it can recognize use of this `reply_path`.
   1794   - otherwise:
   1795     - MUST NOT set `reply_path`.
   1796 
   1797 
   1798 The reader:
   1799 
   1800 - if it advertises `option_onion_messages_only_channels`:
   1801   - MUST NOT accept onion messages from peers without an established channel.
   1802 - otherwise:
   1803   - SHOULD accept onion messages from peers without an established channel.
   1804 - MAY rate-limit messages by dropping them.
   1805 - MUST decrypt `onion_message_packet` using an empty `associated_data`, and `path_key`, as described in [Onion Decryption](04-onion-routing.md#onion-decryption) to extract an `onionmsg_tlv`.
   1806 - If decryption fails, the result is not a valid `onionmsg_tlv`, or it contains unknown even types:
   1807   - MUST ignore the message.
   1808 - if `encrypted_data_tlv` contains `allowed_features`:
   1809   - MUST ignore the message if:
   1810     - `encrypted_data_tlv.allowed_features.features` contains an unknown feature bit (even if it is odd).
   1811     - the message uses a feature not included in `encrypted_data_tlv.allowed_features.features`.
   1812 - if it is not the final node according to the onion encryption:
   1813   - if the `onionmsg_tlv` contains other tlv fields than `encrypted_recipient_data`:
   1814     - MUST ignore the message.
   1815   - if the `encrypted_data_tlv` contains `path_id`:
   1816     - MUST ignore the message.
   1817   - otherwise:
   1818     - if `next_node_id` is present:
   1819       - the *next peer* is the peer with that node id.
   1820     - otherwise, if `short_channel_id` is present and corresponds to an announced short_channel_id or a local alias for a channel:
   1821       - the *next peer* is the peer at the other end of that channel.
   1822     - otherwise:
   1823       - MUST ignore the message.
   1824     - SHOULD forward the message using `onion_message` to the *next peer*.
   1825     - if it forwards the message:
   1826       - MUST set `path_key` in the forwarded `onion_message` to the next `path_key` as calculated in [Route Blinding](#route-blinding).
   1827 - otherwise (it is the final node):
   1828   - if `path_id` is set and corresponds to a path the reader has previously published in a `reply_path`:
   1829     - if the onion message is not a reply to that previous onion:
   1830       - MUST ignore the onion message
   1831   - otherwise (unknown or unset `path_id`):
   1832     - if the onion message is a reply to an onion message which contained a `path_id`:
   1833       - MUST respond (or not respond) exactly as if it did not send the initial onion message.
   1834   - if the `onionmsg_tlv` contains more than one payload field:
   1835     - MUST ignore the message.
   1836   - if it wants to send a reply:
   1837     - MUST create an onion message using `reply_path`.
   1838     - MUST send the reply via `onion_message` to the node indicated by
   1839       the `first_node_id`, using `reply_path` `path_key` to send
   1840       along `reply_path` `path`.
   1841 
   1842 
   1843 #### Rationale
   1844 
   1845 Accepting onion messages from channelless peers is the baseline: a node that
   1846 advertises `option_onion_messages` is expected to accept onion messages from
   1847 any connected peer.  This is a SHOULD rather than a MUST because acceptance
   1848 is always best effort: a node may still drop messages due to rate-limiting.
   1849 
   1850 A node that wants to restrict acceptance to channel peers (e.g. to limit the
   1851 DoS surface of free bandwidth/CPU for any node that can connect) advertises
   1852 `option_onion_messages_only_channels` as an explicit opt-out.  A restrictive
   1853 node should not silently drop these messages while advertising only the
   1854 baseline: it has to advertise the bit, which makes the bit a reliable signal.
   1855 A sender can therefore detect it and simply not attempt a relay it knows will
   1856 fail, rather than sending a message that is silently dropped.
   1857 
   1858 Care must be taken that replies are only accepted using the exact
   1859 reply_path given, otherwise probing is possible.  That means checking
   1860 both ways: non-replies don't use the reply path, and replies always
   1861 use the reply path.
   1862 
   1863 The requirement to discard messages with `onionmsg_tlv` fields which
   1864 are not strictly required ensures consistency between current and
   1865 future implementations.  Even odd fields can be a problem since they
   1866 are parsed (and thus may be rejected!) by nodes which understand them,
   1867 and ignored by those which don't.
   1868 
   1869 All onion messages are blinded, even though this overhead is not
   1870 always necessary (33 bytes here, the 16-byte MAC for each encrypted_data_tlv in
   1871 the onion).  This blinding allows nodes to use a path provided by
   1872 others without knowing its contents.  Using it universally simplifies
   1873 implementations a little, and makes it more difficult to distinguish
   1874 onion messages.
   1875 
   1876 `len` allows larger messages to be sent than the standard 1300 bytes
   1877 allowed for an HTLC onion, but this should be used sparingly as it
   1878 reduces the anonymity set, hence the recommendation that it either looks
   1879 like an HTLC onion, or if larger, be a fixed size.
   1880 
   1881 Onion messages don't explicitly require a channel, but for
   1882 spam-reduction a node may choose to ratelimit such peers, especially
   1883 messages it is asked to forward.
   1884 
   1885 ## `max_htlc_cltv` Selection
   1886 
   1887 This `max_htlc_cltv` value is defined as 2016 blocks, based on historical value
   1888 deployed by Lightning implementations.
   1889 
   1890 # Test Vector
   1891 
   1892 ## Returning Errors
   1893 
   1894 The test vectors use the following parameters:
   1895 
   1896 	pubkey[0] = 0x02eec7245d6b7d2ccb30380bfbe2a3648cd7a942653f5aa340edcea1f283686619
   1897     htlc_hold_time[0] = 1
   1898 
   1899 	pubkey[1] = 0x0324653eac434488002cc06bbfb7f10fe18991e35f9fe4302dbea6d2353dc0ab1c
   1900     htlc_hold_time[1] = 2
   1901 
   1902 	pubkey[2] = 0x027f31ebc5462c1fdce1b737ecff52d37d75dea43ce11c74d25aa297165faa2007
   1903     htlc_hold_time[2] = 3
   1904 
   1905 	pubkey[3] = 0x032c0b7cf95324a07d05398b240174dc0c2be444d96b159aa6c7f7b1e668680991
   1906     htlc_hold_time[3] = 4
   1907 
   1908 	pubkey[4] = 0x02edabbd16b41c8371b92ef2f04c1185b4f03b6dcd52ba9b78d9d7c89c8f221145
   1909     htlc_hold_time[4] = 5
   1910 
   1911 	nhops = 5
   1912 	sessionkey = 0x4141414141414141414141414141414141414141414141414141414141414141
   1913 
   1914 	failure_source  = node 4
   1915 	failure_message = `incorrect_or_unknown_payment_details`
   1916       htlc_msat = 100
   1917       height    = 800000
   1918       tlv data
   1919         type  = 34001
   1920         value = [128, 128, ..., 128] (300 bytes)
   1921 
   1922 The following is an in-depth trace of an example of error message creation:
   1923 
   1924 	# creating error message
   1925 	encoded_failure_message = 400f0000000000000064000c3500fd84d1fd012c80808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808002c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
   1926 	shared_secret = b5756b9b542727dbafc6765a49488b023a725d631af688fc031217e90770c328
   1927 	payload = 0140400f0000000000000064000c3500fd84d1fd012c80808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808002c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
   1928 	um_key = 4da7f2923edce6c2d85987d1d9fa6d88023e6c3a9c3d20f07d3b10b61a78d646
   1929 	raw_error_packet = fda7e11974f78ca6cc456f2d17ae54463664696e93842548245dd2a2c513a6260140400f0000000000000064000c3500fd84d1fd012c80808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808080808002c00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
   1930 	
   1931     # forwarding error packet
   1932 	shared_secret = b5756b9b542727dbafc6765a49488b023a725d631af688fc031217e90770c328
   1933 	ammag_key = 2f36bb8822e1f0d04c27b7d8bb7d7dd586e032a3218b8d414afbba6f169a4d68
   1934 	stream = e9c975b07c9a374ba64fd9be3aae955e917d34d1fa33f2e90f53bbf4394713c6a8c9b16ab5f12fd45edd73c1b0c8b33002df376801ff58aaa94000bf8a86f92620f343baef38a580102395ae3abf9128d1047a0736ff9b83d456740ebbb4aeb3aa9737f18fb4afb4aa074fb26c4d702f42968888550a3bded8c05247e045b866baef0499f079fdaeef6538f31d44deafffdfd3afa2fb4ca9082b8f1c465371a9894dd8c243fb4847e004f5256b3e90e2edde4c9fb3082ddfe4d1e734cacd96ef0706bf63c9984e22dc98851bcccd1c3494351feb458c9c6af41c0044bea3c47552b1d992ae542b17a2d0bba1a096c78d169034ecb55b6e3a7263c26017f033031228833c1daefc0dedb8cf7c3e37c9c37ebfe42f3225c326e8bcfd338804c145b16e34e4f5984bc119af09d471a61f39e9e389c4120cadabc5d9b7b1355a8ccef050ca8ad72f642fc26919927b347808bade4b1c321b08bc363f20745ba2f97f0ced2996a232f55ba28fe7dfa70a9ab0433a085388f25cce8d53de6a2fbd7546377d6ede9027ad173ba1f95767461a3689ef405ab608a21086165c64b02c1782b04a6dba2361a7784603069124e12f2f6dcb1ec7612a4fbf94c0e14631a2bef6190c3d5f35e0c4b32aa85201f449d830fd8f782ec758b0910428e3ec3ca1dba3b6c7d89f69e1ee1b9df3dfbbf6d361e1463886b38d52e8f43b73a3bd48c6f36f5897f514b93364a31d49d1d506340b1315883d425cb36f4ea553430d538fd6f3596d4afc518db2f317dd051abc0d4bfb0a7870c3db70f19fe78d6604bbf088fcb4613f54e67b038277fedcd9680eb97bdffc3be1ab2cbcbafd625b8a7ac34d8c190f98d3064ecd3b95b8895157c6a37f31ef4de094b2cb9dbf8ff1f419ba0ecacb1bb13df0253b826bec2ccca1e745dd3b3e7cc6277ce284d649e7b8285727735ff4ef6cca6c18e2714f4e2a1ac67b25213d3bb49763b3b94e7ebf72507b71fb2fe0329666477ee7cb7ebd6b88ad5add8b217188b1ca0fa13de1ec09cc674346875105be6e0e0d6c8928eb0df23c39a639e04e4aedf535c4e093f08b2c905a14f25c0c0fe47a5a1535ab9eae0d9d67bdd79de13a08d59ee05385c7ea4af1ad3248e61dd22f8990e9e99897d653dd7b1b1433a6d464ea9f74e377f2d8ce99ba7dbc753297644234d25ecb5bd528e2e2082824681299ac30c05354baaa9c3967d86d7c07736f87fc0f63e5036d47235d7ae12178ced3ae36ee5919c093a02579e4fc9edad2c446c656c790704bfc8e2c491a42500aa1d75c8d4921ce29b753f883e17c79b09ea324f1f32ddf1f3284cd70e847b09d90f6718c42e5c94484cc9cbb0df659d255630a3f5a27e7d5dd14fa6b974d1719aa98f01a20fb4b7b1c77b42d57fab3c724339d459ee4a1c6b5d3bd4e08624c786a257872acc9ad3ff62222f2265a658d9f2a007229a5293b67ec91c84c4b4407c228434bad8a815ca9b256c776bd2c9f
   1935 	error packet for node 4: 146e94a9086dbbed6a0ab6932d00c118a7195dbf69b7d7a12b0e6956fc54b5e0a989f165b5f12fd45edd73a5b0c48630ff5be69500d3d82a29c0803f0a0679a6a073c33a6fb8250090a3152eba3f11a85184fa87b67f1b0354d6f48e3b342e332a17b7710f342f342a87cf32eccdf0afc2160808d58abb5e5840d2c760c538e63a6f841970f97d2e6fe5b8739dc45e2f7f5f532f227bcc2988ab0f9cc6d3f12909cd5842c37bc8c7608475a5ebbe10626d5ecc1f3388ad5f645167b44a4d166f87863fe34918cea25c18059b4c4d9cb414b59f6bc50c1cea749c80c43e2344f5d23159122ed4ab9722503b212016470d9610b46c35dbeebaf2e342e09770b38392a803bc9d2e7c8d6d384ffcbeb74943fe3f64afb2a543a6683c7db3088441c531eeb4647518cb41992f8954f1269fb969630944928c2d2b45593731b5da0c4e70d04a0a57afe4af42e99912fbb4f8883a5ecb9cb29b883cb6bfa0f4db2279ff8c6d2b56a232f55ba28fe7dfa70a9ab0433a085388f25cce8d53de6a2fbd7546377d6ede9027ad173ba1f95767461a3689ef405ab608a21086165c64b02c1782b04a6dba2361a7784603069124e12f2f6dcb1ec7612a4fbf94c0e14631a2bef6190c3d5f35e0c4b32aa85201f449d830fd8f782ec758b0910428e3ec3ca1dba3b6c7d89f69e1ee1b9df3dfbbf6d361e1463886b38d52e8f43b73a3bd48c6f36f5897f514b93364a31d49d1d506340b1315883d425cb36f4ea553430d538fd6f3596d4afc518db2f317dd051abc0d4bfb0a7870c3db70f19fe78d6604bbf088fcb4613f54e67b038277fedcd9680eb97bdffc3be1ab2cbcbafd625b8a7ac34d8c190f98d3064ecd3b95b8895157c6a37f31ef4de094b2cb9dbf8ff1f419ba0ecacb1bb13df0253b826bec2ccca1e745dd3b3e7cc6277ce284d649e7b8285727735ff4ef6cca6c18e2714f4e2a1ac67b25213d3bb49763b3b94e7ebf72507b71fb2fe0329666477ee7cb7ebd6b88ad5add8b217188b1ca0fa13de1ec09cc674346875105be6e0e0d6c8928eb0df23c39a639e04e4aedf535c4e093f08b2c905a14f25c0c0fe47a5a1535ab9eae0d9d67bdd79de13a08d59ee05385c7ea4af1ad3248e61dd22f8990e9e99897d653dd7b1b1433a6d464ea9f74e377f2d8ce99ba7dbc753297644234d25ecb5bd528e2e2082824681299ac30c05354baaa9c3967d86d7c07736f87fc0f63e5036d47235d7ae12178ced3ae36ee5919c093a02579e4fc9edad2c446c656c790704bfc8e2c491a42500aa1d75c8d4921ce29b753f883e17c79b09ea324f1f32ddf1f3284cd70e847b09d90f6718c42e5c94484cc9cbb0df659d255630a3f5a27e7d5dd14fa6b974d1719aa98f01a20fb4b7b1c77b42d57fab3c724339d459ee4a1c6b5d3bd4e08624c786a257872acc9ad3ff62222f2265a658d9f2a007229a5293b67ec91c84c4b4407c228434bad8a815ca9b256c776bd2c9f
   1936     attribution data for node 4: d77d0711b5f71d1d1be56bd88b3bb7ebc1792bb739ea7ebc1bc3b031b8bc2df3a50e25aeb99f47d7f7ab39e24187d3f4df9c4333463b053832ee9ac07274a5261b8b2a01fc09ce9ea7cd04d7b585dfb8cf5958e3f3f2a4365d1ec0df1d83c6a6221b5b7d1ff30156a2289a1d3ee559e7c7256bda444bb8e046f860e00b3a59a85e1e1a43de215fd5e6bf646a5deab97b1912c934e31b1cfd344764d6ca7e14ea7b3f2a951aba907c964c0f5d19a44e6d1d7279637321fa598adde927b3087d238f8b426ecde500d318617cdb7a56e6ce3520fc95be41a549973764e4dc483853ecc313947709f1b5199cb077d46e701fa633e11d3e13b03e9212c115ca6fa004b2f3dd912814693b705a561a06da54cdf603677a3abecdc22c7358c2de3cef771b366a568150aeecc86ad1990bb0f4e2865933b03ea0df87901bff467908273dc6cea31cbab0e2b8d398d10b001058c259ed221b7b55762f4c7e49c8c11a45a107b7a2c605c26dc5b0b10d719b1c844670102b2b6a36c43fe4753a78a483fc39166ae28420f112d50c10ee64ca69569a2f690712905236b7c2cb7ac8954f02922d2d918c56d42649261593c47b14b324a65038c3c5be8d3c403ce0c8f19299b1664bf077d7cf1636c4fb9685a8e58b7029fd0939fa07925a60bed339b23f973293598f595e75c8f9d455d7cebe4b5e23357c8bd47d66d6628b39427e37e0aecbabf46c11be6771f7136e108a143ae9bafba0fc47a51b6c7deef4cba54bae906398ee3162a41f2191ca386b628bde7e1dd63d1611aa01a95c456df337c763cb8c3a81a6013aa633739d8cd554c688102211725e6adad165adc1bcd429d020c51b4b25d2117e8bb27eb0cc7020f9070d4ad19ac31a76ebdf5f9246646aeadbfb9a3f1d75bd8237961e786302516a1a781780e8b73f58dc06f307e58bd0eb1d8f5c9111f01312974c1dc777a6a2d3834d8a2a40014e9818d0685cb3919f6b3b788ddc640b0ff9b1854d7098c7dd6f35196e902b26709640bc87935a3914869a807e8339281e9cedaaca99474c3e7bdd35050bb998ab4546f9900904e0e39135e861ff7862049269701081ebce32e4cca992c6967ff0fd239e38233eaf614af31e186635e9439ec5884d798f9174da6ff569d68ed5c092b78bd3f880f5e88a7a8ab36789e1b57b035fb6c32a6358f51f83e4e5f46220bcad072943df8bd9541a61b7dae8f30fa3dd5fb39b1fd9a0b8e802552b78d4ec306ecee15bfe6da14b29ba6d19ce5be4dd478bca74a52429cd5309d404655c3dec85c252
   1937 
   1938     # forwarding error packet
   1939 	shared_secret = 21e13c2d7cfe7e18836df50872466117a295783ab8aab0e7ecc8c725503ad02d
   1940 	ammag_key = cd9ac0e09064f039fa43a31dea05f5fe5f6443d40a98be4071af4a9d704be5ad
   1941 	stream = 617ca1e4624bc3f04fece3aa5a2b615110f421ec62408d16c48ea6c1b7c33fe7084a2bd9d4652fc5068e5052bf6d0acae2176018a3d8c75f37842712913900263cff92f39f3c18aa1f4b20a93e70fc429af7b2b1967ca81a761d40582daf0eb49cef66e3d6fbca0218d3022d32e994b41c884a27c28685ef1eb14603ea80a204b2f2f474b6ad5e71c6389843e3611ebeafc62390b717ca53b3670a33c517ef28a659c251d648bf4c966a4ef187113ec9848bf110816061ca4f2f68e76ceb88bd6208376460b916fb2ddeb77a65e8f88b2e71a2cbf4ea4958041d71c17d05680c051c3676fb0dc8108e5d78fb1e2c44d79a202e9d14071d536371ad47c39a05159e8d6c41d17a1e858faaaf572623aa23a38ffc73a4114cb1ab1cd7f906c6bd4e21b29694f9830d12e8ad4b1ac320b3d5bfb4e534f02cefe9a983d66939581412acb1927eb93e8ed73145cddf24266bdcc95923ecb38c8c9c5f4465335b0f18bf9f2d03fa02d57f258db27983d94378bc796cbe7737180dd7e39a36e461ebcb7ec82b6dcdf9d3f209381f7b3a23e798c4f92e13b4bb972ee977e24f4b83bb59b577c210e1a612c2b035c8271d9bc1fb915776ac6560315b124465866830473aa238c35089cf2adb9c6e9f05ab113c1d0a4a18ba0cb9951b928c0358186532c36d4c3daa65657be141cc22e326f88e445e898893fd5f0a7dd231ee5bc972077b1e12a8e382b75d4b557e895a2adc757f2e451e33e0ae3fb54566ee09155da6ada818aa4a4a2546832a8ba22f0ef9ec6a1c78e03a7c29cb126bcaf81aea61cd8b07ab9f4e5e0ad0d9a3a0c66d2d0a00cc05884d183a68e816e76b75842d55895f5b91c5c1b9f7052763aae8a647aa0799214275b6e781f0816fc9ffb802a0101eb5a2de6b3375d3e3478f892b2de7f1900d8ca9bf188fcba89fc49d03c38fa2587a8ae119abfb295b15fa11cb188796bedc4fdfceef296e44fbfa7e84569cc6346389a421782e40a298e1e2b6f9cae3103c3f39d24541e4ab7b61dafe1a5f2fe936a59d87cccdaf7c226acc451ceec3e81bc4828b4925feeae3526d5e2bf93bd5f4fdc0e069010aea1ae7e0d480d438918598896b776bf08fea124f91b3a13414b56934857707902612fc97b0e5d02cbe6e5901ad304c7e8656390efccf3a1b22e18a2935181b78d5d2c89540ede8b0e6194d0d3945780bf577f622cb12deedbf8210eb1450c298b9ee19f3c7082aabc2bdbd3384f3539dc3766978567135549df0d48287735854a6098fa40a9e48eaa27e0d159beb65dd871e4c0b3fffa65f0375f0d3253f582193135ece60d5b9d8ba6739d87964e992cbec674b728d9eaaed595462c41d15fb497d4baa062368005d13fc99e1402563117a6c140c10363b05196a4cbb6b84ae807d62c748485c15e3316841e4a98c3aac81e3bc996b4baca77eac8cdbe99cc7c5ebeb85c907cefb4abe15cbe87fdc5dc2326019196235ac205934fcf8e3
   1942 	error packet for node 3: 7512354d6a26781d25e65539772ba049b7ed7c530bf75ab7ef80cf974b978a07a1c3dabc61940011585323f70fa98cfa1d4c868da30b1f751e44a72d9b3f79809c8c51c9f0843daa8fe83587844fedeacb7348362003b31922cbb4d6169b2087b6f8d192d9cfe5363254cd1fde24641bde9e422f170c3eb146f194c48a459ae2889d706dc654235fa9dd20307ea54091d09970bf956c067a3bcc05af03c41e01af949a131533778bf6ee3b546caf2eabe9d53d0fb2e8cc952b7e0f5326a69ed2e58e088729a1d85971c6b2e129a5643f3ac43da031e655b27081f10543262cf9d72d6f64d5d96387ac0d43da3e3a03da0c309af121dcf3e99192efa754eab6960c256ffd4c546208e292e0ab9894e3605db098dc16b40f17c320aa4a0e42fc8b105c22f08c9bc6537182c24e32062c6cd6d7ec7062a0c2c2ecdae1588c82185cdc61d874ee916a7873ac54cddf929354f307e870011704a0e9fbc5c7802d6140134028aca0e78a7e2f3d9e5c7e49e20c3a56b624bfea51196ec9e88e4e56be38ff56031369f45f1e03be826d44a182f270c153ee0d9f8cf9f1f4132f33974e37c7887d5b857365c873cb218cbf20d4be3abdb2a2011b14add0a5672e01e5845421cf6dd6faca1f2f443757aae575c53ab797c2227ecdab03882bbbf4599318cefafa72fa0c9a0f5a51d13c9d0e5d25bfcfb0154ed25895260a9df8743ac188714a3f16960e6e2ff663c08bffda41743d50960ea2f28cda0bc3bd4a180e297b5b41c700b674cb31d99c7f2a1445e121e772984abff2bbe3f42d757ceeda3d03fb1ffe710aecabda21d738b1f4620e757e57b123dbc3c4aa5d9617dfa72f4a12d788ca596af14bea583f502f16fdc13a5e739afb0715424af2767049f6b9aa107f69c5da0e85f6d8c5e46507e14616d5d0b797c3dea8b74a1b12d4e47ba7f57f09d515f6c7314543f78b5e85329d50c5f96ee2f55bbe0df742b4003b24ccbd4598a64413ee4807dc7f2a9c0b92424e4ae1b418a3cdf02ea4da5c3b12139348aa7022cc8272a3a1714ee3e4ae111cffd1bdfd62c503c80bdf27b2feaea0d5ab8fe00f9cec66e570b00fd24b4a2ed9a5f6384f148a4d6325110a41ca5659ebc5b98721d298a52819b6fb150f273383f1c5754d320be428941922da790e17f482989c365c078f7f3ae100965e1b38c052041165295157e1a7c5b7a57671b842d4d85a7d971323ad1f45e17a16c4656d889fc75c12fc3d8033f598306196e29571e414281c5da19c12605f48347ad5b4648e371757cbe1c40adb93052af1d6110cfbf611af5c8fc682b7e2ade3bfca8b5c7717d19fc9f97964ba6025aebbc91a6671e259949dcf40984342118de1f6b514a7786bd4f6598ffbe1604cef476b2a4cb1343db608aca09d1d38fc23e98ee9c65e7f6023a8d1e61fd4f34f753454bd8e858c8ad6be6403edc599c220e03ca917db765980ac781e758179cd93983e9c1e769e4241d47c
   1943 	attribution data for node 3: 1571e10db7f8aa9f8e7e99caaf9c892e106c817df1d8e3b7b0e39d1c48f631e473e17e205489dd7b3c634cac3be0825cbf01418cd46e83c24b8d9c207742db9a0f0e5bcd888086498159f08080ba7bf36dee297079eb841391ccd3096da76461e314863b6412efe0ffe228d51c6097db10d3edb2e50ea679820613bfe9db11ba02920ab4c1f2a79890d997f1fc022f3ab78f0029cc6de0c90be74d55f4a99bf77a50e20f8d076fe61776190a61d2f41c408871c0279309cba3b60fcdc7efc4a0e90b47cb4a418fc78f362ecc7f15ebbce9f854c09c7be300ebc1a40a69d4c7cb7a19779b6905e82bec221a709c1dab8cbdcde7b527aca3f54bde651aa9f3f2178829cee3f1c0b9292758a40cc63bd998fcd0d3ed4bdcaf1023267b8f8e44130a63ad15f76145936552381eabb6d684c0a3af6ba8efcf207cebaea5b7acdbb63f8e7221102409d10c23f0514dc9f4d0efb2264161a193a999a23e992632710580a0d320f676d367b9190721194514457761af05207cdab2b6328b1b3767eacb36a7ef4f7bd2e16762d13df188e0898b7410f62459458712a44bf594ae662fd89eb300abb6952ff8ad40164f2bcd7f86db5c7650b654b79046de55d51aa8061ce35f867a3e8f5bf98ad920be827101c64fb871d86e53a4b3c0455bfac5784168218aa72cbee86d9c750a9fa63c363a8b43d7bf4b2762516706a306f0aa3be1ec788b5e13f8b24837e53ac414f211e11c7a093cd9653dfa5fba4e377c79adfa5e841e2ddb6afc054fc715c05ddc6c8fc3e1ee3406e1ffceb2df77dc2f02652614d1bfcfaddebaa53ba919c7051034e2c7b7cfaabdf89f26e7f8e3f956d205dfab747ad0cb505b85b54a68439621b25832cbc2898919d0cd7c0a64cfd235388982dd4dd68240cb668f57e1d2619a656ed326f8c92357ee0d9acead3c20008bc5f04ca8059b55d77861c6d04dfc57cfba57315075acbe1451c96cf28e1e328e142890248d18f53b5d3513ce574dea7156cf596fdb3d909095ec287651f9cf1bcdc791c5938a5dd9b47e84c004d24ab3ae74492c7e8dcc1da15f65324be2672947ec82074cac8ce2b925bc555facbbf1b55d63ea6fbea6a785c97d4caf2e1dad9551b7f66c31caae5ebc7c0047e892f201308fcf452c588be0e63d89152113d87bf0dbd01603b4cdc7f0b724b0714a9851887a01f709408882e18230fe810b9fafa58a666654576d8eba3005f07221f55a6193815a672e5db56204053bc4286fa3db38250396309fd28011b5708a26a2d76c4a333b69b6bfd272fb
   1944 
   1945     # forwarding error packet
   1946 	shared_secret = 3a6b412548762f0dbccce5c7ae7bb8147d1caf9b5471c34120b30bc9c04891cc
   1947 	ammag_key = 1bf08df8628d452141d56adfd1b25c1530d7921c23cecfc749ac03a9b694b0d3
   1948 	stream = 6149f48b5a7e8f3d6f5d870b7a698e204cf64452aab4484ff1dee671fe63fd4b5f1b78ee2047dfa61e3d576b149bedaf83058f85f06a3172a3223ad6c4732d96b32955da7d2feb4140e58d86fc0f2eb5d9d1878e6f8a7f65ab9212030e8e915573ebbd7f35e1a430890be7e67c3fb4bbf2def662fa625421e7b411c29ebe81ec67b77355596b05cc155755664e59c16e21410aabe53e80404a615f44ebb31b365ca77a6e91241667b26c6cad24fb2324cf64e8b9dd6e2ce65f1f098cfd1ef41ba2d4c7def0ff165a0e7c84e7597c40e3dffe97d417c144545a0e38ee33ebaae12cc0c14650e453d46bfc48c0514f354773435ee89b7b2810606eb73262c77a1d67f3633705178d79a1078c3a01b5fadc9651feb63603d19decd3a00c1f69af2dab2595931ca50d8280758b1cc91ba2dc43dbbc3d91bf25c08b46c2ecef7a32cec64d4b61ee3a629ef563afe058b71e71bcb69033948bc8728c5ebe65ec596e4f305b9fc159d53f723dfc95b57f3d51717f1c89af97a6d587e89e62efcc92198a1b2bd66e2d875505ea4046c04389f8cb0ee98f0af03af2652e2f3d9a9c48430f2891a4d9b16e7d18099e4a3dd334c24aba1e2450792c2f22092c170da549d43a440021e699bd6c20d8bbf1961100a01ebcce06a4609f5ad93066287acf68294cfa9ea7cea03a508983b134a9f0118b16409a61c06aaa95897d2067cb7cd59123f3e2ccf0e16091571d616c44818f118bb7835a679f5c0eea8cf1bd5479882b2c2a341ec26dbe5da87b3d37d66b1fbd176f71ab203a3b6eaf7f214d579e7d0e4a3e59089ebd26ba04a62403ae7a793516ec16d971d51c5c0107a917d1a70221e6de16edca7cb057c7d06902b5191f298aa4d478a0c3a6260c257eae504ebbf2b591688e6f3f77af770b6f566ae9868d2f26c12574d3bf9323af59f0fe0072ff94ae597c2aa6fbcbf0831989e02f9d3d1b9fd6dd97f509185d9ecbf272e38bd621ee94b97af8e1cd43853a8f6aa6e8372585c71bf88246d064ade524e1e0bd8496b620c4c2d3ae06b6b064c97536aaf8d515046229f72bee8aa398cd0cc21afd5449595016bef4c77cb1e2e9d31fe1ca3ffde06515e6a4331ccc84edf702e5777b10fc844faf17601a4be3235931f6feca4582a8d247c1d6e4773f8fb6de320cf902bbb1767192782dc550d8e266e727a2aa2a414b816d1826ea46af71701537193c22bbcc0123d7ff5a23b0aa8d7967f36fef27b14fe1866ff3ab215eb29e07af49e19174887d71da7e7fe1b7aa1b3c805c063e0fafedf125fa6c57e38cce33a3f7bb35fd8a9f0950de3c22e49743c05f40bc55f960b8a8b5e2fde4bb229f125538438de418cb318d13968532499118cb7dcaaf8b6d635ac4001273bdafd12c8ea0702fb2f0dac81dbaaf68c1c32266382b293fa3951cb952ed5c1bdc41750cdbc0bd62c51bb685616874e251f031a929c06faef5bfcb0857f815ae20620b823f0abecfb5
   1949 	error packet for node 2: 145bc1c63058f7204abbd2320d422e69fb1b3801a14312f81e5e29e6b5f4774cfed8a25241d3dfb7466e749c1b3261559e49090853612e07bd669dfb5f4c54162fa504138dabd6ebcf0db8017840c35f12a2cfb84f89cc7c8959a6d51815b1d2c5136cedec2e4106bb5f2af9a21bd0a02c40b44ded6e6a90a145850614fb1b0eef2a03389f3f2693bc8a755630fc81fff1d87a147052863a71ad5aebe8770537f333e07d841761ec448257f948540d8f26b1d5b66f86e073746106dfdbb86ac9475acf59d95ece037fba360670d924dce53aaa74262711e62a8fc9eb70cd8618fbedae22853d3053c7f10b1a6f75369d7f73c419baa7dbf9f1fc5895362dcc8b6bd60cca4943ef7143956c91992119bccbe1666a20b7de8a2ff30a46112b53a6bb79b763903ecbd1f1f74952fb1d8eb0950c504df31fe702679c23b463f82a921a2c931500ab08e686cffb2d87258d254fb17843959cccd265a57ba26c740f0f231bb76df932b50c12c10be90174b37d454a3f8b284c849e86578a6182c4a7b2e47dd57d44730a1be9fec4ad07287a397e28dce4fda57e9cdfdb2eb5afdf0d38ef19d982341d18d07a556bb16c1416f480a396f278373b8fd9897023a4ac506e65cf4c306377730f9c8ca63cf47565240b59c4861e52f1dab84d938e96fb31820064d534aca05fd3d2600834fe4caea98f2a748eb8f200af77bd9fbf46141952b9ddda66ef0ebea17ea1e7bb5bce65b6e71554c56dd0d4e14f4cf74c77a150776bf31e7419756c71e7421dc22efe9cf01de9e19fc8808d5b525431b944400db121a77994518d6025711cb25a18774068bba7faaa16d8f65c91bec8768848333156dcb4a08dfbbd9fef392da3e4de13d4d74e83a7d6e46cfe530ee7a6f711e2caf8ad5461ba8177b2ef0a518baf9058ff9156e6aa7b08d938bd8d1485a787809d7b4c8aed97be880708470cd2b2cdf8e2f13428cc4b04ef1f2acbc9562f3693b948d0aa94b0e6113cafa684f8e4a67dc431dfb835726874bef1de36f273f52ee694ec46b0700f77f8538067642a552968e866a72a3f2031ad116663ac17b172b446c5bc705b84777363a9a3fdc6443c07b2f4ef58858122168d4ebbaee920cefc312e1cea870ed6e15eec046ab2073bbf08b0a3366f55cfc6ad4681a12ab0946534e7b6f90ea8992d530ec3daa6b523b3cf03101c60cadd914f30dec932c1ef4341b5a8efac3c921e203574cfe0f1f83433fddb8ccfd273f7c3cab7bc27efe3bb61fdccd5146f1185364b9b621e7fb2b74b51f5ee6be72ab6ff46a6359dc2c855e61469724c1dbeb273df9d2e1c1fb74891239c0019dc12d5c7535f7238f963b761d7102b585372cf021b64c4fc85bfb3161e59d2e298bba44cfd34d6859d9dba9dc6271e5047d525468c814f2ae438474b0a977273036da1a2292f88fcfb89574a6bdca1185b40f8aa54026d5926725f99ef028da1be892e3586361efe15f4a148ff1bc9
   1950 	attribution data for node 2: 34e34397b8621ec2f2b54dbe6c14073e267324cd60b152bce76aec8729a6ddefb61bc263be4b57bd592aae604a32bea69afe6ef4a6b573c26b17d69381ec1fc9b5aa769d148f2f1f8b5377a73840bb6dc641f68e356323d766fff0aaca5039fe7fc27038195844951a97d5a5b26698a4ca1e9cd4bca1fcca0aac5fee91b18977d2ad0e399ba159733fc98f6e96898ebc39bf0028c9c81619233bab6fad0328aa183a635fac20437fa6e00e899b2527c3697a8ab7342e42d55a679b176ab76671fcd480a9894cb897fa6af0a45b917a162bed6c491972403185df7235502f7ada65769d1bfb12d29f10e25b0d3cc08bbf6de8481ac5c04df32b4533b4f764c2aefb7333202645a629fb16e4a208e9045dc36830759c852b31dd613d8b2b10bbead1ed4eb60c85e8a4517deba5ab53e39867c83c26802beee2ee545bdd713208751added5fc0eb2bc89a5aa2decb18ee37dac39f22a33b60cc1a369d24de9f3d2d8b63c039e248806de4e36a47c7a0aed30edd30c3d62debdf1ad82bf7aedd7edec413850d91c261e12beec7ad1586a9ad25b2db62c58ca17119d61dcc4f3e5c4520c42a8e384a45d8659b338b3a08f9e123a1d3781f5fc97564ccff2c1d97f06fa0150cfa1e20eacabefb0c339ec109336d207cc63d9170752fc58314c43e6d4a528fd0975afa85f3aa186ff1b6b8cb12c97ed4ace295b0ef5f075f0217665b8bb180246b87982d10f43c9866b22878106f5214e99188781180478b07764a5e12876ddcb709e0a0a8dd42cf004c695c6fc1669a6fd0e4a1ca54b024d0d80eac492a9e5036501f36fb25b72a054189294955830e43c18e55668337c8c6733abb09fc2d4ade18d5a853a2b82f7b4d77151a64985004f1d9218f2945b63c56fdebd1e96a2a7e49fa70acb4c39873947b83c191c10e9a8f40f60f3ad5a2be47145c22ea59ed3f5f4e61cb069e875fb67142d281d784bf925cc286eacc2c43e94d08da4924b83e58dbf2e43fa625bdd620eba6d9ce960ff17d14ed1f2dbee7d08eceb540fdc75ff06dabc767267658fad8ce99e2a3236e46d2deedcb51c3c6f81589357edebac9772a70b3d910d83cd1b9ce6534a011e9fa557b891a23b5d88afcc0d9856c6dabeab25eea55e9a248182229e4927f268fe5431672fcce52f434ca3d27d1a2136bae5770bb36920df12fbc01d0e8165610efa04794f414c1417f1d4059435c5385bfe2de83ce0e238d6fd2dbd3c0487c69843298577bfa480fe2a16ab2a0e4bc712cd8b5a14871cda61c993b6835303d9043d7689a
   1951 
   1952     # forwarding error packet
   1953 	shared_secret = a6519e98832a0b179f62123b3567c106db99ee37bef036e783263602f3488fae
   1954 	ammag_key = 59ee5867c5c151daa31e36ee42530f429c433836286e63744f2020b980302564
   1955 	stream = 0f10c86f05968dd91188b998ee45dcddfbf89fe9a99aa6375c42ed5520a257e048456fe417c15219ce39d921555956ae2ff795177c63c819233f3bcb9b8b28e5ac6e33a3f9b87ca62dff43f4cc4a2755830a3b7e98c326b278e2bd31f4a9973ee99121c62873f5bfb2d159d3d48c5851e3b341f9f6634f51939188c3b9ff45feeb11160bb39ce3332168b8e744a92107db575ace7866e4b8f390f1edc4acd726ed106555900a0832575c3a7ad11bb1fe388ff32b99bcf2a0d0767a83cf293a220a983ad014d404bfa20022d8b369fe06f7ecc9c74751dcda0ff39d8bca74bf9956745ba4e5d299e0da8f68a9f660040beac03e795a046640cf8271307a8b64780b0588422f5a60ed7e36d60417562938b400802dac5f87f267204b6d5bcfd8a05b221ec294d883271b06ca709042ed5dbb64a7328d2796195eab4512994fb88919c73b3e5dd7bf68b2136d34cff39b3be266b71e004509bf975a240800bb8ae5eed248423a991ae80ef751b2d03b67fb93ffdd7969d5b500fe446a4ffb4cd04d0767a5d367ebd3f8f260f38ae1e9d9f9a7bd1a99ca1e10ee36bd241f06fc2b481c9b7450d9c9704204666807783264a0e93468e22db4dc4a7a4db2963ddf4366d08e225cf94848aac794bcecb7e850113e38cc3647a03a5dfaa3442b1bb58b1de7fa7f436feb4d7c23cbd2de6d55d4025fcd383cc9d49c0b130e2fd5a9097c216683c842f898a8a2159761cca9aa1c818194e3b7bea6da6652d5189f3b6b0ca1d5398b6d14e311d9c7f00399c29e94deb98496f4cd97c5d7d6a65cabc3791f60d728d6422a422c0cff5f7dfd4ce2d7e8d38dd71ae18763acc832c57275497f61b2620cca13cc64c0c48353f3817016f91448d6fc1cc451ee1f4a429e43292bbcd54fcd807e2c47675bac1781d9d81e9e6dc69028d428f5ee261750f626bcaf416a0e7badadf73fe1922207ae6c5209d16849e4a108f4a6f38694075f55177105ac4c2b97f6a474b94c03257d8d12b0196e2905d914b8c2213a1b9dc9608e1a2a1e03fe0820a813275de83be5e9734875787a9e006eb8574c23ddd49e2347d1ecfcedf3caa0a5dd45666368525b48ac14225d6422f82dbf59860ee4dc78e845d3c57668ce9b9e7a8d012491cef242078b458a956ad67c360fb6d8b86ab201d6217e49b55fa02a1dea2dbe88d0b08d30670d1b93c35cc5e41e088fccb267e41d6151cf8560496e1beeefe680744d9dabb383a4957466b4dc3e2bce7b135211da483d998a22fa687cc609641126c5dee3ed87291067916b5b065f40582163291d48e81ecd975d0d6fd52a31754f8ef15e43a560bd30ea5bf21915bd2e7007e607abbc6261edc8430cc7f789675b1fe83e807c5c475bd5178eba2fc40674706b0a68c6a428e5dec36e413e653c6db1178923ff87e2389a78bf9e93b713de4f4753f9f9d6a361369b609e1970c91ff9bd191c472e0bf2e8681412260ad0ef5855dc39f2084d45
   1956 	error packet for node 1: 1b4b09a935ce7af95b336baae307f2b400e3a7e808d9b4cf421cc4b3955620acb69dcdb656128dae8857adbd4e6b37fbb1be9c1f2f02e61e9e59a630c4c77cf383cb37b07413aa4de2f2fbf5b40ae40a91a8f4c6d74aeacef1bb1be4ecbc26ec2c824d2bc45db4b9098e732a769788f1cff3f5b41b0d25c132d40dc5ad045ef0043b15332ca3c5a09de2cdb17455a0f82a8f20da08346282823dab062cdbd2111e238528141d69de13de6d83994fbc711e3e269df63a12d3a4177c5c149150eb4dc2f589cd8acabcddba14dec3b0dada12d663b36176cd3c257c5460bab93981ad99f58660efa9b31d7e63b39915329695b3fa60e0a3bdb93e7e29a54ca6a8f360d3848866198f9c3da3ba958e7730847fe1e6478ce8597848d3412b4ae48b06e05ba9a104e648f6eaf183226b5f63ed2e68f77f7e38711b393766a6fab7921b03eba82b5d7cb78e34dc961948d6161eadd7cf5d95d9c56df2ff5faa6ccf85eacdc9ff2fc3abafe41c365a5bd14fd486d6b5e2f24199319e7813e02e798877ffe31a70ae2398d9e31b9e3727e6c1a3c0d995c67d37bb6e72e9660aaaa9232670f382add2edd468927e3303b6142672546997fe105583e7c5a3c4c2b599731308b5416e6c9a3f3ba55b181ad0439d3535356108b059f2cb8742eed7a58d4eba9fe79eaa77c34b12aff1abdaea93197aabd0e74cb271269ca464b3b06aef1d6573df5e1224179616036b368677f26479376681b772d3760e871d99efd34cca5cd6beca95190d967da820b21e5bec60082ea46d776b0517488c84f26d12873912d1f68fafd67bcf4c298e43cfa754959780682a2db0f75f95f0598c0d04fd014c50e4beb86a9e37d95f2bba7e5065ae052dc306555bca203d104c44a538b438c9762de299e1c4ad30d5b4a6460a76484661fc907682af202cd69b9a4473813b2fdc1142f1403a49b7e69a650b7cde9ff133997dcc6d43f049ecac5fce097a21e2bce49c810346426585e3a5a18569b4cddd5ff6bdec66d0b69fcbc5ab3b137b34cc8aefb8b850a764df0e685c81c326611d901c392a519866e132bbb73234f6a358ba284fbafb21aa3605cacbaf9d0c901390a98b7a7dac9d4f0b405f7291c88b2ff45874241c90ac6c5fc895a440453c344d3a365cb929f9c91b9e39cb98b142444aae03a6ae8284c77eb04b0a163813d4c21883df3c0f398f47bf127b5525f222107a2d8fe55289f0cfd3f4bbad6c5387b0594ef8a966afc9e804ccaf75fe39f35c6446f7ee076d433f2f8a44dba1515acc78e589fa8c71b0a006fe14feebd51d0e0aa4e51110d16759eee86192eee90b34432130f387e0ccd2ee71023f1f641cddb571c690107e08f592039fe36d81336a421e89378f351e633932a2f5f697d25b620ffb8e84bb6478e9bd229bf3b164b48d754ae97bd23f319e3c56b3bcdaaeb3bd7fc02ec02066b324cb72a09b6b43dec1097f49d69d3c138ce6f1a6402898baf7568c
   1957 	attribution data for node 1: 74a4ea61339463642a2182758871b2ea724f31f531aa98d80f1c3043febca41d5ee52e8b1e127e61719a0d078db8909748d57839e58424b91f063c4fbc8a221bef261140e66a9b596ca6d420a973ad54fef30646ae53ccf0855b61f291a81e0ec6dc0f6bf69f0ca0e5889b7e23f577ba67d2a7d6a2aa91264ab9b20630ed52f8ed56cc10a869807cd1a4c2cd802d8433fee5685d6a04edb0bff248a480b93b01904bed3bb31705d1ecb7332004290cc0cd9cc2f7907cf9db28eec02985301668f53fbc28c3e095c8f3a6cd8cab28e5e442fd9ba608b8b12e098731bbfda755393bd403c62289093b40390b2bae337fc87d2606ca028311d73a9ffbdffef56020c735ada30f54e577c6a9ec515ae2739290609503404b118d7494499ecf0457d75015bb60a16288a4959d74cf5ac5d8d6c113de39f748a418d2a7083b90c9c0a09a49149fd1f2d2cde4412e5aa2421eca6fd4f6fe6b2c362ff37d1a0608c931c7ca3b8fefcfd4c44ef9c38357a0767b14f83cb49bd1989fb3f8e2ab202ac98bd8439790764a40bf309ea2205c1632610956495720030a25dc7118e0c868fdfa78c3e9ecce58215579a0581b3bafdb7dbbe53be9e904567fdc0ce1236aab5d22f1ebc18997e3ea83d362d891e04c5785fd5238326f767bce499209f8db211a50e1402160486e98e7235cf397dbb9ae19fd9b79ef589c821c6f99f28be33452405a003b33f4540fe0a41dfcc286f4d7cc10b70552ba7850869abadcd4bb7f256823face853633d6e2a999ac9fcd259c71d08e266db5d744e1909a62c0db673745ad9585949d108ab96640d2bc27fb4acac7fa8b170a30055a5ede90e004df9a44bdc29aeb4a6bec1e85dde1de6aaf01c6a5d12405d0bec22f49026cb23264f8c04b8401d3c2ab6f2e109948b6193b3bec27adfe19fb8afb8a92364d6fc5b219e8737d583e7ff3a4bcb75d53edda3bf3f52896ac36d8a877ad9f296ea6c045603fc62ac4ae41272bde85ef7c3b3fd3538aacfd5b025fefbe277c2906821ecb20e6f75ea479fa3280f9100fb0089203455c56b6bc775e5c2f0f58c63edd63fa3eec0b40da4b276d0d41da2ec0ead865a98d12bc694e23d8eaadd2b4d0ee88e9570c88fb878930f492e036d27998d593e47763927ff7eb80b188864a3846dd2238f7f95f4090ed399ae95deaeb37abca1cf37c397cc12189affb42dca46b4ff6988eb8c060691d155302d448f50ff70a794d97c0408f8cee9385d6a71fa412e36edcb22dbf433db9db4779f27b682ee17fc05e70c8e794b9f7f6d1
   1958 
   1959     # forwarding error packet
   1960 	shared_secret = 53eb63ea8a3fec3b3cd433b85cd62a4b145e1dda09391b348c4e1cd36a03ea66
   1961 	ammag_key = 3761ba4d3e726d8abb16cba5950ee976b84937b61b7ad09e741724d7dee12eb5
   1962 	stream = 3699fd352a948a05f604763c0bca2968d5eaca2b0118602e52e59121f050936c8dd90c24df7dc8cf8f1665e39a6c75e9e2c0900ea245c9ed3b0008148e0ae18bbfaea0c711d67eade980c6f5452e91a06b070bbde68b5494a92575c114660fb53cf04bf686e67ffa4a0f5ae41a59a39a8515cb686db553d25e71e7a97cc2febcac55df2711b6209c502b2f8827b13d3ad2f491c45a0cafe7b4d8d8810e805dee25d676ce92e0619b9c206f922132d806138713a8f69589c18c3fdc5acee41c1234b17ecab96b8c56a46787bba2c062468a13919afc18513835b472a79b2c35f9a91f38eb3b9e998b1000cc4a0dbd62ac1a5cc8102e373526d7e8f3c3a1b4bfb2f8a3947fe350cb89f73aa1bb054edfa9895c0fc971c2b5056dc8665902b51fced6dff80c4d247db977c15a710ce280fbd0ae3ca2a245b1c967aeb5a1a4a441c50bc9ceb33ca64b5ca93bd8b50060520f35a54a148a4112e8762f9d0b0f78a7f46a5f06c7a4b0845d020eb505c9e527aabab71009289a6919520d32af1f9f51ce4b3655c6f1aae1e26a16dc9aae55e9d4a6f91d4ba76e96fcb851161da3fc39d0d97ce30a5855c75ac2f613ff36a24801bcbd33f0ce4a3572b9a2fca21efb3b07897fc07ee71e8b1c0c6f8dbb7d2c4ed13f11249414fc94047d1a4a0be94d45db56af4c1a3bf39c9c5aa18209eaebb9e025f670d4c8cc1ee598c912db154eaa3d0c93cb3957e126c50486bf98c852ad326b5f80a19df6b2791f3d65b8586474f4c5dcb2aca0911d2257d1bb6a1e9fc1435be879e75d23290f9feb93ed40baaeca1c399fc91fb1da3e5f0f5d63e543a8d12fe6f7e654026d3a118ab58cb14bef9328d4af254215eb1f639828cc6405a3ab02d90bb70a798787a52c29b3a28fc67b0908563a65f08112abd4e9115cb01db09460c602aba3ddc375569dc3abe42c61c5ea7feb39ad8b05d8e2718e68806c0e1c34b0bc85492f985f8b3e76197a50d63982b780187078f5c59ebd814afaeffc7b2c6ee39d4f9c8c45fb5f685756c563f4b9d028fe7981b70752f5a31e44ba051ab40f3604c8596f1e95dc9b0911e7ede63d69b5eecd245fbecbcf233cf6eba842c0fec795a5adeab2100b1a1bc62c15046d48ec5709da4af64f59a2e552ddbbdcda1f543bb4b687e79f2253ff0cd9ba4e6bfae8e510e5147273d288fd4336dbd0b6617bf0ef71c0b4f1f9c1dc999c17ad32fe196b1e2b27baf4d59bba8e5193a9595bd786be00c32bae89c5dbed1e994fddffbec49d0e2d270bcc1068850e5d7e7652e274909b3cf5e3bc6bf64def0bbeac974a76d835e9a10bdd7896f27833232d907b7405260e3c986569bb8fdd65a55b020b91149f27bda9e63b4c2cc5370bcc81ef044a68c40c1b178e4265440334cc40f59ab5f82a022532805bfa659257c8d8ab9b4aef6abbd05de284c2eb165ef35737e3d387988c566f7b1ca0b1fc3e7b4ed991b77f23775e1c36a09a991384a33b78
   1963 	error packet for node 0: 2dd2f49c1f5af0fcad371d96e8cddbdcd5096dc309c1d4e110f955926506b3c03b44c192896f45610741c85ed4074212537e0c118d472ff3a559ae244acd9d783c65977765c5d4e00b723d00f12475aafaafff7b31c1be5a589e6e25f8da2959107206dd42bbcb43438129ce6cce2b6b4ae63edc76b876136ca5ea6cd1c6a04ca86eca143d15e53ccdc9e23953e49dc2f87bb11e5238cd6536e57387225b8fff3bf5f3e686fd08458ffe0211b87d64770db9353500af9b122828a006da754cf979738b4374e146ea79dd93656170b89c98c5f2299d6e9c0410c826c721950c780486cd6d5b7130380d7eaff994a8503a8fef3270ce94889fe996da66ed121741987010f785494415ca991b2e8b39ef2df6bde98efd2aec7d251b2772485194c8368451ad49c2354f9d30d95367bde316fec6cbdddc7dc0d25e99d3075e13d3de0822669861dafcd29de74eac48b64411987285491f98d78584d0c2a163b7221ea796f9e8671b2bb91e38ef5e18aaf32c6c02f2fb690358872a1ed28166172631a82c2568d23238017188ebbd48944a147f6cdb3690d5f88e51371cb70adf1fa02afe4ed8b581afc8bcc5104922843a55d52acde09bc9d2b71a663e178788280f3c3eae127d21b0b95777976b3eb17be40a702c244d0e5f833ff49dae6403ff44b131e66df8b88e33ab0a58e379f2c34bf5113c66b9ea8241fc7aa2b1fa53cf4ed3cdd91d407730c66fb039ef3a36d4050dde37d34e80bcfe02a48a6b14ae28227b1627b5ad07608a7763a531f2ffc96dff850e8c583461831b19feffc783bc1beab6301f647e9617d14c92c4b1d63f5147ccda56a35df8ca4806b8884c4aa3c3cc6a174fdc2232404822569c01aba686c1df5eecc059ba97e9688c8b16b70f0d24eacfdba15db1c71f72af1b2af85bd168f0b0800483f115eeccd9b02adf03bdd4a88eab03e43ce342877af2b61f9d3d85497cd1c6b96674f3d4f07f635bb26add1e36835e321d70263b1c04234e222124dad30ffb9f2a138e3ef453442df1af7e566890aedee568093aa922dd62db188aa8361c55503f8e2c2e6ba93de744b55c15260f15ec8e69bb01048ca1fa7bbbd26975bde80930a5b95054688a0ea73af0353cc84b997626a987cc06a517e18f91e02908829d4f4efc011b9867bd9bfe04c5f94e4b9261d30cc39982eb7b250f12aee2a4cce0484ff34eebba89bc6e35bd48d3968e4ca2d77527212017e202141900152f2fd8af0ac3aa456aae13276a13b9b9492a9a636e18244654b3245f07b20eb76b8e1cea8c55e5427f08a63a16b0a633af67c8e48ef8e53519041c9138176eb14b8782c6c2ee76146b8490b97978ee73cd0104e12f483be5a4af414404618e9f6633c55dda6f22252cb793d3d16fae4f0e1431434e7acc8fa2c009d4f6e345ade172313d558a4e61b4377e31b8ed4e28f7cd13a7fe3f72a409bc3bdabfe0ba47a6d861e21f64d2fac706dab18b3e546df4
   1964     attribution data for node 0: 84986c936d26bfd3bb2d34d3ec62cfdb63e0032fdb3d9d75f3e5d456f73dffa7e35aab1db4f1bd3b98ff585caf004f656c51037a3f4e810d275f3f6aea0c8e3a125ebee5f374b6440bcb9bb2955ebf706f42be9999a62ed49c7a81fc73c0b4a16419fd6d334532f40bf179dd19afec21bd8519d5e6ebc3802501ef373bc378eee1f14a6fc5fab5b697c91ce31d5922199d1b0ad5ee12176aacafc7c81d54bc5b8fb7e63f3bfd40a3b6e21f985340cbd1c124c7f85f0369d1aa86ebc66def417107a7861131c8bcd73e8946f4fb54bfac87a2dc15bd7af642f32ae583646141e8875ef81ec9083d7e32d5f135131eab7a43803360434100ff67087762bbe3d6afe2034f5746b8c50e0c3c20dd62a4c174c38b1df7365dccebc7f24f19406649fbf48981448abe5c858bbd4bef6eb983ae7a23e9309fb33b5e7c0522554e88ca04b1d65fc190947dead8c0ccd32932976537d869b5ca53ed4945bccafab2a014ea4cbdc6b0250b25be66ba0afff2ff19c0058c68344fd1b9c472567147525b13b1bc27563e61310110935cf89fda0e34d0575e2389d57bdf2869398ca2965f64a6f04e1d1c2edf2082b97054264a47824dd1a9691c27902b39d57ae4a94dd6481954a9bd1b5cff4ab29ca221fa2bf9b28a362c9661206f896fc7cec563fb80aa5eaccb26c09fa4ef7a981e63028a9c4dac12f82ccb5bea090d56bbb1a4c431e315d9a169299224a8dbd099fb67ea61dfc604edf8a18ee742550b636836bb552dabb28820221bf8546331f32b0c143c1c89310c4fa2e1e0e895ce1a1eb0f43278fdb528131a3e32bfffe0c6de9006418f5309cba773ca38b6ad8507cc59445ccc0257506ebc16a4c01d4cd97e03fcf7a2049fea0db28447858f73b8e9fe98b391b136c9dc510288630a1f0af93b26a8891b857bfe4b818af99a1e011e6dbaa53982d29cf74ae7dffef45545279f19931708ed3eede5e82280eab908e8eb80abff3f1f023ab66869297b40da8496861dc455ac3abe1efa8a6f9e2c4eda48025d43a486a3f26f269743eaa30d6f0e1f48db6287751358a41f5b07aee0f098862e3493731fe2697acce734f004907c6f11eef189424fee52cd30ad708707eaf2e441f52bcf3d0c5440c1742458653c0c8a27b5ade784d9e09c8b47f1671901a29360e7e5e94946b9c75752a1a8d599d2a3e14ac81b84d42115cd688c8383a64fc6e7e1dc5568bb4837358ebe63207a4067af66b2027ad2ce8fb7ae3a452d40723a51fdf9f9c9913e8029a222cf81d12ad41e58860d75deb6de30ad
   1965 
   1966 ## Returning success
   1967 
   1968 A successful payment without a `fulfillment_payload` using the parameters above would result in the following
   1969 attribution data values:
   1970 
   1971 attribution data for node 4:
   1972 d77d0711b5f71d1d1be56bd88b3bb7ebc1792bb739ea7ebc1bc3b031b8bc2df3a50e25aeb99f47d7f7ab39e24187d3f4df9c4333463b053832ee9ac07274a5261b8b2a01fc09ce9ea7cd04d7b585dfb83299fb6570d71f793c1fcac0ef498766952c8c6840efa02a567d558a3cf6822b12476324b9b9efa03e5f8f26f81fa93daac46cbf00c98e69b6747cf69caaa2a71b025bd18830c4c54cd08f598cfde6197b3f2a951aba907c964c0f5d19a44e6d1d7279637321fa598adde927b3087d238f8b426ecde500d318617cdb7a56e6ce3520fc95be41a549973764e4dc483853ecc313947709f1b5199cb077d46e701fa633e11d3e13b03e9212c115ca6fa004b2f3dd912814693b705a561a06da54cdf603677a3abecdc22c7358c2de3cef771b366a568150aeecc86ad1990bb0f4e2865933b03ea0df87901bff467908273dc6cea31cbab0e2b8d398d10b001058c259ed221b7b55762f4c7e49c8c11a45a107b7a2c605c26dc5b0b10d719b1c844670102b2b6a36c43fe4753a78a483fc39166ae28420f112d50c10ee64ca69569a2f690712905236b7c2cb7ac8954f02922d2d918c56d42649261593c47b14b324a65038c3c5be8d3c403ce0c8f19299b1664bf077d7cf1636c4fb9685a8e58b7029fd0939fa07925a60bed339b23f973293598f595e75c8f9d455d7cebe4b5e23357c8bd47d66d6628b39427e37e0aecbabf46c11be6771f7136e108a143ae9bafba0fc47a51b6c7deef4cba54bae906398ee3162a41f2191ca386b628bde7e1dd63d1611aa01a95c456df337c763cb8c3a81a6013aa633739d8cd554c688102211725e6adad165adc1bcd429d020c51b4b25d2117e8bb27eb0cc7020f9070d4ad19ac31a76ebdf5f9246646aeadbfb9a3f1d75bd8237961e786302516a1a781780e8b73f58dc06f307e58bd0eb1d8f5c9111f01312974c1dc777a6a2d3834d8a2a40014e9818d0685cb3919f6b3b788ddc640b0ff9b1854d7098c7dd6f35196e902b26709640bc87935a3914869a807e8339281e9cedaaca99474c3e7bdd35050bb998ab4546f9900904e0e39135e861ff7862049269701081ebce32e4cca992c6967ff0fd239e38233eaf614af31e186635e9439ec5884d798f9174da6ff569d68ed5c092b78bd3f880f5e88a7a8ab36789e1b57b035fb6c32a6358f51f83e4e5f46220bcad072943df8bd9541a61b7dae8f30fa3dd5fb39b1fd9a0b8e802552b78d4ec306ecee15bfe6da14b29ba6d19ce5be4dd478bca74a52429cd5309d404655c3dec85c252
   1973 
   1974 attribution data for node 3:
   1975 1571e10db7f8aa9f8e7e99caaf9c892e106c817df1d8e3b7b0e39d1c48f631e473e17e205489dd7b3c634cac3be0825cbf01418cd46e83c24b8d9c207742db9a0f0e5bcd888086498159f08080ba7bf3ea029c0b493227c4e75a90f70340d9e21f00979fc7e4fb2078477c1a457ba242ed54b313e590b13a2a13bfeed753dab133c78059f460075b2594b4c31c50f31076f8f1a0f7ad0530d0fadaf2d86e505ff9755940ec0665f9e5bc58cad6e523091f94d0bcd3c6c65ca1a5d401128dcc5e14f9108b32e660017c13de598bcf9d403710857cccb0fb9c2a81bfd66bc4552e1132afa3119203a4aaa1e8839c1dab8cbdcde7b527aca3f54bde651aa9f3f2178829cee3f1c0b9292758a40cc63bd998fcd0d3ed4bdcaf1023267b8f8e44130a63ad15f76145936552381eabb6d684c0a3af6ba8efcf207cebaea5b7acdbb63f8e7221102409d10c23f0514dc9f4d0efb2264161a193a999a23e992632710580a0d320f676d367b9190721194514457761af05207cdab2b6328b1b3767eacb36a7ef4f7bd2e16762d13df188e0898b7410f62459458712a44bf594ae662fd89eb300abb6952ff8ad40164f2bcd7f86db5c7650b654b79046de55d51aa8061ce35f867a3e8f5bf98ad920be827101c64fb871d86e53a4b3c0455bfac5784168218aa72cbee86d9c750a9fa63c363a8b43d7bf4b2762516706a306f0aa3be1ec788b5e13f8b24837e53ac414f211e11c7a093cd9653dfa5fba4e377c79adfa5e841e2ddb6afc054fc715c05ddc6c8fc3e1ee3406e1ffceb2df77dc2f02652614d1bfcfaddebaa53ba919c7051034e2c7b7cfaabdf89f26e7f8e3f956d205dfab747ad0cb505b85b54a68439621b25832cbc2898919d0cd7c0a64cfd235388982dd4dd68240cb668f57e1d2619a656ed326f8c92357ee0d9acead3c20008bc5f04ca8059b55d77861c6d04dfc57cfba57315075acbe1451c96cf28e1e328e142890248d18f53b5d3513ce574dea7156cf596fdb3d909095ec287651f9cf1bcdc791c5938a5dd9b47e84c004d24ab3ae74492c7e8dcc1da15f65324be2672947ec82074cac8ce2b925bc555facbbf1b55d63ea6fbea6a785c97d4caf2e1dad9551b7f66c31caae5ebc7c0047e892f201308fcf452c588be0e63d89152113d87bf0dbd01603b4cdc7f0b724b0714a9851887a01f709408882e18230fe810b9fafa58a666654576d8eba3005f07221f55a6193815a672e5db56204053bc4286fa3db38250396309fd28011b5708a26a2d76c4a333b69b6bfd272fb
   1976 
   1977 attribution data for node 2:
   1978 34e34397b8621ec2f2b54dbe6c14073e267324cd60b152bce76aec8729a6ddefb61bc263be4b57bd592aae604a32bea69afe6ef4a6b573c26b17d69381ec1fc9b5aa769d148f2f1f8b5377a73840bb6dffc324ded0d1c00dc0c99e3dbc13273b2f89510af6410b525dd8836208abbbaae12753ae2276fa0ca49950374f94e187bf65cefcdd9dd9142074edc4bd0052d0eb027cb1ab6182497f9a10f9fe800b3228e3c088dab60081c807b30a67313667ca8c9e77b38b161a037cae8e973038d0fc4a97ea215914c6c4e23baf6ac4f0fb1e7fcc8aac3f6303658dae1f91588b535eb678e2200f45383c2590a55dc181a09f2209da72f79ae6745992c803310d39f960e8ecf327aed706e4b3e2704eeb9b304dc0e0685f5dcd0389ec377bdba37610ad556a0e957a413a56339dd3c40817214bced5802beee2ee545bdd713208751added5fc0eb2bc89a5aa2decb18ee37dac39f22a33b60cc1a369d24de9f3d2d8b63c039e248806de4e36a47c7a0aed30edd30c3d62debdf1ad82bf7aedd7edec413850d91c261e12beec7ad1586a9ad25b2db62c58ca17119d61dcc4f3e5c4520c42a8e384a45d8659b338b3a08f9e123a1d3781f5fc97564ccff2c1d97f06fa0150cfa1e20eacabefb0c339ec109336d207cc63d9170752fc58314c43e6d4a528fd0975afa85f3aa186ff1b6b8cb12c97ed4ace295b0ef5f075f0217665b8bb180246b87982d10f43c9866b22878106f5214e99188781180478b07764a5e12876ddcb709e0a0a8dd42cf004c695c6fc1669a6fd0e4a1ca54b024d0d80eac492a9e5036501f36fb25b72a054189294955830e43c18e55668337c8c6733abb09fc2d4ade18d5a853a2b82f7b4d77151a64985004f1d9218f2945b63c56fdebd1e96a2a7e49fa70acb4c39873947b83c191c10e9a8f40f60f3ad5a2be47145c22ea59ed3f5f4e61cb069e875fb67142d281d784bf925cc286eacc2c43e94d08da4924b83e58dbf2e43fa625bdd620eba6d9ce960ff17d14ed1f2dbee7d08eceb540fdc75ff06dabc767267658fad8ce99e2a3236e46d2deedcb51c3c6f81589357edebac9772a70b3d910d83cd1b9ce6534a011e9fa557b891a23b5d88afcc0d9856c6dabeab25eea55e9a248182229e4927f268fe5431672fcce52f434ca3d27d1a2136bae5770bb36920df12fbc01d0e8165610efa04794f414c1417f1d4059435c5385bfe2de83ce0e238d6fd2dbd3c0487c69843298577bfa480fe2a16ab2a0e4bc712cd8b5a14871cda61c993b6835303d9043d7689a
   1979 
   1980 attribution data for node 1:
   1981 74a4ea61339463642a2182758871b2ea724f31f531aa98d80f1c3043febca41d5ee52e8b1e127e61719a0d078db8909748d57839e58424b91f063c4fbc8a221bef261140e66a9b596ca6d420a973ad5431adfa8280a7355462fe50d4cac15cdfbd7a535c4b72a0b6d7d8a64cff3f719ff9b8be28036826342dc3bf3781efc70063d1e6fc79dff86334ae0564a5ab87bd61f8446465ef6713f8c4ef9d0200ebb375f90ee115216b469af42de554622df222858d30d733af1c9223e327ae09d9126be8baee6dd59a112d83a57cc6e0252104c11bc11705d384220eedd72f1a29a0597d97967e28b2ad13ba28b3d8a53c3613c1bb49fe9700739969ef1f795034ef9e2e983af2d3bbd6c637fb12f2f7dfc3aee85e08711e9b604106e95d7a4974e5b047674a6015792dae5d913681d84f71edd415910582e5d86590df2ecfd561dc6e1cdb08d3e10901312326a45fb0498a177319389809c6ba07a76cfad621e07b9af097730e94df92fbd311b2cb5da32c80ab5f14971b6d40f8e2ab202ac98bd8439790764a40bf309ea2205c1632610956495720030a25dc7118e0c868fdfa78c3e9ecce58215579a0581b3bafdb7dbbe53be9e904567fdc0ce1236aab5d22f1ebc18997e3ea83d362d891e04c5785fd5238326f767bce499209f8db211a50e1402160486e98e7235cf397dbb9ae19fd9b79ef589c821c6f99f28be33452405a003b33f4540fe0a41dfcc286f4d7cc10b70552ba7850869abadcd4bb7f256823face853633d6e2a999ac9fcd259c71d08e266db5d744e1909a62c0db673745ad9585949d108ab96640d2bc27fb4acac7fa8b170a30055a5ede90e004df9a44bdc29aeb4a6bec1e85dde1de6aaf01c6a5d12405d0bec22f49026cb23264f8c04b8401d3c2ab6f2e109948b6193b3bec27adfe19fb8afb8a92364d6fc5b219e8737d583e7ff3a4bcb75d53edda3bf3f52896ac36d8a877ad9f296ea6c045603fc62ac4ae41272bde85ef7c3b3fd3538aacfd5b025fefbe277c2906821ecb20e6f75ea479fa3280f9100fb0089203455c56b6bc775e5c2f0f58c63edd63fa3eec0b40da4b276d0d41da2ec0ead865a98d12bc694e23d8eaadd2b4d0ee88e9570c88fb878930f492e036d27998d593e47763927ff7eb80b188864a3846dd2238f7f95f4090ed399ae95deaeb37abca1cf37c397cc12189affb42dca46b4ff6988eb8c060691d155302d448f50ff70a794d97c0408f8cee9385d6a71fa412e36edcb22dbf433db9db4779f27b682ee17fc05e70c8e794b9f7f6d1
   1982 
   1983 attribution data for node 0:
   1984 84986c936d26bfd3bb2d34d3ec62cfdb63e0032fdb3d9d75f3e5d456f73dffa7e35aab1db4f1bd3b98ff585caf004f656c51037a3f4e810d275f3f6aea0c8e3a125ebee5f374b6440bcb9bb2955ebf70c06d64090f9f6cf098200305f7f4305ba9e1350a0c3f7dab4ccf35b8399b9650d8e363bf83d3a0a09706433f0adae6562eb338b21ea6f21329b3775905e59187c325c9cbf589f5da5e915d9e5ad1d21aa1431f9bdc587185ed8b5d4928e697e67cc96bee6d5354e3764cede3f385588fa665310356b2b1e68f8bd30c75d395405614a40a587031ebd6ace60dfb7c6dd188b572bd8e3e9a47b06c2187b528c5ed35c32da5130a21cd881138a5fcac806858ce6c596d810a7492eb261bcc91cead1dae75075b950c2e81cecf7e5fdb2b51df005d285803201ce914dfbf3218383829a0caa8f15486dd801133f1ed7edec436730b0ec98f48732547927229ac80269fcdc5e4f4db264274e940178732b429f9f0e582c559f994a7cdfb76c93ffc39de91ff936316726cc561a6520d47b2cd487299a96322dadc463ef06127fc63902ff9cc4f265e2fbd9de3fa5e48b7b51aa0850580ef9f3b5ebb60c6c3216c5a75a93e82936113d9cad57ae4a94dd6481954a9bd1b5cff4ab29ca221fa2bf9b28a362c9661206f896fc7cec563fb80aa5eaccb26c09fa4ef7a981e63028a9c4dac12f82ccb5bea090d56bbb1a4c431e315d9a169299224a8dbd099fb67ea61dfc604edf8a18ee742550b636836bb552dabb28820221bf8546331f32b0c143c1c89310c4fa2e1e0e895ce1a1eb0f43278fdb528131a3e32bfffe0c6de9006418f5309cba773ca38b6ad8507cc59445ccc0257506ebc16a4c01d4cd97e03fcf7a2049fea0db28447858f73b8e9fe98b391b136c9dc510288630a1f0af93b26a8891b857bfe4b818af99a1e011e6dbaa53982d29cf74ae7dffef45545279f19931708ed3eede5e82280eab908e8eb80abff3f1f023ab66869297b40da8496861dc455ac3abe1efa8a6f9e2c4eda48025d43a486a3f26f269743eaa30d6f0e1f48db6287751358a41f5b07aee0f098862e3493731fe2697acce734f004907c6f11eef189424fee52cd30ad708707eaf2e441f52bcf3d0c5440c1742458653c0c8a27b5ade784d9e09c8b47f1671901a29360e7e5e94946b9c75752a1a8d599d2a3e14ac81b84d42115cd688c8383a64fc6e7e1dc5568bb4837358ebe63207a4067af66b2027ad2ce8fb7ae3a452d40723a51fdf9f9c9913e8029a222cf81d12ad41e58860d75deb6de30ad
   1985 
   1986 A successful payment with a `fulfillment_payload` using the same route parameters contains the following
   1987 `fulfillment_payload_tlvs` records:
   1988 
   1989     type  = 1 (`padding`)
   1990     value = 245 zero bytes
   1991 
   1992     type  = 65537
   1993     value = 070809
   1994 
   1995 These two records serialize to 256 bytes: 247 bytes for the `padding` record and 9 bytes for the type `65537` record.
   1996 With the 16-byte Poly1305 tag, this results in a 272-byte `fulfillment_payload`.
   1997 
   1998 The following are the `fulfillment_payload` and attribution data values at each hop:
   1999 
   2000 fulfillment payload for node 4:
   2001 b5b1fed711469adc0da510494818ce54624b537e7a8aba4b190403d90439798a694bdca0d0d53c18487d9940664a8416eb855290621e186081b2222e279bfa6dcb1645a39c2cbc569ed66f8f9ed0c10d4dcbc61abe6685d558d5fb0ec104bf1d14ab1e42a4cf41f1950c3fd06574a8278f553382a78b2725f36559d6db7aeccd41569f88b3722c3535358915648bd2e82c53cbaaa14c34487a77799cc4650d5c2e2edece013cf4095ee99bc96e1a850fa3373538448bd6d5a1771f50ca39b2a4e85c7201be5bedd5fae801e5e99491e6fb1e76457c48094f347205d1170df06e2fa7128d0dfe7d24716fb621632b948f9ad9edba24fba9293906e193a7ca3c234cce42ca9470c08952be1dbd3dcc8452
   2002 attribution data for node 4:
   2003 d77d0711b5f71d1d1be56bd88b3bb7ebc1792bb739ea7ebc1bc3b031b8bc2df3a50e25aeb99f47d7f7ab39e24187d3f4df9c4333463b053832ee9ac07274a5261b8b2a01fc09ce9ea7cd04d7b585dfb83299fb6570d71f793c1fcac0ef498766952c8c6840efa02a567d558a3cf6822b12476324b9b9efa03e5f8f26f81fa93daac46cbf00c98e69b6747cf69caaa2a71b025bd18830c4c54cd08f598cfde6197b3f2a951aba907c964c0f5d19a44e6d1d7279637321fa598adde927b3087d238f8b426ecde500d318617cdb7a56e6ce3520fc95be41a549973764e4dc483853ecc313947709f1b5199cb077d46e701fa633e11d3e13b03e9212c115ca6fa004b2f3dd912814693b705a561a06da54cdf603677a3abecdc22c7358c2de3cef771b366a568150aeecc86ad1990bb0f4e2865933b03ea0df87901bff467908273dc6cea31cbab0e2b8d398d10b001058c259ed221b7b55762f4c7e49c8c11a45a107b7a2c605c26dc5b0b10d719b1c844670102b2b6a36c43fe4753a78a483fc39166ae28420f112d50c10ee64ca69569a2f690712905236b7c2cb7ac8954f02922d2d918c56d42649261593c47b14b324a65038c3c5be8d3c403ce0c8f19299b1664bf077d7cf1636c4fb9685a8e58b7029fd0939fa07925a60bed339b23f973293598f595e75c8f9d455d7cebe4b5e23357c8bd47d66d6628b39427e37e0aecbabf46c11be6771f7136e108a143ae9bafba0fc47a51b6c7deef4cba54bae906398ee3162a41f2191ca386b628bde7e1dd63d1611aa01a95c456df337c763cb8c3a81a6013aa633739d8cd554c688102211725e6adad165adc1bcd429d020c51b4b25d2117e8bb27eb0cc7020f9070d4ad19ac31a76ebdf5f9246646aeadbfb9a3f1d75bd8237961e786302516a1a781780e8b73f58dc06f307e58bd0eb1d8f5c9111f01312974c1dc777a6a2d3834d8a2a40014e9818d0685cb3919f6b3b788ddc640b0ff9b1854d7098c7dd6f35196e902b26709640bc87935a3914869a807e8339281e9cedaaca99474c3e7bdd35050bb998ab4546f9900904e0e39135e861ff7862049269701081ebce32e4cca992c6967ff0fd239e38233eaf614af31e186635e9439ec5884d798f9174da6ff569d68ed5c092b78bd3f880f5e88a7a8ab36789e1b57b035fb6c32a6358f51f83e4e5f46220bcad072943df8bd9541a61b7dae8f30fa3dd5fb39b1fd9a0b8e802552b78d4ec306ecee15bfe6da14b29ba6d19ce5be4dd478bca74a52429cd5309d404655c3dec85c252
   2004 
   2005 fulfillment payload for node 3:
   2006 d4cd5f33730d592c4249f3e31233af0572bf729218ca375ddd8aa518b3fa466d6101f77904b013dd4ef3c912d9278edc09923288c1c6df3fb636053cb6a2fa4bf7e9d7500310a4fc819d4f26a0a03d4fd73c74ab281a2dcf2ec8bb56ecabb1a9884478a172348bf38ddf3dfd579d3c9393dd79a5650da2caedd41fd531fa4ec9f3a46bfc05df7244f30d115687eacc568395e83a165bfe1bc91073af0172e27488771c9fd7744b45c883d538e90bbbc627bcc428c5ebb71fee5877b7a6d23a198a544565dee2fb2ed736b69f8c7c696dd56fd48e88a24017306f74106a0898622abb24fbf6f3b534ff32ceda7d07d05800f9c32730fcb47a5a774cd464503936d2432e8b450ade0cdd14b2ea1bef2e71
   2007 attribution data for node 3:
   2008 1571e10db7f8aa9f8e7e99caaf9c892e106c817df1d8e3b7b0e39d1c48f631e473e17e205489dd7b3c634cac3be0825cbf01418cd46e83c24b8d9c207742db9a0f0e5bcd888086498159f08080ba7bf3bc5cfe92707ca5d3bc81720c889a034b89cf2d376a67c5d63651e3af267efb768a38f488eac2940cf5525e959599984c3cf56c1daaa92476de574582eba16f90b9a6a74f4aa5f1cdad2115c994a09565f9755940ec0665f9e5bc58cad6e523091f94d0bcd3c6c65ca1a5d401128dcc5e14f9108b32e660017c13de598bcf9d403710857cccb0fb9c2a81bfd66bc4552e1132afa3119203a4aaa1e8839c1dab8cbdcde7b527aca3f54bde651aa9f3f2178829cee3f1c0b9292758a40cc63bd998fcd0d3ed4bdcaf1023267b8f8e44130a63ad15f76145936552381eabb6d684c0a3af6ba8efcf207cebaea5b7acdbb63f8e7221102409d10c23f0514dc9f4d0efb2264161a193a999a23e992632710580a0d320f676d367b9190721194514457761af05207cdab2b6328b1b3767eacb36a7ef4f7bd2e16762d13df188e0898b7410f62459458712a44bf594ae662fd89eb300abb6952ff8ad40164f2bcd7f86db5c7650b654b79046de55d51aa8061ce35f867a3e8f5bf98ad920be827101c64fb871d86e53a4b3c0455bfac5784168218aa72cbee86d9c750a9fa63c363a8b43d7bf4b2762516706a306f0aa3be1ec788b5e13f8b24837e53ac414f211e11c7a093cd9653dfa5fba4e377c79adfa5e841e2ddb6afc054fc715c05ddc6c8fc3e1ee3406e1ffceb2df77dc2f02652614d1bfcfaddebaa53ba919c7051034e2c7b7cfaabdf89f26e7f8e3f956d205dfab747ad0cb505b85b54a68439621b25832cbc2898919d0cd7c0a64cfd235388982dd4dd68240cb668f57e1d2619a656ed326f8c92357ee0d9acead3c20008bc5f04ca8059b55d77861c6d04dfc57cfba57315075acbe1451c96cf28e1e328e142890248d18f53b5d3513ce574dea7156cf596fdb3d909095ec287651f9cf1bcdc791c5938a5dd9b47e84c004d24ab3ae74492c7e8dcc1da15f65324be2672947ec82074cac8ce2b925bc555facbbf1b55d63ea6fbea6a785c97d4caf2e1dad9551b7f66c31caae5ebc7c0047e892f201308fcf452c588be0e63d89152113d87bf0dbd01603b4cdc7f0b724b0714a9851887a01f709408882e18230fe810b9fafa58a666654576d8eba3005f07221f55a6193815a672e5db56204053bc4286fa3db38250396309fd28011b5708a26a2d76c4a333b69b6bfd272fb
   2009 
   2010 fulfillment payload for node 2:
   2011 b584abb82973d6112d1474e8685a21253e4936c0b27e7f122c5443694d99bb263e1a8f9724f7cc7b50ce9e79cdbc63738a97bd0d31acee4d15143fea72d1d7dd44c0828a7e3f4fbdc178c2a05caf13fa0eedf325479052aa855aa955e22520fcfbafc5de47d52fc304d4da1b2ba2882861038fc79f6ff6eb0a600e17af44cf25941318a95cb47788e65a4430c9b30d38a2d4e291f3657e5b83712cebeac1f942d4d066f146505d227aefb995cdf098e2e8d82c9118859bf9b1477e3b5bccce02288082bb2e1ded74d94a3278d500298e0a91435a9f6304436a614cfe59e33283067be5bda617e6e094ce861a2c48e51f73ba9dcfab879c6a3a19fbe60697432bb5b04dbc401d53757c133ed01a5ad4ad
   2012 attribution data for node 2:
   2013 34e34397b8621ec2f2b54dbe6c14073e267324cd60b152bce76aec8729a6ddefb61bc263be4b57bd592aae604a32bea69afe6ef4a6b573c26b17d69381ec1fc9b5aa769d148f2f1f8b5377a73840bb6d40734019bf9dcbb731aeac3b1052e6703e8ffa550f2f3b6b40df0faa5bd67271a99a81e81265b567522733358a1c8a3b770d207ba8a22ba238abf056af11042474f4fd44bbb21e3ea8d978058a8cc67a11ad429f816de27a43dd69a3f1fe8ccf670fa081fd9d89af6079f7baf05c7f4bf318b2dcfe18f5bd8628795265f61cbf40b6efa757fc9242927c329f5e06ddbce3be8c1f5dd48a0370eb559f5dc181a09f2209da72f79ae6745992c803310d39f960e8ecf327aed706e4b3e2704eeb9b304dc0e0685f5dcd0389ec377bdba37610ad556a0e957a413a56339dd3c40817214bced5802beee2ee545bdd713208751added5fc0eb2bc89a5aa2decb18ee37dac39f22a33b60cc1a369d24de9f3d2d8b63c039e248806de4e36a47c7a0aed30edd30c3d62debdf1ad82bf7aedd7edec413850d91c261e12beec7ad1586a9ad25b2db62c58ca17119d61dcc4f3e5c4520c42a8e384a45d8659b338b3a08f9e123a1d3781f5fc97564ccff2c1d97f06fa0150cfa1e20eacabefb0c339ec109336d207cc63d9170752fc58314c43e6d4a528fd0975afa85f3aa186ff1b6b8cb12c97ed4ace295b0ef5f075f0217665b8bb180246b87982d10f43c9866b22878106f5214e99188781180478b07764a5e12876ddcb709e0a0a8dd42cf004c695c6fc1669a6fd0e4a1ca54b024d0d80eac492a9e5036501f36fb25b72a054189294955830e43c18e55668337c8c6733abb09fc2d4ade18d5a853a2b82f7b4d77151a64985004f1d9218f2945b63c56fdebd1e96a2a7e49fa70acb4c39873947b83c191c10e9a8f40f60f3ad5a2be47145c22ea59ed3f5f4e61cb069e875fb67142d281d784bf925cc286eacc2c43e94d08da4924b83e58dbf2e43fa625bdd620eba6d9ce960ff17d14ed1f2dbee7d08eceb540fdc75ff06dabc767267658fad8ce99e2a3236e46d2deedcb51c3c6f81589357edebac9772a70b3d910d83cd1b9ce6534a011e9fa557b891a23b5d88afcc0d9856c6dabeab25eea55e9a248182229e4927f268fe5431672fcce52f434ca3d27d1a2136bae5770bb36920df12fbc01d0e8165610efa04794f414c1417f1d4059435c5385bfe2de83ce0e238d6fd2dbd3c0487c69843298577bfa480fe2a16ab2a0e4bc712cd8b5a14871cda61c993b6835303d9043d7689a
   2014 
   2015 fulfillment payload for node 1:
   2016 ba9463d72ce55bc83c9ccd70861ffdf8c5b1a9291be4d9257016ae3c6d3becc6765fe07333369e629ef7475898e535dda560281a4dcf2654362b0421e95aff38e8aeb1298787331bec87815490e534af8de7c85bdf537418fdb81464168cb7c2123ee4186fa6da7cb60583c8ff2ed07982b0ce3e690cb9ba99f186d416bb8adb7f020ea2ef2894bbc732fcd78d1a2c3f7983b85f8b039ae370e1dd062e6d2e6439c003a4d65a55102db383ef1ceb291cd057dfba81396959613104b894e5f4202218b86b3ac9e9cb7b4a10a06669d788fd7d8a9dd832d8996592d17593978d1a500fbe1943c57f004e41eeb3da28e114997aa3b6f183fa2af59b8ad67c1c2753beb5c5fe6f4733980225e8d40d0cfd95
   2017 attribution data for node 1:
   2018 74a4ea61339463642a2182758871b2ea724f31f531aa98d80f1c3043febca41d5ee52e8b1e127e61719a0d078db8909748d57839e58424b91f063c4fbc8a221bef261140e66a9b596ca6d420a973ad54651be4bf8728ba81adcb9a1d3ce3820cea24f2c6bfdde427edb7706dfd1e8e50c0ab544022275fd457fbd57555cfc85bbfbed6eb0f7a8ea04ebc1b40fc8d3f67402a01d169ed1448ed2e708e16a0fe2c1ab5055be446594036b5ecae456486addbebbd09ca3423d4c15e2afce6b40b545bfbf5859b6bf913e80bcec00e88cba671fee9770fdace16301fbb23b0eca85549ae0be1a96bda5167b6e5fb837edecd981b61e06858badb34ead1e93746ab5afd2bc10e95bffc4dc965de242db63eb8ec221cf57e2c77241fcfca70818a85a447b6fbcaaf4b2fc2135565cbfc03804aa11ad0ab0582e5d86590df2ecfd561dc6e1cdb08d3e10901312326a45fb0498a177319389809c6ba07a76cfad621e07b9af097730e94df92fbd311b2cb5da32c80ab5f14971b6d40f8e2ab202ac98bd8439790764a40bf309ea2205c1632610956495720030a25dc7118e0c868fdfa78c3e9ecce58215579a0581b3bafdb7dbbe53be9e904567fdc0ce1236aab5d22f1ebc18997e3ea83d362d891e04c5785fd5238326f767bce499209f8db211a50e1402160486e98e7235cf397dbb9ae19fd9b79ef589c821c6f99f28be33452405a003b33f4540fe0a41dfcc286f4d7cc10b70552ba7850869abadcd4bb7f256823face853633d6e2a999ac9fcd259c71d08e266db5d744e1909a62c0db673745ad9585949d108ab96640d2bc27fb4acac7fa8b170a30055a5ede90e004df9a44bdc29aeb4a6bec1e85dde1de6aaf01c6a5d12405d0bec22f49026cb23264f8c04b8401d3c2ab6f2e109948b6193b3bec27adfe19fb8afb8a92364d6fc5b219e8737d583e7ff3a4bcb75d53edda3bf3f52896ac36d8a877ad9f296ea6c045603fc62ac4ae41272bde85ef7c3b3fd3538aacfd5b025fefbe277c2906821ecb20e6f75ea479fa3280f9100fb0089203455c56b6bc775e5c2f0f58c63edd63fa3eec0b40da4b276d0d41da2ec0ead865a98d12bc694e23d8eaadd2b4d0ee88e9570c88fb878930f492e036d27998d593e47763927ff7eb80b188864a3846dd2238f7f95f4090ed399ae95deaeb37abca1cf37c397cc12189affb42dca46b4ff6988eb8c060691d155302d448f50ff70a794d97c0408f8cee9385d6a71fa412e36edcb22dbf433db9db4779f27b682ee17fc05e70c8e794b9f7f6d1
   2019 
   2020 fulfillment payload for node 0:
   2021 8c0d9ee20671d1cdca98bb4c8dd5d490105b63021afcb90b22f33f1d9d6b7faafb86ec57ec4b56ad11e122bb0289403447a0b814ef8aefb90d2b0c3567501eb3570011ee96514db6050747a1d5cba50fe6e0c3e639d8208c549d61a502eab8772eceafeee940a586fc0ad92ce57773e307a5055604b9ea68c780617d6a797467d357d185fe9eb4279719d35faaab1105ab77299bd10f3504c439058720ed738a1c16756a44ba348bb193ec7d3dd9f11ac3d0cc1277ace098ed0ed8e25a01e83216a9c6a183a2659ddf2d971bc4a9b5ce776e1b07242a89a15026a3d208bbb8e3f91086f2785be68b5e4122f9d79583b883266ba6dfb4cf0c22737915dda898e1461651818c17f811f51f496f0842223c
   2022 attribution data for node 0:
   2023 84986c936d26bfd3bb2d34d3ec62cfdb63e0032fdb3d9d75f3e5d456f73dffa7e35aab1db4f1bd3b98ff585caf004f656c51037a3f4e810d275f3f6aea0c8e3a125ebee5f374b6440bcb9bb2955ebf706a8fd90a3bef40add4106d8c215290aafbc30881b17d68b6a7aac1b6ab52261df2fceef75d3a490862d4bab3aa510cfb8ca695b38c640b58bb8685db8bb57f93db49657ddda39d21d6074d9ecaa1ea0da6cc904e136dbb4c1ba9839a7fb8367c88662f7f573c82c2746d122cca96b2e7872a48e32c8adba45babdc57a9bca55720b1d2c922622fcf8f8a5ed7daae286484b701e69bd40554a4cc3418444ff7eb9982ecee020c8a92717f089ce1ab0ca00bb3a582253cd832a2f869703a2fadafd8261ebb93fde2a9f4f13dc8470436c3cd110bdcc7f5a1e9f9c743c8e55b50c45dac07e07a8e5c7416de895940fde032786594bbaa8a1147422bd5e926fea510408c249fb61164bf7bdbac53d9fb9704023314c332a865146893ad99743708c4a34a30a82fd8b756c561a6520d47b2cd487299a96322dadc463ef06127fc63902ff9cc4f265e2fbd9de3fa5e48b7b51aa0850580ef9f3b5ebb60c6c3216c5a75a93e82936113d9cad57ae4a94dd6481954a9bd1b5cff4ab29ca221fa2bf9b28a362c9661206f896fc7cec563fb80aa5eaccb26c09fa4ef7a981e63028a9c4dac12f82ccb5bea090d56bbb1a4c431e315d9a169299224a8dbd099fb67ea61dfc604edf8a18ee742550b636836bb552dabb28820221bf8546331f32b0c143c1c89310c4fa2e1e0e895ce1a1eb0f43278fdb528131a3e32bfffe0c6de9006418f5309cba773ca38b6ad8507cc59445ccc0257506ebc16a4c01d4cd97e03fcf7a2049fea0db28447858f73b8e9fe98b391b136c9dc510288630a1f0af93b26a8891b857bfe4b818af99a1e011e6dbaa53982d29cf74ae7dffef45545279f19931708ed3eede5e82280eab908e8eb80abff3f1f023ab66869297b40da8496861dc455ac3abe1efa8a6f9e2c4eda48025d43a486a3f26f269743eaa30d6f0e1f48db6287751358a41f5b07aee0f098862e3493731fe2697acce734f004907c6f11eef189424fee52cd30ad708707eaf2e441f52bcf3d0c5440c1742458653c0c8a27b5ade784d9e09c8b47f1671901a29360e7e5e94946b9c75752a1a8d599d2a3e14ac81b84d42115cd688c8383a64fc6e7e1dc5568bb4837358ebe63207a4067af66b2027ad2ce8fb7ae3a452d40723a51fdf9f9c9913e8029a222cf81d12ad41e58860d75deb6de30ad
   2024 
   2025 # References
   2026 
   2027 [sphinx]: http://www.cypherpunks.ca/~iang/pubs/Sphinx_Oakland09.pdf
   2028 [RFC2104]: https://tools.ietf.org/html/rfc2104
   2029 [fips198]: http://csrc.nist.gov/publications/fips/fips198-1/FIPS-198-1_final.pdf
   2030 [sec2]: http://www.secg.org/sec2-v2.pdf
   2031 [rfc8439]: https://tools.ietf.org/html/rfc8439
   2032 
   2033 # Authors
   2034 
   2035 [ FIXME: ]
   2036 
   2037 ![Creative Commons License](https://i.creativecommons.org/l/by/4.0/88x31.png "License CC-BY")
   2038 <br>
   2039 This work is licensed under a [Creative Commons Attribution 4.0 International License](http://creativecommons.org/licenses/by/4.0/).