ubl-codec
Canonical encoding for the LogLine Workspace — two complementary codecs:
JSON✯Atomic (canonical JSON)
to_canon_vec/from_canon_slice— Serialize/deserialize with key sortingto_cid_hex— BLAKE3 CID of canonical bytesCanonical<T>— Value + precomputed canonical bytesis_canonical— Check if JSON string is already canonicalyaml_to_canon_vec— YAML → canonical JSON
Binary TLV (compact wire format)
- Varint (u64): Base-128 with MSB continuation bit
- Tags:
CID32,PUBKEY32,SIG64,BYTES,STR,U64 - Frames:
typ (u8) + len (varint) + payload
use ;
use blake3_cid;
let cid = blake3_cid;
let mut enc = new;
enc.cid32;
enc.str;
let payload = enc.finish;
let frame = encode_frame;
let = decode_frame.unwrap;
let mut dec = new;
let cid2 = dec.cid32.unwrap;
let msg = dec.str.unwrap;
Installation
[]
= "0.3"
Segurança & Limites
Proteções DoS integradas:
| Limite | Valor | Erro |
|---|---|---|
MAX_FRAME_LEN |
1 MiB | BinaryCodecError::SizeLimit |
MAX_VARINT_BYTES |
10 | BinaryCodecError::VarintOverflow |
- Fuzzing: cargo-fuzz com >860k execuções sem crashes
- Testes adversariais: 11 testes cobrindo frames oversized, varints malformados, truncação
- CI: hardening.yml com property tests, fuzz bursts e verificação de limites
License
MIT OR Apache-2.0 © LogLine Foundation