Main Content

Hash Latch

Hash functions are used for lots of things. Like, verifying the data integrity, mining various cryptocurrencies, etc. I’ve found another application for them - serving as an integral part of the digital lock.

The hash latch generates keys in a manner similar to how some cryptocurrencies are mined. It takes a string and brute-forces a prefix for it so that the hash of the string with the prefix has a certain number of leading zeroes.

But that alone would’ve been too easy to hack.

To prevent an attacker from forging the keys by generating a new prefix: the hash latch doesn’t output the keys in the plaintext. Instead, it encrypts the key and outputs the ciphertext. That means that instead of giving you the actual key, it gives you a safe containing the key. This approach allows the hash latch to protect itself from forged keys and also enables you to put the same key into multiple safes without the recipients of these safes knowing they have the same key (even if they compare their ciphertexts).

Moreover, the hash latch verifies the integrity of a key after decrypting it (just in case).


- Teensy 4.1 x1
- 4.7k resistors x4
- 2.7k resistors x2
- 1k resistors x2
- 10k resistor x1
- Push buttons x2
- Green LED x1
- Red LED x1
- Servo motor x1
- USB port x1
- PS/2 port x1
- Either a USB keyboard, PS/2 keyboard, or an emulator of any of them x1”

Link to article