Expand description
Binary container formats — Rust mirror of TS binary-format.ts.
.tfbundle — sealed/serialized proof bundle, L4/L5 capable. magic = “TFBND” 0x01 0x00 0x00 (8 bytes) body_len = u32 BE body = CBOR-encoded ProofBundleEncrypted | ProofBundle sig_len = u32 BE (0 when unsigned) signature = sig_len bytes (raw ed25519)
.tfpkt — packet-on-the-wire envelope. magic = “TFPKT” 0x01 0x00 0x00 (8 bytes) body_len = u32 BE body = CBOR-encoded Packet
The Rust encoder must produce byte-identical output to the TS
encoder for the same canonical input — verified by
conformance/binary-format-vectors.yaml.
— CBOR DETERMINISM (READ BEFORE EDITING) —
For wire-level parity with the TS encoder (cbor-x with sorted keys
variableMapSize: true), the Rust encoder converts throughserde_json::Valuefirst.serde_json::Value::Objectis aBTreeMap, so its keys are emitted in lexicographic byte order when ciborium walks it — which matches RFC 8949 §4.2.3 deterministic encoding and matches the TS side. Without this intermediate, a native#[derive(Serialize)]struct would emit fields in declaration order and break parity.
Yes, this costs one extra ser/deser per encode. The packets are
small (typical .tfpkt <1 KiB) and constrained-mode use cases never
hot-loop the encoder, so the trade for a stable wire format is
correct. Do NOT remove the round-trip without first updating
conformance/binary-format-vectors.yaml and the matching TS test.
Structs§
Enums§
Constants§
Functions§
- read_
tfbundle - read_
tfbundle_ typed - Read a .tfbundle and deserialize the body into a typed
T. - read_
tfpkt - write_
tfbundle - write_
tfpkt