Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 8375bfc5e5 | |||
| 061723def1 | |||
|
|
237f0abced |
3 changed files with 48 additions and 13 deletions
|
|
@ -329,7 +329,7 @@ sent, and a peer cannot negotiate it.
|
||||||
| --- | --- | --- |
|
| --- | --- | --- |
|
||||||
| invite | `onionwire-invite-v2`, `0x00`-separated over `k`, `o`, `spk`, `kem` | same; `onionwire:v1` over `onionwire-invite-v1` `0x00`-separated `k`,`o`,`spk`, or over `k \|\| o \|\| spk` (legacy only) |
|
| invite | `onionwire-invite-v2`, `0x00`-separated over `k`, `o`, `spk`, `kem` | same; `onionwire:v1` over `onionwire-invite-v1` `0x00`-separated `k`,`o`,`spk`, or over `k \|\| o \|\| spk` (legacy only) |
|
||||||
| `loc ` | `"onionwire-loc-v1"` `0x00` `onion` `0x00` `ts` | same; `onion \|\| LF \|\| ts` (legacy only) |
|
| `loc ` | `"onionwire-loc-v1"` `0x00` `onion` `0x00` `ts` | same; `onion \|\| LF \|\| ts` (legacy only) |
|
||||||
| `prf ` | `"onionwire-prf-v1"` `0x00` `name` `0x00` `bio` `0x00` `xmr_addr` `0x00` `ts` | same; the four fields joined by LF (not yet gated — see below) |
|
| `prf ` | `"onionwire-prf-v1"` `0x00` `name` `0x00` `bio` `0x00` `xmr_addr` `0x00` `ts` | same; the four fields joined by LF (legacy only) |
|
||||||
| `inv ` | `"onionwire-inv-v1"` `0x00` `amount_atomic` `0x00` `address` `0x00` `memo` `0x00` `ts` | same; the four fields joined by LF (legacy only) |
|
| `inv ` | `"onionwire-inv-v1"` `0x00` `amount_atomic` `0x00` `address` `0x00` `memo` `0x00` `ts` | same; the four fields joined by LF (legacy only) |
|
||||||
| `rcp ` | `"onionwire-rcp-v1"` `0x00` `txid` `0x00` `amount_atomic` `0x00` `address` `0x00` `ts` | same; the four fields joined by LF (legacy only) |
|
| `rcp ` | `"onionwire-rcp-v1"` `0x00` `txid` `0x00` `amount_atomic` `0x00` `address` `0x00` `ts` | same; the four fields joined by LF (legacy only) |
|
||||||
| `tip ` | `"onionwire-tip-v1"` `0x00` `txid` `0x00` `amount_atomic` `0x00` `address` `0x00` `memo` `0x00` `ts` | same; the five fields joined by LF (legacy only) |
|
| `tip ` | `"onionwire-tip-v1"` `0x00` `txid` `0x00` `amount_atomic` `0x00` `address` `0x00` `memo` `0x00` `ts` | same; the five fields joined by LF (legacy only) |
|
||||||
|
|
@ -337,10 +337,6 @@ sent, and a peer cannot negotiate it.
|
||||||
The tag suffixes do say `-v1`; that is the tag's own version, not the invite
|
The tag suffixes do say `-v1`; that is the tag's own version, not the invite
|
||||||
string version.
|
string version.
|
||||||
|
|
||||||
`prf ` is the one frame whose legacy fallback is not yet gated: it is accepted
|
|
||||||
unconditionally in this revision and moving it under `LEGACY_SIGS` is a
|
|
||||||
separate change.
|
|
||||||
|
|
||||||
**Mixed-fleet consequence.** Older builds verify only the untagged bytes, so
|
**Mixed-fleet consequence.** Older builds verify only the untagged bytes, so
|
||||||
they reject every tagged signature from a new sender — including `tip `, which
|
they reject every tagged signature from a new sender — including `tip `, which
|
||||||
older builds emitted and verified untagged. That direction needs the peer
|
older builds emitted and verified untagged. That direction needs the peer
|
||||||
|
|
@ -401,8 +397,8 @@ ed25519_sign(identity_sk,
|
||||||
```
|
```
|
||||||
|
|
||||||
**Legacy accept:** a signature over the four fields joined by LF is still
|
**Legacy accept:** a signature over the four fields joined by LF is still
|
||||||
accepted on verify. New profile frames MUST use the domain-separated form.
|
accepted on verify while `LEGACY_SIGS` is on. New profile frames MUST use the
|
||||||
Do not emit legacy. This fallback is not yet read through `LEGACY_SIGS`.
|
domain-separated form. Do not emit legacy.
|
||||||
|
|
||||||
Apply only for an existing friend, valid signature, newer `ts`. Not a public
|
Apply only for an existing friend, valid signature, newer `ts`. Not a public
|
||||||
profile. Not a directory.
|
profile. Not a directory.
|
||||||
|
|
|
||||||
|
|
@ -95,12 +95,13 @@ pub fn verify(identity_pk: &[u8], prf: &Profile) -> bool {
|
||||||
&signature,
|
&signature,
|
||||||
)
|
)
|
||||||
.is_ok()
|
.is_ok()
|
||||||
|| vk
|
|| (crate::pay::legacy_sigs()
|
||||||
.verify(
|
&& vk
|
||||||
&sign_msg_v1(&prf.display_name, &prf.bio, &prf.xmr_addr, prf.ts),
|
.verify(
|
||||||
&signature,
|
&sign_msg_v1(&prf.display_name, &prf.bio, &prf.xmr_addr, prf.ts),
|
||||||
)
|
&signature,
|
||||||
.is_ok()
|
)
|
||||||
|
.is_ok())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn encode(prf: &Profile) -> Vec<u8> {
|
pub fn encode(prf: &Profile) -> Vec<u8> {
|
||||||
|
|
|
||||||
|
|
@ -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 {
|
fn untagged_inv(sk: &SigningKey, amount: &str, address: &str, memo: &str, ts: i64) -> Invoice {
|
||||||
let mut msg = Vec::from(amount.as_bytes());
|
let mut msg = Vec::from(amount.as_bytes());
|
||||||
msg.push(b'\n');
|
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]
|
#[test]
|
||||||
fn legacy_off_rejects_untagged_inv() {
|
fn legacy_off_rejects_untagged_inv() {
|
||||||
let (sk, pk) = keypair();
|
let (sk, pk) = keypair();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue