VSF Logo

What it is

A self-describing binary format for any kind of data. For images, it adds a colour model that says what each one claims.

Every value carries its type. Every file carries its hash. Every number is as wide as it needs to be and no wider. Every colour entry says whether it was measured or assumed, and by whom. Having all of it in one open format, checked by default, is the point.

Readable by people and by AI. Every value carries its type and size, and every section its name, so a file can be printed exactly as it is stored, with no schema and without the program that wrote it. vsfinfo shows each value in VSF's own notation, type and size first (z3⦉9⦊ version, l5⦉96002205⦊ File length), each section by name, offset and size, and whether the hashes verify. A person can read that, and so can a language model, which can then explain or check a file it has never seen.

Crate vsf 0.10.1, format v10, reads v9. GitHub | docs.rs | crates.io

What it carries

  • The container. Typed values, sections with a table of contents, a BLAKE3 hash on every file, per-section content hashes, Ed25519 signatures and lazy partial reads. Edits are appended as generations, so the original bytes never move and any earlier state can be checked out.
  • Images. VSF RGB (primaries at 703/523/462 nm, Illuminant E white), four IDT classes with tiers, spectral camera profiles, and 32 source primaries and 37 transfer curves (sRGB, Display P3, Rec.2020, ACES, S-Log3, LogC4, Apple Log and the rest) kept exactly as they arrived, each verified against colour-science.
  • Raw photography. opsin converts a DNG to VSF with its matrices, illuminants and calibration signature kept verbatim, renders it bit for bit as the source did, and writes a characterization made here back into a DNG every reader applies.
  • Audio and video. Photon carries encrypted, compressed, multi-track audio and video in VSF.
  • Numbers, time and place. Integers of any width, IEEE and Spirix floats, complex numbers, bit-packed tensors, Eagle Time, Dymaxion WorldCoord and Huffman-compressed Unicode text.

What a colour entry says

Every colour transform in a VSF file carries a class, saying what it claims: Absolute (the light, as it was), Relative (the object, with the illuminant divided out), Creative (a deliberate look) or Technical (no claim about the scene). It also carries a tier, saying who measured it: this unit, the model, or a convention. A camera JPEG is Creative, because white balance alone decides it.

A camera's spectral response can travel with the file, so the transform can be rebuilt for any light and any observer. Conversions between sRGB, Display P3, Adobe RGB, Rec.2020, ACES and the camera log spaces are colorimetric, with no hidden white balance. The full model, and how it relates to DNG, ICC and ACES, is in idt/README.md.

Exponential Width Encoding

Every integer on the wire is a type letter, one marker byte, then the bytes, big-endian:

Value 42:         'u' '3' 0x2A           8 bits
Value 4,096:      'u' '4' 0x10 0x00      16 bits
Value 2^32 - 1:   'u' '5' + 4 bytes      32 bits
Value 2^64 - 1:   'u' '6' + 8 bytes      64 bits
Value 2^128 - 1:  'u' '7' + 16 bytes     128 bits

The marker is a base36 digit. 0 to 9 are 0 to 9, A to Z are 10 to 35. A marker of value N means 2N bits follow. So u0 is a bool, u3 a byte, u6 a u64, uA 1024 bits, and uZ 235 bits, which is 4 GiB and more than any single integer will need.

What that buys

  1. O(1) skip. Read the marker, know the width, move on. No continuation bits, no length-of-length.
  2. No ceiling. The marker is the exponent. Thirty-six exponents cover bool to 4 GiB with one byte.
  3. Canonical form. A writer emits the narrowest marker that holds the value, and a reader rejects a value a narrower marker would have held. One number has exactly one byte form, so two byte strings never decode to the same value. That is what makes byte-exact hashing and signatures mean something.
  4. Printable. Markers are ASCII, so a hex dump reads.

Width markers before an integer have a long history, from ASN.1 BER (1988) to CBOR. VSF makes the marker the exponent directly, holds every width to a power of two, requires the minimal form, and uses the same scheme for every length, offset and count in the file, so nothing in the format has a size limit the data did not bring.

Types

Every value is ⦉letter(s)⦊⦉size⦊⦉data⦊. The second byte says which of three things you are looking at, and the ranges never overlap:

