Custom UUIDv4 plus random generation
- Status: SHIPPED in C++ port
- Spec: SEC-04, PIN-09, FR-03
- Sources:
tosv.cppuuid4 plus hexr,archive/tosv.pycustom_uuid4,uploads/paste.txtvision, SPEC.md 5
What it is
UUIDv4 and hex randomness are hand-rolled in ten lines on
random_device: 16 bytes, version nibble 0100, variant bits
10, dashed hex print. No uuid library anywhere, because helpers
that briefly hold whole secrets violate the vision rule, and no
dependency that needs its own audit.
How TOSV does it
uuid4 fills 16 bytes from random_device, masks bytes 6 and 8 to
RFC bits, and snprintfs the dashed form. hexr picks hex chars for
cred suffixes, session ids, and duress suffixes. Every call site
uses fresh bytes: grant users, grant ids, blob ids, session ids,
lock tokens.
What it protects against
ID guessing (122 random bits per UUID) and supply-chain risk from ID libraries. Blob names double as unguessable capabilities: knowing the store path buys nothing without the id.
Attack realism
High for the guessing half: 122-bit ids under per-grant auth are
beyond enumeration forever. Honest about the platform half:
random_device is a real CSPRNG on Linux x86_64 (RDRAND plus
urandom mix per libstdc++) and weaker folklore elsewhere, which is
why the deploy target is pinned.
Pros
Zero deps, ten auditable lines. RFC-shaped, so every tool that parses UUIDs keeps working. No helper-held copies of secrets.
Cons and how the vault resolves them
- Platform-dependent entropy quality. Resolved by pinning Linux x86_64 plus a Gate 2 entropy smoke (1M ids, uniqueness plus nibble distribution); other platforms need an ADR first.
- Hand-rolled crypto-adjacent code. Resolved by tininess plus the exact RFC bit masks in review; this is the rare hand-roll that is smaller than its library.
rand()%16style modulo bias in hexr. Accepted with math: 8-16 hex chars at 4 bits each lose fractions of a bit to bias, leaving 96-plus-bit creds under rate limits. M5 switched to full-width nibble sampling: zero bias by construction.- No central id registry to detect collision. Accepted: 122-bit random collision needs billions of ids; the 100k blob cap keeps the birthday math absurd.
Residual risk
None at pinned platform and scale; entropy smoke reruns in CI.