pay: domain-separate tip and gate legacy signature acceptance
All checks were successful
ci / test (pull_request) Successful in 19m52s
ci / sdk (pull_request) Successful in 2m16s

`tip` was the one payment frame with no domain tag: sign_tip signed the
LF-joined fields, so its signature could be confused with any other
newline-joined preimage. Mirror inv/rcp: sign_tip now emits
"onionwire-tip-v1" || 0x00-separated txid/amount/address/memo/ts, and
verify_tip tries that form then the historical layout.

Legacy acceptance is now one switch instead of nine call sites:
`pay::LEGACY_SIGS` (default true) plus `pay::legacy_sigs()`. Every v1 /
concat fallback reads it — the `onionwire:v1` invite string and its two
historical signature forms, `loc`, `inv`, `rcp`, and `tip`. `prf` is not
gated here because src/profile.rs is outside this card's file scope; the
spec says so.

Tests: legacy-on keeps every untagged form verifying (incl. a new tip
case); legacy-off rejects each untagged form while the tagged form still
verifies (loc, inv, rcp, tip, invite); sign_tip is pinned to the tagged
layout.

docs/PROTOCOL.md gains the emitted/accepted table per signed frame and
the mixed-fleet consequence.
This commit is contained in:
rust-dev 2026-10-22 22:23:44 -04:00
commit b8c52ca97d
No known key found for this signature in database
6 changed files with 352 additions and 35 deletions

View file

@ -101,6 +101,11 @@ pub fn decode(raw: &str) -> Result<QrPayload> {
if kem_ascii.is_some() {
return Err(Error("unknown field".into()));
}
// A v1 invite only ever carries a legacy signature: with legacy
// acceptance off it fails closed here, before any verify.
if !crate::pay::legacy_sigs() {
return Err(Error("legacy invite signatures disabled".into()));
}
let ok_tagged = vk
.verify(&sign_msg_v1_tagged(&k, &onion, &spk), &signature)
.is_ok();