Repository navigation
BOLT 12: payer proofs - #1295
rustyrussell wants to merge 11 commits into
Conversation
Signed-off-by: Rusty Russell <[email protected]>
jkczyz
left a comment
There was a problem hiding this comment.
Some minor comments from a first pass. Should have more feedback once we attempt to implement this.
Implements the payer proof extension to BOLT 12 as specified in lightning/bolts#1295. This allows proving that a BOLT 12 invoice was paid by demonstrating possession of the payment preimage, a valid invoice signature, and a payer signature. Key additions: - Extend merkle.rs with selective disclosure primitives for creating and reconstructing merkle trees with partial TLV disclosure - Add payer_proof.rs with PayerProof, PayerProofBuilder, and UnsignedPayerProof types for building and verifying payer proofs - Support bech32 encoding with "lnp" prefix 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
vincenzopalazzo
left a comment
There was a problem hiding this comment.
Thanks for this spec! I am finishing to implement it in ldk and have some feedback from implementation experience:
- The nonce hash notation needs clarification (see inline comment)
- Test vectors would be extremely valuable for cross-implementation compatibility. Wondering if you already had some draft implementation where we can compare the tests vectors?
Happy to provide my implementation's test vectors once the ambiguities are resolved.
Implements the payer proof extension to BOLT 12 as specified in lightning/bolts#1295. This allows proving that a BOLT 12 invoice was paid by demonstrating possession of the payment preimage, a valid invoice signature, and a payer signature. Key additions: - Extend merkle.rs with selective disclosure primitives for creating and reconstructing merkle trees with partial TLV disclosure - Add payer_proof.rs with PayerProof, PayerProofBuilder, and UnsignedPayerProof types for building and verifying payer proofs - Support bech32 encoding with "lnp" prefix
Implements the payer proof extension to BOLT 12 as specified in lightning/bolts#1295. This allows proving that a BOLT 12 invoice was paid by demonstrating possession of the payment preimage, a valid invoice signature, and a payer signature. Key additions: - Extend merkle.rs with selective disclosure primitives for creating and reconstructing merkle trees with partial TLV disclosure - Add payer_proof.rs with PayerProof, PayerProofBuilder, and UnsignedPayerProof types for building and verifying payer proofs - Support bech32 encoding with "lnp" prefix
Implements the payer proof extension to BOLT 12 as specified in lightning/bolts#1295. This allows proving that a BOLT 12 invoice was paid by demonstrating possession of the payment preimage, a valid invoice signature, and a payer signature. Key additions: - Extend merkle.rs with selective disclosure primitives for creating and reconstructing merkle trees with partial TLV disclosure - Add payer_proof.rs with PayerProof, PayerProofBuilder, and UnsignedPayerProof types for building and verifying payer proofs - Support bech32 encoding with "lnp" prefix
Implements the payer proof extension to BOLT 12 as specified in lightning/bolts#1295. This allows proving that a BOLT 12 invoice was paid by demonstrating possession of the payment preimage, a valid invoice signature, and a payer signature. Key additions: - Extend merkle.rs with selective disclosure primitives for creating and reconstructing merkle trees with partial TLV disclosure - Add payer_proof.rs with PayerProof, PayerProofBuilder, and UnsignedPayerProof types for building and verifying payer proofs - Support bech32 encoding with "lnp" prefix
Implements the payer proof extension to BOLT 12 as specified in lightning/bolts#1295. This allows proving that a BOLT 12 invoice was paid by demonstrating possession of the payment preimage, a valid invoice signature, and a payer signature. Key additions: - Extend merkle.rs with selective disclosure primitives for creating and reconstructing merkle trees with partial TLV disclosure - Add payer_proof.rs with PayerProof, PayerProofBuilder, and UnsignedPayerProof types for building and verifying payer proofs - Support bech32 encoding with "lnp" prefix
Add a Rust CLI tool that generates and verifies test vectors for BOLT 12 payer proofs as specified in lightning/bolts#1295. The tool uses the rust-lightning implementation from lightningdevkit/rust-lightning#4297. Features: - Generate deterministic test vectors with configurable seed - Verify test vectors from JSON files - Support for basic proofs, proofs with notes, and invalid test cases - Uses refund flow for explicit payer key control Co-Authored-By: Claude Opus 4.5 <[email protected]>
Implements payer proofs for BOLT 12 invoices as specified in lightning/bolts#1295. A PayerProof cryptographically proves that a BOLT 12 invoice was paid by demonstrating possession of the payment preimage, a valid invoice signature over a merkle root (via selective disclosure), and a payer signature proving who authorized the payment. Key components: - `PayerProofBuilder`: constructs proofs with selective disclosure, supporting both direct signing and derived key signing from `ExpandedKey` + `Nonce` - `PayerProof`: verifiable proof with bech32 encoding (lnp HRP) - Selective disclosure via merkle tree: omitted TLV fields are represented by minimized markers and missing hashes, allowing verification of the invoice signature without revealing all fields - `compute_selective_disclosure` / `reconstruct_merkle_root`: build and verify merkle proofs using n-node in-place tree traversal
Implements payer proofs for BOLT 12 invoices as specified in lightning/bolts#1295. A payer proof cryptographically demonstrates that a BOLT 12 invoice was paid using selective disclosure of invoice fields, the payment preimage, and signatures from both the invoice issuer and the payer.
Implements payer proofs for BOLT 12 invoices as specified in lightning/bolts#1295. A payer proof cryptographically demonstrates that a BOLT 12 invoice was paid using selective disclosure of invoice fields, the payment preimage, and signatures from both the invoice issuer and the payer.
Implement payer proofs for BOLT 12 invoices as specified in lightning/bolts#1295. A payer proof cryptographically demonstrates that a BOLT 12 invoice was paid using selective disclosure of invoice fields, the payment preimage, and signatures from both the invoice issuer and the payer. The selective disclosure mechanism uses a merkle tree over the invoice's TLV fields, allowing the payer to reveal only chosen fields while proving the full invoice was signed by the issuer. Privacy-preserving omitted markers hide the actual TLV type numbers of undisclosed fields. PayerProofBuilder provides two signing modes: an explicit signing function for callers with direct key access, and automatic key re-derivation from ExpandedKey + Nonce + PaymentId for the common case where invoice requests used deriving_signing_pubkey. Co-Authored-By: Claude Opus 4.6 <[email protected]>
Implement payer proofs for BOLT 12 invoices as specified in lightning/bolts#1295. A payer proof cryptographically demonstrates that a BOLT 12 invoice was paid using selective disclosure of invoice fields, the payment preimage, and signatures from both the invoice issuer and the payer. The selective disclosure mechanism uses a merkle tree over the invoice's TLV fields, allowing the payer to reveal only chosen fields while proving the full invoice was signed by the issuer. Privacy-preserving omitted markers hide the actual TLV type numbers of undisclosed fields. PayerProofBuilder provides two signing modes: an explicit signing function for callers with direct key access, and automatic key re-derivation from ExpandedKey + Nonce + PaymentId for the common case where invoice requests used deriving_signing_pubkey. Co-Authored-By: Claude Opus 4.6 <[email protected]>
Implement payer proofs for BOLT 12 invoices as specified in lightning/bolts#1295. A payer proof cryptographically demonstrates that a BOLT 12 invoice was paid using selective disclosure of invoice fields, the payment preimage, and signatures from both the invoice issuer and the payer. The selective disclosure mechanism uses a merkle tree over the invoice's TLV fields, allowing the payer to reveal only chosen fields while proving the full invoice was signed by the issuer. Privacy-preserving omitted markers hide the actual TLV type numbers of undisclosed fields. PayerProofBuilder provides two signing modes: an explicit signing function for callers with direct key access, and automatic key re-derivation from ExpandedKey + Nonce + PaymentId for the common case where invoice requests used deriving_signing_pubkey. Co-Authored-By: Claude Opus 4.6 <[email protected]>
|
I created a tool for the test vectors https://github.com/vincenzopalazzo/payer-proof-test-vectors, and this is the most recent one https://github.com/vincenzopalazzo/payer-proof-test-vectors/blob/main/test_vectors.json |
Implement payer proofs for BOLT 12 invoices as specified in lightning/bolts#1295. A payer proof cryptographically demonstrates that a BOLT 12 invoice was paid using selective disclosure of invoice fields, the payment preimage, and signatures from both the invoice issuer and the payer. The selective disclosure mechanism uses a merkle tree over the invoice's TLV fields, allowing the payer to reveal only chosen fields while proving the full invoice was signed by the issuer. Privacy-preserving omitted markers hide the actual TLV type numbers of undisclosed fields. PayerProofBuilder provides two signing modes: an explicit signing function for callers with direct key access, and automatic key re-derivation from ExpandedKey + Nonce + PaymentId for the common case where invoice requests used deriving_signing_pubkey. Co-Authored-By: Claude Opus 4.6 <[email protected]>
Implement payer proofs for BOLT 12 invoices as specified in lightning/bolts#1295. A payer proof cryptographically demonstrates that a BOLT 12 invoice was paid using selective disclosure of invoice fields, the payment preimage, and signatures from both the invoice issuer and the payer. The selective disclosure mechanism uses a merkle tree over the invoice's TLV fields, allowing the payer to reveal only chosen fields while proving the full invoice was signed by the issuer. Privacy-preserving omitted markers hide the actual TLV type numbers of undisclosed fields. PayerProofBuilder provides two signing modes: an explicit signing function for callers with direct key access, and automatic key re-derivation from ExpandedKey + Nonce + PaymentId for the common case where invoice requests used deriving_signing_pubkey. Co-Authored-By: Claude Opus 4.6 <[email protected]>
Implement payer proofs for BOLT 12 invoices as specified in lightning/bolts#1295. A payer proof cryptographically demonstrates that a BOLT 12 invoice was paid using selective disclosure of invoice fields, the payment preimage, and signatures from both the invoice issuer and the payer. The selective disclosure mechanism uses a merkle tree over the invoice's TLV fields, allowing the payer to reveal only chosen fields while proving the full invoice was signed by the issuer. Privacy-preserving omitted markers hide the actual TLV type numbers of undisclosed fields. PayerProofBuilder provides two signing modes: an explicit signing function for callers with direct key access, and automatic key re-derivation from ExpandedKey + Nonce + PaymentId for the common case where invoice requests used deriving_signing_pubkey. Co-Authored-By: Claude Opus 4.6 <[email protected]>
Add the `payer_proof` module: `PayerProof`/`UnsignedPayerProof`, the `PayerProofBuilder` (with selective disclosure and a derived-key path), bech32 `lnp` encoding, and parse-time verification, implementing the payer proof extension to BOLT 12 (lightning/bolts#1295). Also exposes the offer/invoice TLV-type constants and an invoice-bytes accessor used to build proofs, and a `Sha256` `Writeable`/`Readable` impl for the proof hashes. Co-Authored-By: Rusty Russell <[email protected]> Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> Co-Authored-By: OpenAI Codex <[email protected]>
Add the `payer_proof` module: `PayerProof`/`UnsignedPayerProof`, the `PayerProofBuilder` (with selective disclosure and a derived-key path), bech32 `lnp` encoding, and parse-time verification, implementing the payer proof extension to BOLT 12 (lightning/bolts#1295). Also exposes the offer/invoice TLV-type constants and an invoice-bytes accessor used to build proofs, and a `Sha256` `Writeable`/`Readable` impl for the proof hashes. Co-Authored-By: Rusty Russell <[email protected]> Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> Co-Authored-By: OpenAI Codex <[email protected]>
Add the `payer_proof` module: `PayerProof`/`UnsignedPayerProof`, the `PayerProofBuilder` (with selective disclosure and a derived-key path), bech32 `lnp` encoding, and parse-time verification, implementing the payer proof extension to BOLT 12 (lightning/bolts#1295). Also exposes the offer/invoice TLV-type constants and an invoice-bytes accessor used to build proofs, and a `Sha256` `Writeable`/`Readable` impl for the proof hashes. Co-Authored-By: Rusty Russell <[email protected]> Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> Co-Authored-By: OpenAI Codex <[email protected]>
|
I addressed the remaining reader-side It adds the reader-side carve-out for the |
Add the `payer_proof` module: `PayerProof`/`UnsignedPayerProof`, the `PayerProofBuilder` (with selective disclosure and a derived-key path), bech32 `lnp` encoding, and parse-time verification, implementing the payer proof extension to BOLT 12 (lightning/bolts#1295). Also exposes the offer/invoice TLV-type constants and an invoice-bytes accessor used to build proofs, and a `Sha256` `Writeable`/`Readable` impl for the proof hashes. Co-Authored-By: Rusty Russell <[email protected]> Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> Co-Authored-By: OpenAI Codex <[email protected]>
Add the `payer_proof` module: `PayerProof`/`UnsignedPayerProof`, the `PayerProofBuilder` (with selective disclosure and a derived-key path), bech32 `lnp` encoding, and parse-time verification, implementing the payer proof extension to BOLT 12 (lightning/bolts#1295). Also exposes the offer/invoice TLV-type constants and an invoice-bytes accessor used to build proofs, and a `Sha256` `Writeable`/`Readable` impl for the proof hashes. Co-Authored-By: Rusty Russell <[email protected]> Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> Co-Authored-By: OpenAI Codex <[email protected]>
Add the `payer_proof` module: `PayerProof`/`UnsignedPayerProof`, the `PayerProofBuilder` (with selective disclosure and a derived-key path), bech32 `lnp` encoding, and parse-time verification, implementing the payer proof extension to BOLT 12 (lightning/bolts#1295). Also exposes the offer/invoice TLV-type constants and an invoice-bytes accessor used to build proofs, and a `Sha256` `Writeable`/`Readable` impl for the proof hashes. Co-Authored-By: Rusty Russell <[email protected]> Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> Co-Authored-By: OpenAI Codex <[email protected]>
|
I opened a replacement PR to take this over from my fork, per Rusty’s handoff: I’ll continue review/fixes there. Maintainers can close this PR when ready. |
Add the `payer_proof` module: `PayerProof`/`UnsignedPayerProof`, the `PayerProofBuilder` (with selective disclosure and a derived-key path), bech32 `lnp` encoding, and parse-time verification, implementing the payer proof extension to BOLT 12 (lightning/bolts#1295). Also exposes the offer/invoice TLV-type constants and an invoice-bytes accessor used to build proofs, and a `Sha256` `Writeable`/`Readable` impl for the proof hashes. Co-Authored-By: Rusty Russell <[email protected]> Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> Co-Authored-By: OpenAI Codex <[email protected]>
|
Closing in favor of #1346. Thanks Rusty! |
Add the `payer_proof` module: `PayerProof`/`UnsignedPayerProof`, the `PayerProofBuilder` (with selective disclosure and a derived-key path), bech32 `lnp` encoding, and parse-time verification, implementing the payer proof extension to BOLT 12 (lightning/bolts#1295). Also exposes the offer/invoice TLV-type constants and an invoice-bytes accessor used to build proofs, and a `Sha256` `Writeable`/`Readable` impl for the proof hashes. Co-Authored-By: Rusty Russell <[email protected]> Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> Co-Authored-By: OpenAI Codex <[email protected]> Backport of 5747866 Conflicts resolved in: * lightning/src/events/mod.rs * lightning/src/offers/payer_proof.rs
Add the `payer_proof` module: `PayerProof`/`UnsignedPayerProof`, the `PayerProofBuilder` (with selective disclosure and a derived-key path), bech32 `lnp` encoding, and parse-time verification, implementing the payer proof extension to BOLT 12 (lightning/bolts#1295). Also exposes the offer/invoice TLV-type constants and an invoice-bytes accessor used to build proofs, and a `Sha256` `Writeable`/`Readable` impl for the proof hashes. Co-Authored-By: Rusty Russell <[email protected]> Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> Co-Authored-By: OpenAI Codex <[email protected]> Backport of 5747866 Conflicts resolved in: * lightning/src/offers/payer_proof.rs
As specified in lightning/bolts#1295
…ec contradiction Add a failing C unit test that reproduces the BOLT 12 spec contradiction raised on lightning/bolts#1295. The writer rule in `12-offer-encoding.md` (lines 1041-1049, head db3eff3a54) mandates that after a `proof_omitted_tlvs` entry of `239` the next entry MUST be `1000000000`, because the writer skips past the signature/payer-proof TLV range (240..999999999). The reader rule (lines 1065-1067) only accepts an entry that is `prev + 1` or `<included TLV> + 1`, with no carve-out for the 239 -> 1000000000 jump. A reader applying the spec literally rejects a marker sequence the writer rule mandates. CLN's reader in common/bolt12_proof.c lines 339-388 is a literal transcription of the bogus reader rule (specifically the `omitted != prev_omitted + 1` branch at line 379). Fed the writer-rule-mandated sequence [1, 2, ..., 239, 1000000000] it returns an error on the 1000000000 entry. The new test in common/test/run-bolt12_proof_marker_jump.c builds the minimum tlv_payer_proof needed to reach the marker-validation loop and asserts check_payer_proof returns NULL. It is expected to fail on current master, the failure IS the reproduction. The fix belongs in the spec PR first (amend reader rule 1065) and only then mirrored into CLN. The same contradiction is reproduced on the Rust-Lightning side in lightningdevkit/rust-lightning#4297, test spec_writer_reader_rules_contradict_on_gap_jump in lightning/src/offers/merkle.rs (commit 0034c79ae). Changelog-None Link: lightning/bolts#1295 (comment) Link: lightningdevkit/rust-lightning#4297 Signed-off-by: Vincenzo Palazzo <[email protected]>
In `lightning/bolts#1295` (head db3eff3a54, 12-offer-encoding.md), the writer rule (lines 1041-1049) mandates that after a `proof_omitted_tlvs` entry of `239` the next entry is `1000000000` (jumping past the signature/payer-proof TLV range 240..999999999), but the reader rule (lines 1065-1067) only accepts `prev + 1` or `<included TLV> + 1`. A reader applying the spec literally rejects a marker sequence the writer rule mandates. The contradiction was raised on the spec PR: lightning/bolts#1295 (comment) CLN's reader at `common/bolt12_proof.c` line 379 was a literal transcription of the bogus reader rule, and CLN's writer at line 115 used `++last_type` which would have emitted `240` (invalid) after `239` if a real invoice ever reached the boundary. Fix this by collapsing both writer and reader onto a single helper `next_marker(prev)` that returns the smallest valid marker number strictly greater than `prev`. Both sides now reference the same symbol, so the writer/reader asymmetry that caused this bug is structurally impossible. The unit test `run-bolt12_proof_marker_jump` is rewritten as a real end-to-end test: it builds an invoice with the standard required fields plus 64 dummy unknown TLVs at odd extension-range types (1000000001, 1000000003, ..., 1000000127), makes a payer_proof including only the three required fields, and asserts that `check_payer_proof` returns NULL. The marker sequence produced ends with [..., 237, 238, 239, 1000000000], exercising the gap-jump end-to-end. The test also sanity-checks that 239 appears in the sequence and that 1000000000 follows it immediately, so the test cannot go green for the wrong reason. Existing `run-bolt12_proof` and `run-bolt12_proof_vectors` still pass with no changes to their behaviour. Parallel LDK reproduction: lightningdevkit/rust-lightning#4297 (test `spec_writer_reader_rules_contradict_on_gap_jump` in lightning/src/offers/merkle.rs, commit 0034c79ae). Changelog-Fixed: Reader of BOLT 12 payer_proof now accepts the writer-rule-mandated 239 -> 1000000000 marker jump. Link: lightning/bolts#1295 (comment) Link: lightningdevkit/rust-lightning#4297 Signed-off-by: Vincenzo Palazzo <[email protected]>
Add a new valid_vector `marker_jump_239_to_1000000000` to the JSON output produced by `run-bolt12_proof_vectors`. The vector encodes a real signed payer_proof whose `proof_omitted_tlvs` ends with [..., 237, 238, 239, 1000000000], i.e. it actually contains the spec gap-jump. The point is cross-implementation coverage: with this vector in the JSON corpus that CLN already emits, other BOLT 12 implementations (LDK PR ElementsProject#4297, future eclair, ...) can consume the same bech32 string through their own decoder and verifier. A reader that still has the old "must be prev + 1 or <included TLV> + 1" rule will reject the proof with an error naming `1000000000` after `239`; that surfaces the same latent bug across implementations rather than having each project rediscover it independently. The marker-jump invoice is built by `build_marker_jump_invoice`, which is a minimal invoice (same keys A-F as the existing vectors) plus 64 dummy unknown TLVs at odd extension-range types (1000000001, 1000000003, ..., 1000000127). The new `include_required_only` callback includes only the three required fields (invreq_payer_id, invoice_payment_hash, invoice_node_id), so the 64 trailing dummies and the optional invoice fields all get omitted. The writer-side `next_marker` walks the marker counter through 1..239 and then emits 1000000000 on the 64th dummy, which is the case under test. The existing 5 valid_vectors and 23 invalid_vectors are unchanged; the new entry is appended at the end of `valid_vectors[]` so the existing positions are preserved. Link: lightning/bolts#1295 (comment) Link: lightningdevkit/rust-lightning#4297 Signed-off-by: Vincenzo Palazzo <[email protected]>
As specified in lightning/bolts#1295
…ec contradiction Add a failing C unit test that reproduces the BOLT 12 spec contradiction raised on lightning/bolts#1295. The writer rule in `12-offer-encoding.md` (lines 1041-1049, head db3eff3a54) mandates that after a `proof_omitted_tlvs` entry of `239` the next entry MUST be `1000000000`, because the writer skips past the signature/payer-proof TLV range (240..999999999). The reader rule (lines 1065-1067) only accepts an entry that is `prev + 1` or `<included TLV> + 1`, with no carve-out for the 239 -> 1000000000 jump. A reader applying the spec literally rejects a marker sequence the writer rule mandates. CLN's reader in common/bolt12_proof.c lines 339-388 is a literal transcription of the bogus reader rule (specifically the `omitted != prev_omitted + 1` branch at line 379). Fed the writer-rule-mandated sequence [1, 2, ..., 239, 1000000000] it returns an error on the 1000000000 entry. The new test in common/test/run-bolt12_proof_marker_jump.c builds the minimum tlv_payer_proof needed to reach the marker-validation loop and asserts check_payer_proof returns NULL. It is expected to fail on current master, the failure IS the reproduction. The fix belongs in the spec PR first (amend reader rule 1065) and only then mirrored into CLN. The same contradiction is reproduced on the Rust-Lightning side in lightningdevkit/rust-lightning#4297, test spec_writer_reader_rules_contradict_on_gap_jump in lightning/src/offers/merkle.rs (commit 0034c79ae). Changelog-None Link: lightning/bolts#1295 (comment) Link: lightningdevkit/rust-lightning#4297 Signed-off-by: Vincenzo Palazzo <[email protected]>
In `lightning/bolts#1295` (head db3eff3a54, 12-offer-encoding.md), the writer rule (lines 1041-1049) mandates that after a `proof_omitted_tlvs` entry of `239` the next entry is `1000000000` (jumping past the signature/payer-proof TLV range 240..999999999), but the reader rule (lines 1065-1067) only accepts `prev + 1` or `<included TLV> + 1`. A reader applying the spec literally rejects a marker sequence the writer rule mandates. The contradiction was raised on the spec PR: lightning/bolts#1295 (comment) CLN's reader at `common/bolt12_proof.c` line 379 was a literal transcription of the bogus reader rule, and CLN's writer at line 115 used `++last_type` which would have emitted `240` (invalid) after `239` if a real invoice ever reached the boundary. Fix this by collapsing both writer and reader onto a single helper `next_marker(prev)` that returns the smallest valid marker number strictly greater than `prev`. Both sides now reference the same symbol, so the writer/reader asymmetry that caused this bug is structurally impossible. The unit test `run-bolt12_proof_marker_jump` is rewritten as a real end-to-end test: it builds an invoice with the standard required fields plus 64 dummy unknown TLVs at odd extension-range types (1000000001, 1000000003, ..., 1000000127), makes a payer_proof including only the three required fields, and asserts that `check_payer_proof` returns NULL. The marker sequence produced ends with [..., 237, 238, 239, 1000000000], exercising the gap-jump end-to-end. The test also sanity-checks that 239 appears in the sequence and that 1000000000 follows it immediately, so the test cannot go green for the wrong reason. Existing `run-bolt12_proof` and `run-bolt12_proof_vectors` still pass with no changes to their behaviour. Parallel LDK reproduction: lightningdevkit/rust-lightning#4297 (test `spec_writer_reader_rules_contradict_on_gap_jump` in lightning/src/offers/merkle.rs, commit 0034c79ae). Changelog-Fixed: Reader of BOLT 12 payer_proof now accepts the writer-rule-mandated 239 -> 1000000000 marker jump. Link: lightning/bolts#1295 (comment) Link: lightningdevkit/rust-lightning#4297 Signed-off-by: Vincenzo Palazzo <[email protected]>
Add a new valid_vector `marker_jump_239_to_1000000000` to the JSON output produced by `run-bolt12_proof_vectors`. The vector encodes a real signed payer_proof whose `proof_omitted_tlvs` ends with [..., 237, 238, 239, 1000000000], i.e. it actually contains the spec gap-jump. The point is cross-implementation coverage: with this vector in the JSON corpus that CLN already emits, other BOLT 12 implementations (LDK PR ElementsProject#4297, future eclair, ...) can consume the same bech32 string through their own decoder and verifier. A reader that still has the old "must be prev + 1 or <included TLV> + 1" rule will reject the proof with an error naming `1000000000` after `239`; that surfaces the same latent bug across implementations rather than having each project rediscover it independently. The marker-jump invoice is built by `build_marker_jump_invoice`, which is a minimal invoice (same keys A-F as the existing vectors) plus 64 dummy unknown TLVs at odd extension-range types (1000000001, 1000000003, ..., 1000000127). The new `include_required_only` callback includes only the three required fields (invreq_payer_id, invoice_payment_hash, invoice_node_id), so the 64 trailing dummies and the optional invoice fields all get omitted. The writer-side `next_marker` walks the marker counter through 1..239 and then emits 1000000000 on the 64th dummy, which is the case under test. The existing 5 valid_vectors and 23 invalid_vectors are unchanged; the new entry is appended at the end of `valid_vectors[]` so the existing positions are preserved. Link: lightning/bolts#1295 (comment) Link: lightningdevkit/rust-lightning#4297 Signed-off-by: Vincenzo Palazzo <[email protected]>
…ec contradiction Add a failing C unit test that reproduces the BOLT 12 spec contradiction raised on lightning/bolts#1295. The writer rule in `12-offer-encoding.md` (lines 1041-1049, head db3eff3a54) mandates that after a `proof_omitted_tlvs` entry of `239` the next entry MUST be `1000000000`, because the writer skips past the signature/payer-proof TLV range (240..999999999). The reader rule (lines 1065-1067) only accepts an entry that is `prev + 1` or `<included TLV> + 1`, with no carve-out for the 239 -> 1000000000 jump. A reader applying the spec literally rejects a marker sequence the writer rule mandates. CLN's reader in common/bolt12_proof.c lines 339-388 is a literal transcription of the bogus reader rule (specifically the `omitted != prev_omitted + 1` branch at line 379). Fed the writer-rule-mandated sequence [1, 2, ..., 239, 1000000000] it returns an error on the 1000000000 entry. The new test in common/test/run-bolt12_proof_marker_jump.c builds the minimum tlv_payer_proof needed to reach the marker-validation loop and asserts check_payer_proof returns NULL. It is expected to fail on current master, the failure IS the reproduction. The fix belongs in the spec PR first (amend reader rule 1065) and only then mirrored into CLN. The same contradiction is reproduced on the Rust-Lightning side in lightningdevkit/rust-lightning#4297, test spec_writer_reader_rules_contradict_on_gap_jump in lightning/src/offers/merkle.rs (commit 0034c79ae). Changelog-None Link: lightning/bolts#1295 (comment) Link: lightningdevkit/rust-lightning#4297 Signed-off-by: Vincenzo Palazzo <[email protected]>
In `lightning/bolts#1295` (head db3eff3a54, 12-offer-encoding.md), the writer rule (lines 1041-1049) mandates that after a `proof_omitted_tlvs` entry of `239` the next entry is `1000000000` (jumping past the signature/payer-proof TLV range 240..999999999), but the reader rule (lines 1065-1067) only accepts `prev + 1` or `<included TLV> + 1`. A reader applying the spec literally rejects a marker sequence the writer rule mandates. The contradiction was raised on the spec PR: lightning/bolts#1295 (comment) CLN's reader at `common/bolt12_proof.c` line 379 was a literal transcription of the bogus reader rule, and CLN's writer at line 115 used `++last_type` which would have emitted `240` (invalid) after `239` if a real invoice ever reached the boundary. Fix this by collapsing both writer and reader onto a single helper `next_marker(prev)` that returns the smallest valid marker number strictly greater than `prev`. Both sides now reference the same symbol, so the writer/reader asymmetry that caused this bug is structurally impossible. The unit test `run-bolt12_proof_marker_jump` is rewritten as a real end-to-end test: it builds an invoice with the standard required fields plus 64 dummy unknown TLVs at odd extension-range types (1000000001, 1000000003, ..., 1000000127), makes a payer_proof including only the three required fields, and asserts that `check_payer_proof` returns NULL. The marker sequence produced ends with [..., 237, 238, 239, 1000000000], exercising the gap-jump end-to-end. The test also sanity-checks that 239 appears in the sequence and that 1000000000 follows it immediately, so the test cannot go green for the wrong reason. Existing `run-bolt12_proof` and `run-bolt12_proof_vectors` still pass with no changes to their behaviour. Parallel LDK reproduction: lightningdevkit/rust-lightning#4297 (test `spec_writer_reader_rules_contradict_on_gap_jump` in lightning/src/offers/merkle.rs, commit 0034c79ae). Changelog-Fixed: Reader of BOLT 12 payer_proof now accepts the writer-rule-mandated 239 -> 1000000000 marker jump. Link: lightning/bolts#1295 (comment) Link: lightningdevkit/rust-lightning#4297 Signed-off-by: Vincenzo Palazzo <[email protected]>
Add a new valid_vector `marker_jump_239_to_1000000000` to the JSON output produced by `run-bolt12_proof_vectors`. The vector encodes a real signed payer_proof whose `proof_omitted_tlvs` ends with [..., 237, 238, 239, 1000000000], i.e. it actually contains the spec gap-jump. The point is cross-implementation coverage: with this vector in the JSON corpus that CLN already emits, other BOLT 12 implementations (LDK PR ElementsProject#4297, future eclair, ...) can consume the same bech32 string through their own decoder and verifier. A reader that still has the old "must be prev + 1 or <included TLV> + 1" rule will reject the proof with an error naming `1000000000` after `239`; that surfaces the same latent bug across implementations rather than having each project rediscover it independently. The marker-jump invoice is built by `build_marker_jump_invoice`, which is a minimal invoice (same keys A-F as the existing vectors) plus 64 dummy unknown TLVs at odd extension-range types (1000000001, 1000000003, ..., 1000000127). The new `include_required_only` callback includes only the three required fields (invreq_payer_id, invoice_payment_hash, invoice_node_id), so the 64 trailing dummies and the optional invoice fields all get omitted. The writer-side `next_marker` walks the marker counter through 1..239 and then emits 1000000000 on the 64th dummy, which is the case under test. The existing 5 valid_vectors and 23 invalid_vectors are unchanged; the new entry is appended at the end of `valid_vectors[]` so the existing positions are preserved. Link: lightning/bolts#1295 (comment) Link: lightningdevkit/rust-lightning#4297 Signed-off-by: Vincenzo Palazzo <[email protected]>
…ec contradiction Add a failing C unit test that reproduces the BOLT 12 spec contradiction raised on lightning/bolts#1295. The writer rule in `12-offer-encoding.md` (lines 1041-1049, head db3eff3a54) mandates that after a `proof_omitted_tlvs` entry of `239` the next entry MUST be `1000000000`, because the writer skips past the signature/payer-proof TLV range (240..999999999). The reader rule (lines 1065-1067) only accepts an entry that is `prev + 1` or `<included TLV> + 1`, with no carve-out for the 239 -> 1000000000 jump. A reader applying the spec literally rejects a marker sequence the writer rule mandates. CLN's reader in common/bolt12_proof.c lines 339-388 is a literal transcription of the bogus reader rule (specifically the `omitted != prev_omitted + 1` branch at line 379). Fed the writer-rule-mandated sequence [1, 2, ..., 239, 1000000000] it returns an error on the 1000000000 entry. The new test in common/test/run-bolt12_proof_marker_jump.c builds the minimum tlv_payer_proof needed to reach the marker-validation loop and asserts check_payer_proof returns NULL. It is expected to fail on current master, the failure IS the reproduction. The fix belongs in the spec PR first (amend reader rule 1065) and only then mirrored into CLN. The same contradiction is reproduced on the Rust-Lightning side in lightningdevkit/rust-lightning#4297, test spec_writer_reader_rules_contradict_on_gap_jump in lightning/src/offers/merkle.rs (commit 0034c79ae). Changelog-None Link: lightning/bolts#1295 (comment) Link: lightningdevkit/rust-lightning#4297 Signed-off-by: Vincenzo Palazzo <[email protected]>
In `lightning/bolts#1295` (head db3eff3a54, 12-offer-encoding.md), the writer rule (lines 1041-1049) mandates that after a `proof_omitted_tlvs` entry of `239` the next entry is `1000000000` (jumping past the signature/payer-proof TLV range 240..999999999), but the reader rule (lines 1065-1067) only accepts `prev + 1` or `<included TLV> + 1`. A reader applying the spec literally rejects a marker sequence the writer rule mandates. The contradiction was raised on the spec PR: lightning/bolts#1295 (comment) CLN's reader at `common/bolt12_proof.c` line 379 was a literal transcription of the bogus reader rule, and CLN's writer at line 115 used `++last_type` which would have emitted `240` (invalid) after `239` if a real invoice ever reached the boundary. Fix this by collapsing both writer and reader onto a single helper `next_marker(prev)` that returns the smallest valid marker number strictly greater than `prev`. Both sides now reference the same symbol, so the writer/reader asymmetry that caused this bug is structurally impossible. The unit test `run-bolt12_proof_marker_jump` is rewritten as a real end-to-end test: it builds an invoice with the standard required fields plus 64 dummy unknown TLVs at odd extension-range types (1000000001, 1000000003, ..., 1000000127), makes a payer_proof including only the three required fields, and asserts that `check_payer_proof` returns NULL. The marker sequence produced ends with [..., 237, 238, 239, 1000000000], exercising the gap-jump end-to-end. The test also sanity-checks that 239 appears in the sequence and that 1000000000 follows it immediately, so the test cannot go green for the wrong reason. Existing `run-bolt12_proof` and `run-bolt12_proof_vectors` still pass with no changes to their behaviour. Parallel LDK reproduction: lightningdevkit/rust-lightning#4297 (test `spec_writer_reader_rules_contradict_on_gap_jump` in lightning/src/offers/merkle.rs, commit 0034c79ae). Changelog-Fixed: Reader of BOLT 12 payer_proof now accepts the writer-rule-mandated 239 -> 1000000000 marker jump. Link: lightning/bolts#1295 (comment) Link: lightningdevkit/rust-lightning#4297 Signed-off-by: Vincenzo Palazzo <[email protected]>
Needs: