fix(protocol): domain-separate loc/prf/inv/rcp signatures
All checks were successful
ci / test (pull_request) Successful in 2m30s

Sign application frames as tag || 0x00 || fields (onionwire-loc-v1,
onionwire-prf-v1, onionwire-inv-v1, onionwire-rcp-v1). Verify accepts
that form first, then the legacy untagged LF-joined layout. Encode still
emits only the tagged signature; wire prefixes and field layout are
unchanged.

Older builds verify untagged bytes only, so they reject new tagged
signatures (fail closed). Mixed-version fleets break outbound app frames
from a new sender to an old receiver until both sides are updated.
This commit is contained in:
Sirius DevOps 2026-09-11 23:42:41 -04:00
commit c8e69732c7
No known key found for this signature in database
5 changed files with 371 additions and 16 deletions

View file

@ -144,6 +144,20 @@ Chat MUST NOT begin with three lowercase ASCII letters and a space.
Hex on the wire is lowercase on encode; decode accepts either case. No `0x`
prefix.
### Application-frame signatures
`loc`, `prf`, `inv`, and `rcp` each carry an ed25519 signature over the
**fields**, not the 4-byte typed prefix. Encode MUST sign the domain-separated
form (type tag, then each field, `0x00` separators). Verify MUST accept that
form and, for mixed-version peers, the legacy untagged LF-joined layout.
Anything else fails closed. Do not emit the legacy layout.
The invite string is separate and keeps `onionwire-invite-v1` (see Invite).
Older builds verify only the untagged bytes, so they reject tagged signatures
(fail closed, no downgrade). Mixed-version fleets break outbound application
frames from a new sender to an old receiver until both sides are updated.
### `loc ` — locator update
Sent when the sender rotated their onion and the receiver is reachable.
@ -155,7 +169,18 @@ loc <onion>\n<ts>\n<sig_hex>
- `onion` — v3 onion (56 base32 `a-z2-7` chars + `.onion`)
- `ts` — unix seconds, decimal ASCII
- `sig_hex` — 64-byte ed25519, 128 hex chars
- signed bytes: `onion || LF || ascii(ts)` (the `loc ` prefix is **not** signed)
- the `loc ` prefix is **not** signed
**Current signature (encode this):**
```
ed25519_sign(identity_sk,
"onionwire-loc-v1" || 0x00 || onion || 0x00 || ascii(ts))
```
**Legacy accept:** a signature over `onion || LF || ascii(ts)` is still
accepted on verify so old loc frames verify. New loc frames MUST use the
domain-separated form. Do not emit legacy.
Apply only if **all** of:
@ -175,7 +200,18 @@ prf <display_name>\n<bio>\n<xmr_addr>\n<ts>\n<sig_hex>
Limits: name ≤ 64 bytes, bio ≤ 512 bytes. No newlines in those fields.
`xmr_addr` may be empty; if non-empty it MUST be a checksummed Monero address
(see invoices). Signed bytes: the four fields joined by LF (no `prf ` prefix).
(see invoices). The `prf ` prefix is **not** signed.
**Current signature (encode this):**
```
ed25519_sign(identity_sk,
"onionwire-prf-v1" || 0x00 || name || 0x00 || bio || 0x00 || xmr_addr || 0x00 || ascii(ts))
```
**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.
Do not emit legacy.
Apply only for an existing friend, valid signature, newer `ts`. Not a public
profile. Not a directory.
@ -188,7 +224,18 @@ inv <amount_atomic>\n<address>\n<memo>\n<ts>\n<sig_hex>
`amount_atomic` is decimal piconero (integer string, > 0). `address` is a
Monero mainnet/stagenet standard, subaddress, or integrated address with a
valid Keccak checksum. Signed bytes: the four fields joined by LF.
valid Keccak checksum. The `inv ` prefix is **not** signed.
**Current signature (encode this):**
```
ed25519_sign(identity_sk,
"onionwire-inv-v1" || 0x00 || amount_atomic || 0x00 || address || 0x00 || memo || 0x00 || ascii(ts))
```
**Legacy accept:** a signature over the four fields joined by LF is still
accepted on verify. New invoices MUST use the domain-separated form. Do not
emit legacy.
The frame is a signed claim, not a payment.
@ -198,6 +245,19 @@ The frame is a signed claim, not a payment.
rcp <txid>\n<amount_atomic>\n<address>\n<ts>\n<sig_hex>
```
The `rcp ` prefix is **not** signed.
**Current signature (encode this):**
```
ed25519_sign(identity_sk,
"onionwire-rcp-v1" || 0x00 || txid || 0x00 || amount_atomic || 0x00 || address || 0x00 || ascii(ts))
```
**Legacy accept:** a signature over the four fields joined by LF is still
accepted on verify. New receipts MUST use the domain-separated form. Do not
emit legacy.
Signature proves which friend sent the claim. It does **not** prove money
moved. Local `verified=1` only if a user-hosted `monero-wallet-rpc` returns
one transfer row with the same non-empty `txid`, `amount`, and `address`