Merge PR 'Correct `PayerProof` comment on what `proof_signature` covers' (#5708)
What changed, and why it matters
This change only fixes a code comment and adds a test. It does not change any actual behavior. The comment now correctly explains which data is included when verifying a 'proof_signature' in the PayerProof feature. The new test confirms that unknown odd data fields in a specific reserved range are ignored, which matches the existing implementation. There is no security fix here.
No action required. This is a documentation/test commit with no security or behavioral relevance.
Security signals we found
No functional code changes
Comment-only correction
Test-only addition validating existing behavior
Evidence from the diff
The commit updates an inline comment in lightning/src/offers/payer_proof.rs to state that the proof_signature covers every payer-proof TLV outside SIGNATURE_TYPES, rather than ‘every payer-proof TLV except the proof_signature TLV.’ It also adds a unit test verifying that an unknown odd TLV within SIGNATURE_TYPES is skipped during parsing and does not affect signature verification or the invoice merkle root. The diff contains no logic changes.
Changed components
lightning/src/offers/payer_proof.rsInspect captured patch +40 / −2
### lightning/src/offers/payer_proof.rs
@@ -915,8 +915,9 @@ impl TryFrom<Vec<u8>> for PayerProof {
.map_err(|_| Bolt12ParseError::Decode(DecodeError::InvalidValue))?;
// Verify the payer signature against the merkle root of the proof
- // itself, computed over every payer-proof TLV except the
- // `proof_signature` TLV being verified. See module docs.
+ // itself, computed over every payer-proof TLV outside `SIGNATURE_TYPES`
+ // (which excludes the `proof_signature` TLV being verified). See module
+ // docs.
let proof_tagged_hash = proof_signature_hash(&bytes);
merkle::verify_signature(
&proof_signature,
@@ -1690,6 +1691,43 @@ mod tests {
));
}
+ #[test]
+ fn test_round_trip_accepts_unknown_odd_signature_range_tlv() {
+ // Unknown odd TLVs in the `SIGNATURE_TYPES` range are skipped when
+ // parsing and are an input to neither the invoice merkle root nor the
+ // `proof_signature` hash, so a signed proof carrying one still
+ // verifies with all of its fields intact.
+ let unknown_odd_signature_range_type = PAYER_PROOF_PROOF_SIGNATURE_TYPE + 2;
+ assert_eq!(unknown_odd_signature_range_type % 2, 1);
+ assert!(SIGNATURE_TYPES.contains(&unknown_odd_signature_range_type));
+
+ let proof = build_round_trip_proof_with_multiple_trailing_omitted_tlvs();
+ let mut bytes = Vec::new();
+ for record in TlvStream::new(proof.bytes()) {
+ bytes.extend_from_slice(record.record_bytes);
+ // Keep the stream in ascending type order by inserting the record
+ // right after `proof_signature`, before the data-range TLVs.
+ if record.r#type == PAYER_PROOF_PROOF_SIGNATURE_TYPE {
+ write_tlv_record_bytes(&mut bytes, unknown_odd_signature_range_type, b"ignored");
+ }
+ }
+
+ let parsed = PayerProof::try_from(bytes)
+ .expect("An unknown odd TLV in the signature range should be skipped when parsing");
+ assert_eq!(parsed.payment_hash(), proof.payment_hash());
+ assert_eq!(parsed.payment_preimage(), proof.payment_preimage());
+ assert_eq!(parsed.payer_signing_pubkey(), proof.payer_signing_pubkey());
+ assert_eq!(parsed.issuer_signing_pubkey(), proof.issuer_signing_pubkey());
+ assert_eq!(parsed.invoice_signature(), proof.invoice_signature());
+ assert_eq!(parsed.proof_signature(), proof.proof_signature());
+ assert_eq!(parsed.merkle_root(), proof.merkle_root());
+ assert_eq!(parsed.offer_description(), proof.offer_description());
+ assert_eq!(parsed.offer_issuer(), proof.offer_issuer());
+ assert_eq!(parsed.invoice_amount_msats(), proof.invoice_amount_msats());
+ assert_eq!(parsed.invoice_created_at(), proof.invoice_created_at());
+ assert_eq!(parsed.proof_note(), proof.proof_note());
+ }
+
#[test]
fn test_parsed_proof_exposes_disclosed_fields() {
let proof = build_round_trip_proof_with_disclosed_fields();Why this scored 13/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.