Skip to content

Deterministic CBOR v1 (FRNK) Specification ​

Status: Normative Encoding and Validation Standard
Implementations: @frank/codec (TypeScript), frank-cbor (Rust zero-copy parser)
Conformance Vectors: docs/protocol/cbor/vectors/


1. Framing Architecture ​

Every independently stored, signed, hashed, or forwarded Frank object is serialized as an exact binary frame:

OffsetSizeFieldDescription
04 bytesMagic BytesASCII FRNK (0x46 0x52 0x4e 0x4b)
41 byteFrame VersionProtocol frame version (0x01)
54 bytesBody LengthBig-endian uint32 payload length (bytes 9..N)
9NN bytesCBOR EnvelopeCanonical CBOR map { 0: type_id, 1: schema_version, 2: min_reader_version, 3: payload_bytes }

Worked example: a Type 22 text item {0: "hi"} (23 bytes total):

text
46 52 4e 4b            FRNK (magic)
01                     frame version 1
00 00 00 0e            CBOR body length 14
a4                     envelope map, 4 entries
  00 16                  0: type_id = 22 (text-message-item)
  01 01                  1: schema_version = 1
  02 01                  2: min_reader_version = 1
  03 45                  3: payload = 5-byte string
     a1 00 62 68 69        payload map {0: "hi"}

2. Canonical Encoding Constraints (Strict CBOR) ​

To ensure byte-for-byte deterministic hashing across all languages (TypeScript, Rust, Go, Python):

  1. Integer Map Keys: All protocol map keys MUST be unsigned integers (uint), serialized in strictly ascending numerical order without duplicates. Text or string keys are forbidden.
  2. Minimal Integer Representation: Integers MUST use the shortest possible CBOR encoding (0–23 inline, 24–255 as 1-byte, 256–65535 as 2-byte, etc.).
  3. No Indefinite-Length Items: Indefinite-length byte strings, text strings, arrays, or maps are strictly rejected.
  4. No Floating-Point Values: IEEE 754 float types are disallowed in protocol records to prevent architecture-dependent precision loss.
  5. Exact UTF-8 String Encoding: Text strings MUST be valid UTF-8, with no unassigned Unicode code points or invalid surrogate pairs.
  6. Zero Trailing Bytes: The CBOR payload must consume exactly the remaining bytes of the frame. Trailing data is a fatal deserialization error.

3. Type ID Allocation Registry ​

Generated from docs/protocol/message-types/v1.json, the authoritative list (see its README).

Type IDHexNameCDDL Schema RuleDescription
10x0001Directory Statementdirectory-statementAccount-to-relay binding, public keys (P,M,P′P, M, P'), and revision
20x0002Directory Attestationdirectory-attestationWraps and signs a Type 1 directory statement with ECDSA
30x0003Key Transition Statementkey-transition-statementCryptographic authorization linking a retiring key to a new subject key
100x000aDirect Message Deliverydirect-message-deliveryOutermost DKSAP message container with payment stamps
110x000bRecipient Encrypted Payloadrecipient-encrypted-payload-v2XChaCha20-Poly1305 ciphertext with DLEQ zero-knowledge proof
120x000cEncrypted Message Contentencrypted-message-contentInner decrypted container with logical message ID & payload
130x000dForwarding Delivery Envelopeforwarding-delivery-envelopeStore-and-forward relay hop delivery envelope with storage stamps (up to 32 MiB)
140x000eMailbox Checkpointmailbox-checkpointDurable journal facts and mailbox state checkpoint
200x0014Message Content Revisionmessage-content-revisionOrdered array of semantic message items
210x0015Container Message Itemcontainer-message-itemOpaque nested child frame container for multi-item deliveries
220x0016UTF-8 Text Itemtext-message-itemPlaintext chat message text up to 256 KiB
230x0017Email Bridge Message Itememail-message-itemEmail carried through a gateway: parties, subject, bodies, references and attachments
240x0018Stealth Payment Itemstealth-message-itemSingle-use ephemeral DKSAP on-chain transfer notification
250x0019Universal State Channel Updatechannel-update-itemInstant off-chain multi-network state execution and interactive turns
260x001aBlackjack Message Itemblackjack item (closed shapes)Peer-to-peer blackjack hand and move items (closed payload shapes, up to 4 KiB)
270x001bGeneric Plugin Message Itemplugin-message-itemApplication item type identifier with the owning plugin's opaque bytes (512 KiB unless the plugin declares up to 8 MiB)
400x0028Topic Post Contenttopic-postPublic forum post content with structured authored entries
410x0029Topic Post Submissiontopic-post-submissionInitial post creation paired with raw signed on-chain burn transaction (T7T_7)
420x002aTopic Vote Submissiontopic-vote-submissionUpvote on existing post paired with raw signed on-chain burn transaction (T7T_7)
430x002bForum Post Observationforum-single-viewSingle post observation paired with author address, raw signed burn tx, and vote weight
440x002cForum Topic Batch (forum-topic-page)forum-topic-pagePaginated batch of up to 128 post observation frames within a topic, with continuation cursor and relay epoch
450x002dForum Discovery Listing (forum-discovery-page)forum-discovery-pagePaginated directory of active topics, post counts, and last activity timestamps
460x002eForum Operation Statusforum-operation-statusRelay submission/confirmation status report for an on-chain burn transaction

NOTE

Database Pagination vs. Web Pages: In Types 44 and 45 (forum-topic-page and forum-discovery-page), the term "Page" refers strictly to cursor-based database query result sets (holding up to 128 verified post observations with continuation cursors), not HTML documents or rendered web pages.


4. Multi-Stage Validation Order ​

Implementations MUST process frames through twelve rigorous validation stages:

Frank & Cashweb High-Assurance Protocol Documentation