This repository constains the implementation of two Zero-Knowledge Proof (ZK) libraries for ZK-Friendly Hash Functions named zk-lib and zk-dusk, developed as part of the bachelor thesis. The libraries provides plain and zero-knowledge circuit implementation for various hash functions in the Polygon's Plonky2 and Dusk Plonk's Plonk proof systems for generating zero-knowledge proofs, in the Rust programming language.
Hash functions: MiMC, Poseidon, Rescue-prime, Griffin, Anemoi and Arion.
To use this library, ensure you satisfy one of the following prerequisites:
- Rust compiler with recent nightly toolchain. You can set up with the following command:
rustup override set nightly-YYYY-MM-DD
Make sure to replace YYYY-MM-DD with the appropriate date for your setup.
- Copy the rust-toolchain file in your project directory. It can be changed to a more recent nightly version.
- mimc-python:
- Implementation of the MiMC hash function Python, primarily used for testing purposes.
- zk-lib:
- Library containing implementation of the MiMC, Poseidon, Rescue-Prime, Griffin, Anemoi and Arion hash functions, as well as the zero-knowledge circuit for each one using Plonky2 as the proof system.
- Benchmarking of the hashes and the zero-knowledge circuit for each hash function.
- zk-dusk
- Library containing implementation of the MiMC, Poseidon, Rescue-Prime, Griffin, Anemoi and Arion hash functions, as well as the zero-knowledge circuit for each one using PLONK as the proof system.
- Benchmarking of the hashes and the zero-knowledge circuit for each hash function.
Measurements were conducted on a system configured with a 1.4 GHz Quad-Core Intel Core i5 processor, 8 GB LPDDR3 RAM with a transfer rate of 2133 MHz, and running macOS 14.5. The system was clocked at 1.4 GHz and utilized Rust’s Nightly build dated 2024-02-01. Benchmarking was performed using Criterion 0.5, with Plonky2 version 0.1.4 and dusk-plonk version 0.19.
![image](https://private-user-images.githubusercontent.com/125358906/336780127-712fa09f-aec0-4e71-93b3-8b3e0bc6950b.jpeg?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjU5NjY5MjIsIm5iZiI6MTcyNTk2NjYyMiwicGF0aCI6Ii8xMjUzNT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