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

@ -54,9 +54,10 @@ pub fn verify(identity_pk: &[u8], loc: &Loc) -> bool {
let signature = Signature::from_bytes(&sig);
vk.verify(&sign_msg_v2(&loc.onion, loc.ts), &signature)
.is_ok()
|| vk
.verify(&sign_msg_v1(&loc.onion, loc.ts), &signature)
.is_ok()
|| (crate::pay::legacy_sigs()
&& vk
.verify(&sign_msg_v1(&loc.onion, loc.ts), &signature)
.is_ok())
}
pub fn encode(loc: &Loc) -> Vec<u8> {