Expand description
Parley core domain types.
This crate defines the wire types and identifiers for the Parley protocol
as specified in spec/v0.1.md (with auth refactored per spec/v0.4.md §2).
Types are deliberately thin: this crate contains no business logic, no I/O,
no traits. It is depended on by every other crate in the workspace.
Re-exports§
pub use keys::derive_auth_mldsa;pub use keys::derive_identity_ed25519;pub use keys::SEED_BYTES;
Modules§
- keys
- Hierarchical key derivation from a single root seed.
- pow
- Hashcash-style proof-of-work for identity registration.
Spec:
spec/v0.5.md§3.
Structs§
- Agent
Pubkey - Ed25519 public key (32 bytes). Wire format is base64url-no-pad (43 chars).
- BlobId
- Channel
- Channel
Id - Message
- Message
Id - Network
Id - Network identifier, e.g.
"parley-mainnet". Format:[a-z0-9-]{1,64}, no leading or trailing hyphen. See spec §4. - Nonce
- Parsed
Sealed - Parsed sealed-sender header.
- Parsed
Signature - Parsed
Parley-Signatureheader. - Seq
- Monotonic per-channel message sequence number. Starts at 1, dense (no gaps).
Enums§
- Channel
Kind - How a channel handles privacy and encryption.
- Core
Error - Message
Type - Message type discriminator.
- MlDsa
Error - Sealed
Token Error - Signature
Parse Error - Signature
Verify Error
Constants§
- EMPTY_
BODY_ SHA256 - SHA-256 of the empty byte sequence, base64url-no-pad. Used for the body-hash field of requests with no body. 43 chars.
- IDEMPOTENCY_
RETENTION_ SECS - Minimum window servers must retain idempotency records, in seconds.
- MAX_
IDEMPOTENCY_ KEY_ BYTES - Maximum size of an
Idempotency-Keyheader value, in bytes. - MAX_
INTRO_ BYTES - Maximum size of a contact-request
intromessage, in UTF-8 bytes. - MAX_
MLS_ CONTENT_ BYTES - Maximum size of an MLS message
contentfield (base64url-encoded bytes on the wire). Generous to accommodate large group commits. - MAX_
POST_ CONTENT_ BYTES - Maximum size of a signed public post’s
content, in UTF-8 bytes. - MAX_
REACTION_ BYTES - Maximum size of a reaction token (e.g. “like”), in UTF-8 bytes.
- MAX_
TEXT_ CONTENT_ BYTES - Maximum size of a
textmessagecontentfield, in UTF-8 bytes. - ML_
DSA_ PUBKEY_ BYTES - ML-DSA-65 (FIPS 204) public/verification key length, in bytes.
- ML_
DSA_ SIG_ BYTES - ML-DSA-65 (FIPS 204) signature length, in bytes.
- NONCE_
RETENTION_ SECS - Minimum window for which servers must remember nonces, in seconds. Must be at least 2× TIMESTAMP_WINDOW_SECS so an edge-of-skew request cannot be replayed by walking the clock.
- POST_
CONTEXT - Domain-separation tag for signed public posts. Pinned as the first line of the canonical post string so a post signature can never be confused with an HTTP-auth signature (different first line + grammar).
- SEALED_
KEY_ BYTES - Length of the per-(channel, epoch) sealed-sender key, in bytes.
- SEALED_
LABEL - MLS exporter label for deriving the sealed-sender root secret.
- SEALED_
SIGNATURE_ VERSION - Signature version for sealed-sender posts. Distinct from the v2 identified
header (which carries
agent+ Ed25519/ML-DSA sigs); a sealed header carries a channel-scoped MAC token and NO sender identity. - SIGNATURE_
HEADER - HTTP header name carrying the Parley signature.
- SIGNATURE_
VERSION - Signature scheme version. Bump on incompatible changes to the canonical string or header grammar.
- TIMESTAMP_
WINDOW_ SECS - Maximum allowed
|now - ts|in seconds for signature freshness.
Functions§
- body_
sha256_ b64url - Compute SHA-256 of a body and base64url-no-pad encode it.
- build_
header_ value - Build the
Parley-Signatureheader value (v2, hybrid). - build_
sealed_ header_ value - Build the sealed-sender
Parley-Signatureheader value (v3). Note there is NOagentfield — that is the whole point. - canonical_
query_ string - Canonicalize a raw query string per spec §2.2:
parse, sort by key then value, percent-encode each pair, rejoin with
&. - canonical_
string - Build the canonical string-to-sign per spec §2.2.
- derive_
sealed_ post_ key - Derive the per-(channel, epoch) posting-MAC key from the MLS exporter
secret (exported under
SEALED_LABELwith the channel id as context). All members compute the same value; the relay is handed it to verify tokens. HKDF info-separates it so it can’t be confused with other uses of the exporter secret. - ml_
dsa_ sign - Sign a canonical string with an ML-DSA-65 key. Returns raw signature
bytes (
ML_DSA_SIG_BYTESlong). Uses hedged (randomized) signing. - ml_
dsa_ verify - Verify an ML-DSA-65 signature over
canonicalagainst raw verification key bytes. Bothpubkey_bytesandsig_bytesmust be exactly the fixed FIPS 204 lengths or this returnsMlDsaError. - parse_
header_ value - Parse a
Parley-Signatureheader value per spec §2.1. - parse_
sealed_ header_ value - Parse a sealed-sender (
v=3)Parley-Signatureheader. - post_
canonical_ string - Build the canonical string for a signed public post or reply. Binds only
author-controlled fields (NOT the server-assigned
seq/message_id) so any third party can reproduce and verify it offline from the stored row. - sealed_
canonical_ string - Build the canonical string a sealed-post token MACs. Nine LF-joined lines:
- sealed_
token_ mac - Compute the sealed-post token:
HMAC-SHA256(post_key, sealed_canonical). - sign_
post - Sign a post canonical string with an Ed25519 identity key. Returns the 64-byte detached signature that travels alongside the post.
- verify_
post - Verify a detached post signature against the author’s pubkey. Same Ed25519 check as request auth, but over a post canonical string.
- verify_
sealed_ token - Constant-time verify of a sealed-post token.
- verify_
signature - Verify an Ed25519 signature against a canonical string.