V0.1.0 RELEASED / RUST + LEAN 4

Small bytes.
Explicit contracts.

Varint + ZigZag, with the edge cases accounted for. One small Rust library. A corresponding Lean 4 proof package.

Read the API docs ↗

no_stdzero runtime dependenciesMIT
THE BYTE LABLoading WebAssembly…

Watch an integer get smaller.

The published Rust codec runs right here in your browser.

Unsigned: 0 to 18,446,744,073,709,551,615.

CANONICAL HEX— bytes

continuation bit 7 payload bits

Browser adapter · bited 0.1.0 · exact BigInt input

0heap allocations in the core
18specified proof obligations, proved
351original conformance cases
5 / 10maximum bytes for u32 / u64

01 / VERIFICATION

A small library.
A traceable proof boundary.

The mathematical contract, independent reference semantics and Rust-derived model meet in explicit refinement theorems.

Rust source is extracted through pinned Charon and Aeneas into Bited.Generated. Bited.Spec defines the contract for Bited.Reference; Bited.Proofs proves its properties. Bited.Refinement establishes Rust-to-model correspondence. Bited.Public exports the theorems, with transitive axiom audit and fresh stored-proof replay.

What is proved

ZigZag bijection, encoding and decoding correctness, canonical uniqueness, shortest base-128 length, buffer preservation, streaming equivalence and source correspondence.

Where the proof stops

The pinned extraction profile uses Apple ARM and 64-bit usize. Compiler and machine-code correctness are outside the boundary. Fresh replay uses the same Lean kernel.

Inspect the trust boundary ↗

02 / PERFORMANCE

Three libraries.
The same integer workloads.

2.00×

full-width u64 encoder throughput
vs integer-encoding 4.1.0 on Apple M5

Mean encoder CPU time with approximate 95 percent intervals across four workloads, comparing bited, leb128 0.2.5 and integer-encoding 4.1.0.
Apple M5 · Rust 1.88.0 · one thread · 15 rotating repetitions · mean CPU ns/value; lower is faster.
Encoding: mean CPU ns/value. All three produce identical canonical bytes for the checked inputs.
Workloadbited 0.1.0leb128 0.2.5integer-encoding 4.1.0
One-byte1.0861.7901.092
Short 80 / 15 / 51.3262.9181.387
Full-width u642.65718.2335.320
Large full-width traversal3.75419.0496.036
Decoding: mean CPU ns/value. bited uses canonical-only decoding; peer APIs perform different validation.
Workloadbited 0.1.0leb128 0.2.5integer-encoding 4.1.0
One-byte1.0415.5701.116
Short 80 / 15 / 55.0115.6675.057
Full-width u648.1597.3658.246
Large full-width traversal8.5718.4828.573

The short mixture is 80% one-byte, 15% two-byte and 5% full-width values. One-byte encoding is close to integer-encoding; the intervals overlap. leb128 is faster at full-width decoding.

These are matched native public API measurements on shared valid inputs, not identical validation work. They do not establish browser/WASM rankings, other-CPU rankings or a universal fastest implementation.

Decoding policies and error behavior.

Observed behavior on the recorded malformed-input cases; not an exhaustive peer audit.
Input / contractbited 0.1.0leb128 0.2.5integer-encoding 4.1.0
Redundant zero: 80 00Canonical policy rejects;
bounded policy accepts and flags it
Accepts 0Accepts 0
Truncated: 80Truncated, consumed 1UnexpectedEofNone
Overflow on byte 10Overflow, consumed 10OverflowNone
11 continuation bytesTooLong, consumed 10UnexpectedEof;
reader consumed 11
None
Trailing bytes: 00 01Prefix consumes 1;
exact API rejects trailing data
Prefix consumes 1Returns (0, 1)

Accepting noncanonical encodings can be an intentional API policy. These observations do not imply that a peer is unsafe or defective. The Lean proof claims on this page concern bited only.

Download raw measurements ↓Read the engineering article ↗

03 / THE API

Choose the contract
your caller needs.

RUSTfixed-output.rs
use bited::encode_u64;

let encoded = encode_u64(300);

assert_eq!(encoded.as_bytes(), &[0xac, 0x02]);
assert_eq!(encoded.len(), 2);

Caller-provided buffers are also supported. Insufficient capacity leaves the output buffer unchanged.

READY TO USE / V0.1.0

A focused primitive
for your next binary format.

Protocols, delta-coded streams, embedded firmware and WebAssembly. Consumers need Rust 1.88 or later; Lean is needed only to reproduce the proofs.