summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Bracht Laumann Jespersen <t@laumann.xyz>2022-09-20 14:14:51 +0200
committerThomas Bracht Laumann Jespersen <t@laumann.xyz>2022-09-20 14:14:51 +0200
commitdae7ab43fa7b26c30de8547c0871132e10365003 (patch)
treed1b5cf90933f8de8110a9c0c51637f1ce3d01cb3
parent8d4c203859f37b414b6a9d78237bfa9c9f10697c (diff)
ani: update note on hashes
-rw-r--r--site/ani/2022-08-20-note-on-hashes.md30
1 files changed, 24 insertions, 6 deletions
diff --git a/site/ani/2022-08-20-note-on-hashes.md b/site/ani/2022-08-20-note-on-hashes.md
index 63ee0d4..345d8b8 100644
--- a/site/ani/2022-08-20-note-on-hashes.md
+++ b/site/ani/2022-08-20-note-on-hashes.md
@@ -3,7 +3,7 @@
Posted on <b><time id="post-date">2022-08-23</time></b>.
<p id="post-excerpt">
-Quick note on hashes in Pijul
+Quick note on hashes in Pijul.
</p>
All hashes in Pijul are [blake3](https://github.com/BLAKE3-team/BLAKE3) which is
@@ -14,15 +14,33 @@ tree which serves our purposes nicely.
A blake3 hash could be represented like this:
- $ echo foo | b3sum | xxd -cols 32 -g 32 | awk '{print $2}'
+ $ echo foo | blake3sum | xxd -cols 32 -g 32 | awk '{print $2}'
49dc870df1de7fd60794cebce449f5ccdae575affaa67a24b62acb03e039db92
but instead the Pijul authors have decided to base32-encode the bytes (without
padding).
- $ echo foo | b3sum | base32 | tr -d '='
+ $ echo foo | blake3sum | base32 | tr -d '='
JHOIODPR3Z75MB4UZ26OISPVZTNOK5NP7KTHUJFWFLFQHYBZ3OJA
-I believe that the encoding alphabet is actually the
-[Crockford](https://en.wikipedia.org/wiki/Base32#Crockford's_Base32) alphabet,
-but so far I've been able to decode hashes with the default alphabet.
+An additional feature is that hashed that are base32-encoded include a marker to
+indicate the hashing algorithm. At the moment the possible hashes are limited to
+two:
+
+ enum Hash {
+ None, // The hash of the "null change"
+ Blake3([u8; BLAKE3_BYTES]),
+ }
+
+The "null change" is essentially a "root commit" that kind of bootstraps the
+dependency graph. All other changes are hashed with blake3. To distinguish
+between the two in change files, the base32 encoding of hashes to the change
+file name appends a single byte to indicate the hash variant used. For the null
+change this is a zero byte, for blake3 it's a `1u8`. Generating the change file
+name ends up something like this:
+
+ $ BLAKE3_HASH="\x1"
+ $ echo -n "$(echo foo | blake3sum)${BLAKE3_HASH}" | base32 | tr -d '='
+ JHOIODPR3Z75MB4UZ26OISPVZTNOK5NP7KTHUJFWFLFQHYBZ3OJAC
+
+As a side effect all change files with blake3 hash end with the letter `C`.