multihash icon indicating copy to clipboard operation
multihash copied to clipboard

Keyed hash functions (SipHash)

Open TotalKrill opened this issue 3 years ago • 1 comments

Basically, a widely used hash function ( at least internally in software ) is SipHash, which needs a key to produce an output is an hash function that produces small size hashes. Since it requires a key, the hash cannot be reproduced without it. The purpose of multihash is to be able to determine a way how to reproduce the given hash.

I have a use case that would require a hash-function that produces small digests ( ideally max 32bits ) for IoT usecases. And the end goal is to find stuff on IPFS, how could one go about to start supporting keyed hashes in multihash. Which would be a start to get IPFS support for this?

SipHash Wikipedia

TotalKrill avatar Apr 13 '22 15:04 TotalKrill

You could encode the key in the multihash itself, though that just defeats half of the purpose of SipHash (to prevent denial-of-service through hash collisions) AND would make the size bigger. Ignoring that purpose thing since it's not your point, you could encode the key in the DAG that it points to or perhaps specify a fixed key for your multicodec table entry.

Still I doubt 32 bits for content-addressable work is enough. To calculate SipHash you'd need a double-hash-size key anyways, so it's not like your embedded device is dealing with that much less data...

Artoria2e5 avatar Sep 21 '25 14:09 Artoria2e5