KZG Commitment Library
This repository contains a Rust implementation of KZG Commitments, a cryptographic primitive used for polynomial commitments. The library provides functionality to generate, commit, and verify polynomial commitments.
Blog post on implementing KZG commitment scheme You can find the python version of this code here
Features
- Vector to Polynomial: Convert a vector of elements to polynomial form.
- Polynomial Commitment: Commit to a polynomial
- Proof Generation: Generate a proof for a given set of points from the vector.
- Proof Verification: Verify the correctness of the proofs generated.
Installation
To use this library, add the following to your Cargo.toml
= "0.1.0"
Usage
Here is a basic example of how to use the library:
use KZGCommitment;
use ;
Testing
To run the tests, use the following command:
Example Tests
test_vec_to_poly: Tests the conversion of a vector to a polynomial and evaluates it at random points.test_verify_proof_valid: Tests the generation and verification of a valid proof.test_invalid_proof_generation: Tests the generation of an invalid proof and ensures the correct error is returned.test_invalid_proof_verification: Tests the verification of an invalid proof and ensures the correct error is returned.
TODO
- Use BigInt for vectors instead of i32
- Add support for precomputed powers_of_tau (trusted_setup)
- Add more tests for invalid proof verification
- Add benchmarks
Contributing
Contributions are welcome! Please open an issue or submit a pull request.
License
This project is licensed under the MIT License. See the LICENSE file for details.
Acknowledgements
KZG Commitments - More information about KZG Commitments.
This project was inspired by Dankrad Feist's blog post on KZG Commitments.