A note on hashes

Posted on .

Quick note on hashes in Pijul.

All hashes in Pijul are blake3 which is a 32-byte hash. The default implementation of blake3 appears to be in Rust, but there’s a C implementation in the main tree which serves our purposes nicely.

A blake3 hash could be represented like this:

$ echo foo | blake3sum | xxd -cols 32 -g 32 | awk '{print $2}'

but instead the Pijul authors have decided to base32-encode the bytes (without padding).

$ echo foo | blake3sum | base32 | tr -d '='

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 '='

As a side effect all change files with blake3 hash end with the letter C.

Articles from blogs I follow around the net

In praise of Plan 9

Plan 9 is an operating system designed by Bell Labs. It’s the OS they wrote after Unix, with the benefit of hindsight. It is the most interesting operating system that you’ve never heard of, and, in my opinion, the best operating system design to date. Even …

via Drew DeVault's blog November 12, 2022

Making Hare more debuggable

Hare programs need to be easier to debug. This blog post outlines our plans for improving the situation. For a start, we’d like to implement the following features: Detailed backtraces Address sanitization New memory allocator DWARF support These are rou…

via Blogs on The Hare programming language November 4, 2022


the actual problem with bloat

via orib.dev September 26, 2022

Generated by openring