Expand description
The seam between a product server and the messenger server.
One small crate used by BOTH sides so the wire cannot drift: the product server signs, the messenger core verifies. No I/O, no database.
§Assertion v1
Header value: v1.<base64url(json)>.<hex hmac-sha256>. The JSON carries
nick, cred_ref, authenticated (1), paid (0 or 1), iat, exp
(unix seconds) and nonce. The HMAC key is the raw UTF-8 of the shared
secret. The HMAC input is this UTF-8 text, every line ending in a newline:
v1
<METHOD>
<path and query as the receiver sees it>
<nick>
1
<0 or 1>
<cred_ref>
<iat>
<exp>
<nonce>The verifier rebuilds the text from the parsed JSON, so the JSON values are exactly what was signed.
§Events
JSON bodies with id and type (credential.revoked, account.deleted,
nick.changed); the signature header carries the hex HMAC-SHA256 of the
raw body bytes under the same secret.
Modules§
- keyproof
- Proof-of-possession login: an identity is an ed25519 key pair held by the CLIENT; it proves itself by signing a server challenge. No password, no shared secret, nothing an agent can read.
Structs§
- Assertion
- What an assertion states about the caller.
- Event
- One event with its idempotency id.
- Live
Nick - Nonce
Cache - Remembers nonces until their assertion expires.
- Reconcile
- Startup reconciliation: the product’s snapshot of live credentials, so the messenger can
catch up on
credential.revoked/account.deletedevents it never received. Posted to/account-source/v1/reconcilewith the same body signature as events.
Enums§
Constants§
- ANON_
READ_ HEADER - Marker a product puts on an unauthenticated, read-only forward (no assertion). The core
honours it only when anonymous read is switched on (
M4A_ANON_READ=on), only forGET, and only for the paths ofanon_read_path_ok. - ASSERTION_
TTL_ S - Lifetime of an assertion the signer makes, in seconds.
- DEFAULT_
ASSERTION_ HEADER - Default header carrying the assertion. Products may configure another name.
- DEFAULT_
EVENT_ SIG_ HEADER - Default header carrying the event body signature.
- LINK_
TOKEN_ HEADER - Header carrying the barrier token on private links (product -> edge, product -> core). Every receiver of a link checks it inside, on top of the transport (WireGuard or a unix socket) that already protects the link.
- VECTORS
- Shared accept/reject vectors for assertion v1 (JSON; see the file).
Functions§
- anon_
read_ path_ ok - Anonymous read allowlist:
GETs that answer from public, world-readable data only.pathmay carry a query string and the/_matrixprefix. - link_
path_ is_ open - Paths that stay reachable without the barrier token because they are public protocol surfaces (federation peers, key documents, discovery, health).
- link_
token_ ok - Constant-time comparison of a presented barrier token with the expected one.
- sign_
assertion - Make the header value for one request.
pathis the path and query as the receiver will see it. - sign_
body - Hex HMAC-SHA256 of a raw event body.
- verify_
assertion - Verify a header value against any of
secrets(current first).now_msandskew_msbound[iat, exp]. Replay is the caller’s concern (NonceCache). - verify_
body - True when
sig_hexis valid forbodyunder any ofsecrets.