|  | 
|  | 1 | +``` | 
|  | 2 | +bLIP: 14 | 
|  | 3 | +Title: Sender authentication | 
|  | 4 | +Status: Draft | 
|  | 5 | +Author: Joost Jager <[email protected]> | 
|  | 6 | +Created: 2022-02-04 | 
|  | 7 | +License: CC0 | 
|  | 8 | +``` | 
|  | 9 | + | 
|  | 10 | +## Abstract | 
|  | 11 | + | 
|  | 12 | +By default, the lightning protocol protects the sender identity by means of | 
|  | 13 | +ephemeral keys and onion routing. There are however use cases that ask for | 
|  | 14 | +inclusion of the sender identity with a payment. | 
|  | 15 | + | 
|  | 16 | +This bLIP serves to document a way to authenticate the sender of a payment via a | 
|  | 17 | +custom TLV record. | 
|  | 18 | + | 
|  | 19 | +## Copyright | 
|  | 20 | + | 
|  | 21 | +This bLIP is licensed under the CC0 license. | 
|  | 22 | + | 
|  | 23 | +## Specification | 
|  | 24 | + | 
|  | 25 | +Sender: | 
|  | 26 | + | 
|  | 27 | +* MUST include a TLV record keyed by type `83231` with the following value: | 
|  | 28 | + | 
|  | 29 | +  * [`33*byte`:`sender_pubkey`] | 
|  | 30 | +  * [`8*byte`:`timestamp`] | 
|  | 31 | +  * [`var length`:`signature`] | 
|  | 32 | + | 
|  | 33 | +  `sender_pubkey` is the public key of the sender. Note that `sender_pubkey` doesn't | 
|  | 34 | +  need to be the sender's node public key. It can also be a more general | 
|  | 35 | +  identity. | 
|  | 36 | + | 
|  | 37 | +  `timestamp` is the payment initiation time in nano seconds since unix epoch | 
|  | 38 | +  (big endian encoded). | 
|  | 39 | + | 
|  | 40 | +  `signature` is a DER-encoded ECDSA signature calculated using `sender_pubkey` | 
|  | 41 | +  over a message that is a concatenation of the following fields: | 
|  | 42 | + | 
|  | 43 | +  * `timestamp` (8 bytes) | 
|  | 44 | +  * `recipient_pubkey` (33 bytes) | 
|  | 45 | +  * `payment_hash` (32 bytes) | 
|  | 46 | +  * `payment_secret` (32 bytes) | 
|  | 47 | +  * `amount_msat` (8 bytes, big endian) | 
|  | 48 | + | 
|  | 49 | +  For multi-part payments, `amount_msat` is the total amount of the set. The | 
|  | 50 | +  value of the TLV record MUST be identical for all parts. | 
|  | 51 | + | 
|  | 52 | +Receiver: | 
|  | 53 | + | 
|  | 54 | +* MUST verify that `signature` is valid and produced using `sender_pubkey`. | 
|  | 55 | + | 
|  | 56 | +* SHOULD verify that `timestamp` is not unreasonably long ago. Suggested cut-off is | 
|  | 57 | +  one hour. | 
|  | 58 | + | 
|  | 59 | +* If verification fails, SHOULD error with | 
|  | 60 | +  `PERM|15 incorrect_or_unknown_payment_details`. | 
|  | 61 | + | 
|  | 62 | +## Motivation | 
|  | 63 | + | 
|  | 64 | +Potential use cases: | 
|  | 65 | + | 
|  | 66 | +* A donation payment where the donor wants to make themselves known. | 
|  | 67 | + | 
|  | 68 | +* Regulated custodial wallets that can offer higher receive limits for payments | 
|  | 69 | +  originating from specific sources. | 
|  | 70 | + | 
|  | 71 | +* A web shop recommending other items to buy based on payment history. | 
|  | 72 | + | 
|  | 73 | +* Lightning deposits to an exchange where the exchange automatically credits the | 
|  | 74 | +  correct account based on the sender identity. | 
|  | 75 | + | 
|  | 76 | +There are many ways to authenticate the sender of a payment in Lightning. This | 
|  | 77 | +documentation is an attempt to prevent the emergence of too many variants that | 
|  | 78 | +all do more or less the same thing. | 
|  | 79 | + | 
|  | 80 | +## Rationale | 
|  | 81 | + | 
|  | 82 | +* The TLV record key is an odd number, meaning that the record is ignored by | 
|  | 83 | +  receivers that do not support sender authentication. No feature bit is needed. | 
|  | 84 | + | 
|  | 85 | +* It is possible to recover the public key from an ECDSA signature, so strictly | 
|  | 86 | +  speaking `sender_pubkey` is redundant. Note that with Schnorr signatures, recovery is no | 
|  | 87 | +  longer possible. | 
|  | 88 | + | 
|  | 89 | +* It is undesired that a signature can be reused in any way. Therefore all of | 
|  | 90 | +  the identifying payment properties are covered by the signature. | 
|  | 91 | + | 
|  | 92 | +## Test vectors | 
|  | 93 | + | 
|  | 94 | +TBD | 
0 commit comments