Second byteASCIIMeaning
0 to 90x30 to 0x39size exponent, base36 low
A to Z0x41 to 0x5Asize exponent, base36 high
a to z0x61 to 0x7Anamed family member
PrefixFamily
u i f junsigned, signed, IEEE float, complex, sized by marker
s cSpirix scalar and circle, 25 each, F3 to F7 × E3 to E7
t_ q_tensor, contiguous and strided, one per element type
pbit-packed tensor, 1 to 128 bits per element
h g k mhash, signature, key, MAC, each carrying its algorithm
nnetwork: address, host, IPv4, IPv6, CIDR, MAC, port, socket, URL, DNS name
rcolour and raster; ro* drawable objects
d o ldictionary key, offset, length: the container's own structure
a xASCII text, Huffman Unicode
e wEagle Time, WorldCoord
opopcode

318 variants today. The enum is the format: add a variant and the encoder, decoder and vsfinfo will not compile until they handle it. The code is Rust, with the usual Rust guarantees and no others; a parser still has to bound what it allocates against what it was handed, and a bug report is the right response to one that does not.

What the types buy

Bit-packed tensors

A 14-bit sensor stores 14 bits, not 16. A 4-bit quantised model stores 4. Phred scores store 6. Any rows or tile unpack straight from the bytes without copying the rest.

Cryptographic primitives as types

A hash, signature, key or MAC carries its algorithm in the type, so a SHA-256 hash cannot be handed to code expecting BLAKE3. Implemented today: BLAKE3 hashing (always on), Ed25519 verify in no_std, Ed25519 signing, X25519, ChaCha20-Poly1305 and AES-GCM.

Spirix

Two's-complement floating point. One zero. One infinity, for actual singularities. Values too small or too large to represent keep their sign. a × b = 0 exactly when a = 0 or b = 0. Undefined results record why they are undefined.

WorldCoord and Eagle Time

A Dymaxion-projected Earth coordinate, 2.14 mm average and 5.06 mm worst case in 64 bits. Eagle Time is physics-bounded consensus time, optional in the header: a clockless device omits it rather than writing a placeholder.

Integrity and provenance

Every file built by VsfBuilder carries a BLAKE3 hash of the whole file in its header. There is no opt-out. verification::read_verified checks it before handing anything back, on a desktop or in an nRF52840 bootloader.

  1. Content hashes per section. Every table-of-contents entry can carry a BLAKE3 of its body. A section that is never moved stays provable whatever is appended after it.
  2. Signatures. sign_section signs the document as built, and the per-section content hashes keep each section provable on its own.
  3. Calibration hashes. A RAW names its dark, flat, bias, vignette and distortion frames by hash, so the wrong frame is caught before it corrupts a photograph.

BLAKE3 hashes at several GB/s per core, so on most storage the hash adds little to the time spent reading or writing the file.

Quick start

[dependencies]
vsf = "0.10"
use vsf::{VsfType, BitPackedTensor, Tensor};
use vsf::crypto_algorithms::HASH_BLAKE3;

// 12-bit camera RAW, packed at 12 bits
let raw = BitPackedTensor::pack(12, vec![4096, 3072], &pixel_data);
let encoded = VsfType::p(raw).flatten();

// 8-bit greyscale as a tensor
let img = VsfType::t_u3(Tensor::new(vec![1920, 1080], grey));

// Text, Huffman compressed (needs the `text-encode` feature)
let doc = VsfType::x("Kia ora".to_string());

// A hash that knows its algorithm
let hash = VsfType::h(HASH_BLAKE3, hash_bytes);

// Round trip
let decoded = VsfType::parse(&encoded)?;
assert_eq!(original, decoded);

Embedded builds use default-features = false; everything that needs an allocator or atomics is behind a feature. Three binaries ship with the crate: vsfinfo (a 1:1 literal dump of any file), vsflog (read a structured log) and vsfimg (any PNG, JPEG, WebP or TIFF to a canonical VSF image).

Versioning

From 0.8.0 the crate minor is the format version: vsf 0.10.x writes v10 files. Any breaking change, wire or API, bumps both. The backward-compatibility floor lives in every file header and is enforced by the reader by name, never by misparsing. A release that wrote wrong bytes is yanked; a release that misread valid files but never wrote a bad byte is superseded and left in history. A frozen-wire test pins the exact bytes of the text and key types so a wire break can never ship silently.

The rest of the stack

VSF is the encoding the rest of it serialises thru: Spirix (arithmetic), TOKEN (identity), Eagle Time (time), Dymaxion (location), ihi, tohu, manifestus and Photon.

License

Three things, three licenses:

Nobody is asked for money, attribution beyond what MPL requires, or permission. Sell what you build with it. The format itself stays free, for everyone, forever, and the licenses are the mechanism, not a request.

01010010 11000011 10000101

One value, one byte form.