Why are DNA hashes padded by a "u"?

Hello folks,

writing the TS version of the hApp client call tutorial, I was struggling with encoding the DNA hash for the Cell ID. The DNA and PubAgentKey hashes were both prepended with a “u”, and the reason for that was not obvious to me.

I looked through the Rust code to see if this was documented anywhere, and asked @Connoropolous about it too. That only turned up a comment that indicates the pad is needed.

Does anyone know why there is this pad?

1 Like

It occurs to me that we can check git history to know who wrote the line of code. I think I know

We’re just trying to make sure Holochain addresses can be easily interpreted and understood by other applications out there. To do that we’re following the Multihash Multiformat standards.

u = unsigned integer

The hC[x] part that follows are prefixes we have registered in the Multihash table so people know to intepret these as Holochain compatible hashes using the Blake2b hashing algorithm.


Thanks @artbrock !
The u is related to multiformat spec, for ‘unsigned integer’ then?

1 Like

Thank you @Connoropolous and @artbrock. So there is a purpose behind it. And quite an interesting one - “self-identifying hashes”. Yeah, I had also wondered what kind of hashing algorithm is used, and I can find out looking in the code/docs. But knowing about the existence of a multihash protocol, there’s a table for that.

@Connoropolous If I understand it correctly, then it’s this unsigned varint.

1 Like

After a long time I have got a simple answer to my question:
The u stands for base64url according to the multibase protocol, which is the URL and file name safe version of Base64, and is needed when handling Base64 encoded hashes.

Byte hashes must not be prefixed with u.

All about hashes in the docs now: