A CPU/GPU implemnetation of Merkle Tree with SHA-3 and Rescue hash functions (from scratch) with a verifier for the hashing process. Merkle Tree is popular in hashing distributed systems and/or databases.
A Merkle tree is a binary tree in which each leaf node contains a hash of a data block, and each internal node contains the hash of the concatenation of its children's hashes. The tree culminates in a single hash called the Merkle root, which provides a compact representation of the entire data set.
Given a set of
SHA-3, based on the Keccak algorithm, is a sponge-based cryptographic hash function standardized by NIST in 2015. It operates on a fixed-size internal state (1600 bits) divided into a bitrate
The core permutation function, Keccak-f[1600], consists of 24 rounds, each applying a sequence of transformations (\textit{theta}, \textit{rho}, \textit{pi}, \textit{chi}, and \textit{iota}) to the state array organized as a
SHA-3's post-quantum resistance stems from its output length: for a
Rescue is a cryptographic hash function designed specifically for zero-knowledge proof systems and post-quantum resistance. Unlike traditional bit-based constructions, Rescue operates over finite fields and is optimized for algebraic structures used in zk-SNARKs and other proof systems.
Rescue uses an SPN (Substitution-Permutation Network) structure composed of multiple rounds. Each round includes nonlinear S-boxes applied to state elements (typically raising each element to a power
For this project, Rescue is implemented over a prime field
Necessary packages can be installed via
pip install -r requirements.txt
This project was developed on Cuda 12 drivers and uses CuPy for the GPU implementation. The details regarding the miniconda environment can be found in conda.yaml file.
python main.py --data <List of strings to include in the Merkle Tree> --hash-function <SHA256, SHA3, Rescue> --print-tree --device <cpu, gpu>

