BLAKE3 in 6502 assembly
February 12, 2022 · View on GitHub
BLAKE3 is a cryptographic hash function. The MOS
6502 is the classic
8-bit microprocessor that powered the Apple II, the
Commodore 64, and the NES console. This implementation of BLAKE3
runs on Ben Eater's 6502 breadboard computer.
Source code is in rom.s.
This program loops over the BLAKE3 test
vectors
and hashes each one. Then it hashes a couple more inputs, including the
one shown in the photo above, 1 MB of all zeros. This is larger
than the 6502's 64 KiB of addressable memory, and with a 1 MHz
clock it takes 17.7 minutes. You can reproduce the same result with
b3sum in
the terminal:
$ head -c 1000000 /dev/zero | b3sum --length=8
c211bb2e5afbd0ef -
You can also run this program in the terminal with make emulate. This
requires Rust and Cargo. The emulator is based on
the emulator_6502
Rust crate by Garett Cooper.