YAMF-Hash
Yet Another Multi Format - Hash Digest Edition
A future-proof binary encoding for hash digests, for use in structured data.
This is basically the same as yamf-pubkey. The only difference is that the minimum size of a secure hash is 256 bits (rather than the minimum 32 bits of a public key). Thus the length of a hash with an id between 0 and 127 is computed as 2 ^ (8 + (tag >> 3))
(whereas yamf-pubkey does 2 ^ (5 + (tag >> 3))
)
A quick, self-contained definition of the binary encoding:
A binarily encoded yamf-hash begins with a canonical varint called the tag
.
- if
tag >= 128
, the bytes following the tag are a varint encoding of the length of the digest, followed by that many bytes - else, the length is
2 ^ (8 + (tag >> 3))
and the tag byte is followed by that many bytes of digest data
The tag
indicates what cryptographic algorithm has been used to compute the hash.
The only currently assigned tag is 0
for sha256 digests.
For human-readable encodings, the tag 0
is given the name "sha256"
.