profile: gate the legacy prf fallback on LEGACY_SIGS
profile::verify accepted the untagged v1 layout unconditionally, the last v1 site outside the pay::LEGACY_SIGS switch. Short-circuit it the same way loc::verify does; emit side is unchanged and still tags. PROTOCOL.md drops the 'not yet gated' caveats so prf reads like the other frames. Adds legacy_off_rejects_untagged_prf alongside the other legacy_off_rejects_untagged_* tests.
This commit is contained in:
parent
b8c52ca97d
commit
237f0abced
3 changed files with 48 additions and 13 deletions
|
|
@ -212,6 +212,23 @@ fn untagged_loc(sk: &SigningKey, onion: &str, ts: i64) -> Loc {
|
|||
}
|
||||
}
|
||||
|
||||
fn untagged_prf(sk: &SigningKey, name: &str, bio: &str, xmr_addr: &str, ts: i64) -> Profile {
|
||||
let mut msg = Vec::from(name.as_bytes());
|
||||
for f in [bio, xmr_addr] {
|
||||
msg.push(b'\n');
|
||||
msg.extend_from_slice(f.as_bytes());
|
||||
}
|
||||
msg.push(b'\n');
|
||||
msg.extend_from_slice(ts.to_string().as_bytes());
|
||||
Profile {
|
||||
display_name: name.into(),
|
||||
bio: bio.into(),
|
||||
xmr_addr: xmr_addr.into(),
|
||||
ts,
|
||||
sig: sk.sign(&msg).to_bytes().to_vec(),
|
||||
}
|
||||
}
|
||||
|
||||
fn untagged_inv(sk: &SigningKey, amount: &str, address: &str, memo: &str, ts: i64) -> Invoice {
|
||||
let mut msg = Vec::from(amount.as_bytes());
|
||||
msg.push(b'\n');
|
||||
|
|
@ -302,6 +319,27 @@ fn legacy_off_rejects_untagged_loc() {
|
|||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn legacy_off_rejects_untagged_prf() {
|
||||
let (sk, pk) = keypair();
|
||||
let legacy = untagged_prf(&sk, "Ali", "hi", "", 2_000_000_000);
|
||||
let tagged = profile::sign(&sk.to_bytes(), "Ali", "hi", "", 2_000_000_000).unwrap();
|
||||
pay::with_legacy_sigs(false, || {
|
||||
assert!(
|
||||
!profile::verify(&pk, &legacy),
|
||||
"untagged prf must be rejected with legacy off"
|
||||
);
|
||||
assert!(
|
||||
profile::verify(&pk, &tagged),
|
||||
"tagged prf must still verify with legacy off"
|
||||
);
|
||||
});
|
||||
assert!(
|
||||
profile::verify(&pk, &legacy),
|
||||
"the switch restores acceptance after the scoped override"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn legacy_off_rejects_untagged_inv() {
|
||||
let (sk, pk) = keypair();
|
||||
|
|
|
|||
Loading…
Reference in a new issue