Expand description
Digests and the two encodings a digest is written in.
The half of Wave 2’s crypto item that belongs to the host under lib/README.md’s division: a
hash function is somebody else’s table and base64 is somebody else’s grammar, so both are
primitives rather than Beck. What is composition — a signed token, a fingerprint, a check that
reads the two halves apart — is lib/crypto.beck.
Three constraints shaped what is here.
- A digest is a pure function. It performs no effect and it is the same on every replay, so
nothing about it has to be recorded on an envelope. That is the difference between hashing and
the other two things a crypto library usually offers: random bytes and a clock are
nondeterministic, and Beck already has
uuid()andnow()for those, both chargednondet. - Only one function turns a
secret[Str]into aStr, and it iskeyed. §3.5’s property is that a secret cannot reach a browser; a message authentication code exists precisely to be handed to one, so the declassification is the point rather than a hole in it — but it is chargedcap.signso that a view cannot mint one, anddocs/adr/0014is the record of that decision. - Comparing a digest is not
==.sameis constant-time, because a verifier that returns early tells the caller where the first wrong byte was.
BLAKE3 rather than SHA-2 because it is already in this tree — beck-rt’s SignedIdentity
(docs/48) and the signal graph’s stable ids both use it — and adding a second hash function to
avoid reusing one is a dependency taken for symmetry.
docs/adr/0015 records
why ring was not taken instead, and what that leaves unbuilt.
Functions§
- base64_
decode - The inverse of
base64_encode, tolerant of padding and of the standard alphabet. - base64_
decode_ bytes - The same decoder, stopping before the text.
- base64_
encode - RFC 4648 §5 — the URL-and-filename-safe alphabet, without padding.
- base64_
encode_ bytes - The same encoder, starting before the text.
- hex_
decode - The inverse of
hex_encode, or why it is not one. - hex_
encode - Lowercase hex, two digits per byte of UTF-8.
- keyed
- A message authentication code over
messageunderkey, as 64 lowercase hex digits. - of
- BLAKE3 of
text, as 64 lowercase hex digits. - same
- Equality that does not stop at the first difference.
- uuid_
normalise - A UUID in the canonical 8-4-4-4-12 form, lowercased, or why it is not one.
- uuid_
version - Which version a canonical UUID declares, as the digit in the third group.