Appearance
Store-and-Forward Forwarding Delivery Envelope (Type 13)
- Status: Standard (Track C, Issue #986, PR #996, Commit
fc3fcb5a) - Implementations:
- CDDL Schema:
docs/protocol/cbor/direct-message.cddl - TypeScript:
packages/frank-codec/src/forwarding.ts - Rust:
backend/cashweb/frank-cbor/src/forwarding.rs
- CDDL Schema:
1. Overview & Architectural Objective
The Type 13 Forwarding Delivery Envelope provides hop-by-hop store-and-forward relaying across federated Cashweb nodes. It enforces a strict Content-Oblivious Boundary: intermediary and destination relays verify storage stamps, delivery TTLs, and routing identities without inspecting or decrypting the encapsulated message payload.
2. CDDL Wire Specification
From docs/protocol/cbor/direct-message.cddl:
cddl
; Active type 13 / schema 1 / min-reader 1: relay forwarding delivery envelope.
; Key 0 is not a field. The forwarding digest uses the inner type-10 frame's own network tag.
forwarding-delivery-envelope = {
1: account-ref, ; destination relay routing identity (key type 1)
2: framed-object, ; inner direct-message-delivery (Type 10) frame
3: digest-32, ; forwarding payload digest of field 2
4: [1*64 payment-member], ; payments compensating the destination relay
? 5: tstr .size (1..256), ; optional destination relay endpoint URI
? 6: uint .le 4294967295, ; optional delivery TTL / expiration timestamp (seconds)
* (uint .ge 7) => frank-value, ; additive extensible fields; key 0 is a schema error
}3. Nested Multi-Layer Encapsulation
Frank achieves defense-in-depth through concentric deterministic CBOR frames:
┌────────────────────────────────────────────────────────────────────────────────────────┐
│ 1. TYPE 13: FORWARDING DELIVERY ENVELOPE (Hop-by-Hop Relay Envelope) │
│ • Destination Relay Identity P_relay (Field 1, Key Type 1, 33-byte secp256k1) │
│ • Forwarding Payload Digest T_fwd (Field 3, 32-byte SHA-256 of the inner type 10) │
│ • Payments (Field 4, [1*64 payment-member]; each item carries its own network) │
│ • Optional Endpoint URI & TTL Timestamp (Fields 5, 6) │
│ ┌────────────────────────────────────────────────────────────────────────────────────┐ │
│ │ 2. TYPE 10: DIRECT MESSAGE DELIVERY (Destination Relay Delivery Frame) │ │
│ │ • Network Tag (Field 0) │ │
│ │ • Recipient Stamp Key P' (Field 1, Key Type 1) │ │
│ │ • Frame Digest T3 of Field 2 (Field 3) │ │
│ │ • Recipient Storage Payment Stamps (Field 4) │ │
│ │ ┌────────────────────────────────────────────────────────────────────────────────┐ │ │
│ │ │ 3. TYPE 11: RECIPIENT ENCRYPTED PAYLOAD (XChaCha20-Poly1305 Crypto-Box v2) │ │ │
│ │ │ • Routing Sender & Recipient Identities (Fields 1, 2) │ │ │
│ │ │ • Ephemeral Stamp Point E (Field 5, 33 bytes) │ │ │
│ │ │ • Ephemeral Stamp Point X (Field 6, 33 bytes) │ │ │
│ │ │ • Chaum-Pedersen DLEQ Proof c || s (Field 7, 64 bytes) │ │ │
│ │ │ • Ciphertext (Field 4, AEAD authenticated with dm-crypto-context-v1) │ │ │
│ │ │ ┌────────────────────────────────────────────────────────────────────────────┐ │ │ │
│ │ │ │ 4. TYPE 12: DECRYPTED MESSAGE CONTENT (End-to-End Plaintext Context) │ │ │ │
│ │ │ │ • Stable Logical Message ID (UUID-16, Field 1) │ │ │ │
│ │ │ │ • Content Digest T1a of Field 2 (Field 3) │ │ │ │
│ │ │ │ • Conversation ID (UUID-16, Field 4) & Optional Name │ │ │ │
│ │ │ │ ┌────────────────────────────────────────────────────────────────────────┐ │ │ │ │
│ │ │ │ │ 5. TYPE 20: MESSAGE CONTENT REVISION │ │ │ │ │
│ │ │ │ │ • Transcript Network Domain: "frank" (Field 0) │ │ │ │ │
│ │ │ │ │ • Ordered Semantic Message-Item Frames (Field 1, [1*256]) │ │ │ │ │
│ │ │ │ │ ┌────────────────────────────────────────────────────────────────────┐ │ │ │ │ │
│ │ │ │ │ │ 6. SEMANTIC ITEMS: │ │ │ │ │ │
│ │ │ │ │ │ • Type 22: UTF-8 Text Item │ │ │ │ │ │
│ │ │ │ │ │ • Type 24: Stealth Payment Item │ │ │ │ │ │
│ │ │ │ │ │ • Type 25: Universal State Channel Update │ │ │ │ │ │
│ │ │ │ │ │ (Interactive Turns, Gaming, Swaps, State Execution) │ │ │ │ │ │
│ │ │ │ │ └────────────────────────────────────────────────────────────────────┘ │ │ │ │ │
│ │ │ │ └────────────────────────────────────────────────────────────────────────┘ │ │ │ │
│ │ │ └────────────────────────────────────────────────────────────────────────────┘ │ │ │
│ │ └────────────────────────────────────────────────────────────────────────────────┘ │ │
│ └────────────────────────────────────────────────────────────────────────────────────┘ │
└────────────────────────────────────────────────────────────────────────────────────────┘4. Relay Store-and-Forward Sequence
5. Implementation Invariants
- Payment list: Field 4 may mix stamp payments and stealth payments. A stamp payment settles on the inner type-10 frame's network (README S3); a stealth payment may name another network, which must be a
docs/protocol/chains/v1.jsonchain identifier. Stamp child indices are contiguous over the stamp members. A type 13 map that contains key 0 is a schema error. - Deterministic Payload Digest: Field 3 MUST equal
forwardingPayloadDigest(payloadFrame), using the inner type-10 frame's own network tag. - Fail-Closed Relay Policy: If destination relay connectivity or KV coordination is lost, the relay fails closed (returning
HTTP 503 Service Unavailable), preventing dropped messages or lost storage stamps.