@@ -264,39 +264,78 @@ It is formatted according to the Type-Length-Value format defined in [BOLT #1](0
264
264
2 . data:
265
265
* [ ` 32*byte ` :` payment_secret ` ]
266
266
* [ ` tu64 ` :` total_msat ` ]
267
+ 1 . type: 10 (` encrypted_recipient_data ` )
268
+ 2 . data:
269
+ * [ ` ...*byte ` :` encrypted_data ` ]
270
+ 1 . type: 12 (` blinding_point ` )
271
+ 2 . data:
272
+ * [ ` point ` :` blinding ` ]
267
273
1 . type: 16 (` payment_metadata ` )
268
274
2 . data:
269
275
* [ ` ...*byte ` :` payment_metadata ` ]
270
276
271
277
### Requirements
272
278
273
279
The writer:
280
+
274
281
- Unless ` node_announcement ` , ` init ` message or the [ BOLT #11 ] ( 11-payment-encoding.md#tagged-fields ) offers feature ` var_onion_optin ` :
275
282
- MUST use the legacy payload format instead.
276
- - For every node:
283
+ - For every node inside a blinded route:
284
+ - MUST include the ` encrypted_data ` provided by the recipient
285
+ - For the first node in the blinded route:
286
+ - MUST include the ` blinding_point ` provided by the recipient
287
+ - If it is the final node:
288
+ - MUST include ` amt_to_forward ` and ` outgoing_cltv_value ` .
289
+ - Otherwise:
290
+ - MUST NOT include ` amt_to_forward ` and ` outgoing_cltv_value ` .
291
+ - For every node outside of a blinded route:
277
292
- MUST include ` amt_to_forward ` and ` outgoing_cltv_value ` .
278
- - For every non-final node:
279
- - MUST include ` short_channel_id `
280
- - MUST NOT include ` payment_data `
281
- - For the final node:
282
- - MUST NOT include ` short_channel_id `
283
- - if the recipient provided ` payment_secret ` :
284
- - MUST include ` payment_data `
285
- - MUST set ` payment_secret ` to the one provided
286
- - MUST set ` total_msat ` to the total amount it will send
287
- - if the recipient provided ` payment_metadata ` :
288
- - MUST include ` payment_metadata ` with every HTLC
289
- - MUST not apply any limits to the size of payment_metadata except the limits implied by the fixed onion size
293
+ - For every non-final node:
294
+ - MUST include ` short_channel_id `
295
+ - MUST NOT include ` payment_data `
296
+ - For the final node:
297
+ - MUST NOT include ` short_channel_id `
298
+ - if the recipient provided ` payment_secret ` :
299
+ - MUST include ` payment_data `
300
+ - MUST set ` payment_secret ` to the one provided
301
+ - MUST set ` total_msat ` to the total amount it will send
302
+ - if the recipient provided ` payment_metadata ` :
303
+ - MUST include ` payment_metadata ` with every HTLC
304
+ - MUST not apply any limits to the size of ` payment_metadata ` except the limits implied by the fixed onion size
290
305
291
306
The reader:
292
- - MUST return an error if ` amt_to_forward ` or ` outgoing_cltv_value ` are not present.
293
- - if it is the final node:
294
- - MUST treat ` total_msat ` as if it were equal to ` amt_to_forward ` if it
295
- is not present.
307
+
308
+ - If ` blinding_point ` is set (either in the payload or the outer message):
309
+ - MUST return an error if it is set in both the payload and the outer message
310
+ - MUST return an error if ` encrypted_recipient_data ` is not present.
311
+ - MUST return an error if the expiry is greater than ` encrypted_recipient_data.payment_constraints.max_cltv_expiry ` .
312
+ - MUST return an error if the amount is below ` encrypted_recipient_data.payment_constraints.htlc_minimum_msat ` .
313
+ - MUST return an error if the payment uses a feature not included in ` encrypted_recipient_data.payment_constraints.allowed_features ` .
314
+ - If it not the final node:
315
+ - MUST return an error if ` encrypted_recipient_data ` does not contain ` short_channel_id ` or ` next_node_id ` .
316
+ - MUST return an error if ` encrypted_recipient_data ` does not contain ` payment_relay ` .
317
+ - If ` encrypted_recipient_data.payment_relay ` does not satisfy its current settings:
318
+ - MAY return an error.
319
+ - Otherwise:
320
+ - MUST use values from ` encrypted_recipient_data.payment_relay ` to relay the payment.
321
+ - If it is the final node:
322
+ - MUST return an error if the ` path_id ` in ` encrypted_recipient_data ` does not match the one it created.
323
+ - MUST return an error if ` amt_to_forward ` or ` outgoing_cltv_value ` are not present.
324
+ - MUST return an error if ` amt_to_forward ` is below what it expects for the payment.
325
+ - SHOULD add a random delay before returning errors.
326
+ - Otherwise (it is not part of a blinded route):
327
+ - MUST return an error if ` amt_to_forward ` or ` outgoing_cltv_value ` are not present.
328
+ - MUST return an error if ` encrypted_recipient_data ` is present.
329
+ - If it is the final node:
330
+ - MUST treat ` total_msat ` as if it were equal to ` amt_to_forward ` if it is not present.
296
331
297
332
The requirements for the contents of these fields are specified [ above] ( #legacy-hop_data-payload-format )
298
333
and [ below] ( #basic-multi-part-payments ) .
299
334
335
+ The requirements for the fields related to route blinding
336
+ (` encrypted_recipient_data ` and ` blinding_point ` ) are also specified
337
+ [ below] ( #route-blinding ) .
338
+
300
339
### Basic Multi-Part Payments
301
340
302
341
An HTLC may be part of a larger "multi-part" payment: such
@@ -413,6 +452,16 @@ may contain the following TLV fields:
413
452
1 . type: 8 (` next_blinding_override ` )
414
453
2 . data:
415
454
* [ ` point ` :` blinding ` ]
455
+ 1 . type: 10 (` payment_relay ` )
456
+ 2 . data:
457
+ * [ ` u32 ` :` fee_base_msat ` ]
458
+ * [ ` u32 ` :` fee_proportional_millionths ` ]
459
+ * [ ` u16 ` :` cltv_expiry_delta ` ]
460
+ 1 . type: 12 (` payment_constraints ` )
461
+ 2 . data:
462
+ * [ ` u32 ` :` max_cltv_expiry ` ]
463
+ * [ ` u64 ` :` htlc_minimum_msat ` ]
464
+ * [ ` ...*byte ` :` allowed_features ` ]
416
465
417
466
#### Requirements
418
467
@@ -436,6 +485,14 @@ A recipient N(r) creating a blinded route `N(0) -> N(1) -> ... -> N(r)` to itsel
436
485
- MUST communicate the blinded node IDs ` B(i) ` and ` encrypted_data(i) ` to the sender
437
486
- MUST communicate the real node ID of the introduction point ` N(0) ` to the sender
438
487
- MUST communicate the first blinding ephemeral key ` E(0) ` to the sender
488
+ - If the blinded route will be used for payments:
489
+ - MUST set ` short_channel_id ` and ` payment_relay ` in the ` encrypted_data ` for intermediate nodes
490
+ - MUST NOT set ` path_id ` in the ` encrypted_data ` for intermediate nodes
491
+ - MUST compute the total fees and cltv delta of the route and communicate them to the sender
492
+ - If the blinded route will be used for messages:
493
+ - MUST set ` next_node_id ` in the ` encrypted_data ` for intermediate nodes
494
+ - MUST NOT set ` payment_relay ` or ` payment_constraints ` in the ` encrypted_data ` payloads
495
+ - MUST NOT set ` path_id ` in the ` encrypted_data ` for intermediate nodes
439
496
440
497
The sender:
441
498
@@ -519,11 +576,28 @@ context information in the `path_id` field (e.g. the `payment_preimage`) and
519
576
verify that when receiving the onion. Note that it's important to use private
520
577
information in that case, that senders cannot have access to.
521
578
579
+ Whenever the final recipient receives an invalid message from a blinded route,
580
+ it should add a random delay before returning an error (if it returns one).
581
+ Invalid messages are likely to be probing attempts and message timing may help
582
+ the attacker infer its distance to the final recipient.
583
+
522
584
The ` padding ` field can be used to ensure that all ` encrypted_data ` have the
523
585
same length. It's particularly useful when adding dummy hops at the end of a
524
586
blinded route, to prevent the sender from figuring out which node is the final
525
587
recipient.
526
588
589
+ When route blinding is used for payments, the recipient specifies the fees and
590
+ expiry that blinded nodes should apply to the payment instead of letting the
591
+ sender configure them. The recipient also adds additional constraints to the
592
+ payments that can go through that route to protect against probing attacks that
593
+ would let malicious nodes unblind the identity of the blinded nodes.
594
+
595
+ When route blinding is used for payments, nodes inside the blinded route must
596
+ not return standard onion errors, because they would provide information to the
597
+ sender that could help them unblind the identity of the blinded nodes. Also,
598
+ instead of forwarding errors, nodes should replace them with garbage, in case
599
+ a downstream node was buggy and returned a valid onion error.
600
+
527
601
# Accepting and Forwarding a Payment
528
602
529
603
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.
@@ -971,11 +1045,15 @@ channel.
971
1045
### Requirements
972
1046
973
1047
The _ erring node_ :
1048
+
974
1049
- SHOULD set ` pad ` such that the ` failure_len ` plus ` pad_len ` is equal to 256.
975
- - Note: this value is 118 bytes longer than the longest currently-defined
976
- message.
1050
+ - Note: this value is 118 bytes longer than the longest currently-defined message.
1051
+ - If it is part of a blinded route:
1052
+ - MUST return random bytes instead of a valid onion error.
1053
+ - SHOULD replace downstream errors by random bytes before forwarding them upstream.
977
1054
978
1055
The _ origin node_ :
1056
+
979
1057
- once the return message has been decrypted:
980
1058
- SHOULD store a copy of the message.
981
1059
- SHOULD continue decrypting, until the loop has been repeated 20 times.
0 commit comments