Canonical codec maps byte strings (<2^64) to residues with exact decoding
The base-m length codec decodes exactly for all moduli within the paper's parameter bounds
Crypto & theory arXiv 24 Mar 2026 Method Prototype evidence
Published as “Canonical Byte-String Encoding for Finite-Ring Cryptosystems”
Why it matters
It gives developers of finite-ring cryptosystems a ready-to-use, formally verified serialization layer that can be safely composed with existing encryption primitives.
Summary
The paper presents a canonical base-m-len codec that maps byte strings (< 2^64 bytes) to residue streams in Zm with exact, suffix-tolerant decoding, and proves stream-level correctness in Lean 4. It shows linear-time encoding/decoding and reports native Rust throughput up to 640 MiB/s, substantially faster than exact BigUint radix-conversion baselines. The implementation and formal proofs are released as open-source artifacts, but the codec is deterministic and reveals the plaintext length, offering no confidentiality on its own.
What they found 4
- Stream-level correctness: decoding the encoded byte string yields the original bytes.
“Decodem(Encodem(bytes)) = ok(bytes).”
- Suffix tolerance: decoding with any valid suffix still returns the original bytes.
“Decodem(Encodem(bytes) ‖ t) = ok(bytes).”
- Native encode throughput for m=65 on 1 KiB input is 163.6 MiB/s, far exceeding the BigUint baseline of 25.2 MiB/s.
“Encode 1 KiB 163.6”
- The payload cost per byte follows the asymptotic rate log_m 256 digits per byte.
“The payload contributes a number of digits proportional to the byte length, with asymptotic rate logm256 = log2 m digits per byte.”
Caveats 4
- The preferred wire format exposes the exact byte length.
- The codec is public and deterministic, so it provides no confidentiality, integrity, or authenticity before the surrounding cryptographic protocol is applied.
- The Lean formalization proves the abstract specification boundary rather than the Rust implementation, so low-level parser and allocator behavior remain implementation responsibilities.
- Because decoding allocates according to the embedded length, implementations should enforce a callerspecified maximum decoded length for untrusted inputs.
What’s new here 4
- Provides a deterministic, self-delimiting byte-to-residue representation layer for arbitrary finite-ring moduli.
- Formal verification of the abstract codec (prefix inversion, payload bounds, end-to-end correctness) in Lean 4.
- Rust reference implementation with benchmarked performance showing practical speed advantages over exact radix conversion.
- Suffix-tolerant decoding that ignores any valid trailing digits after the declared length.