Add Grumpkin cycle implementation (#181)

* bn256+grumpkin from halo2curves

* chore: Integrate halo2curves more extensively

- Extend existing tests with additional test cases using the new curve types

* fix: Assign correct orders to bn256 and grumpkin scalar fields

- Swap scalar orders between grumpkin and bn256 in `impl_traits!` implementation

* test: Finish improving test integration with halo2curves

- Enhances test coverage for `pasta_curves` and `halo2curves`
- Cleans up commented code in `test_ivc_nontrivial` and `test_ivc_nontrivial_with_compression` tests
- Updates relevant test cases in `src/lib.rs` to include new curve tests

* chore: Remove commented-out/uneeded code in bn254_grumpkin.rs

* test: reproduce test_from_label for bn254_grumpkin

- Implement the `from_label_serial` function in bn254_grumpkin provider
- Add a test to compare parallel and serial implementations of `from_label` function

* refactor: Clean up to_coordinate & summarize changes

* refactor: rename bn254_grumpkin -> bn256_grumpkin

* test: Expand testing for public params digest using bn256 and grumpkin

* chore: Update halo2curves dependency in Cargo.toml

- Updated the `halo2curves` dependency in `Cargo.toml` to the latest version `0.1.0` from a specific git branch.

* refactor: Refactor multi-exponentiation methods across providers

- Updated bn256_grumpkin.rs to use the cpu_best_multiexp function from pasta provider instead of its native function.
- Modified visibility of cpu_best_multiexp function in pasta.rs from private to crate level.

* chore: set up dependencies to import the correct getrandom feature on Wasm

---------

Co-authored-by: Leo Alt <leo@ethereum.org>
This commit is contained in:
François Garillot
2023-07-05 19:10:05 -04:00
committed by GitHub
parent 905ec2d5a1
commit 4b077bcab1
12 changed files with 340 additions and 19 deletions

View File

@@ -754,6 +754,7 @@ mod tests {
r1cs::{NovaShape, NovaWitness},
{shape_cs::ShapeCS, solver::SatisfyingAssignment},
};
use crate::provider::bn256_grumpkin::{bn256, grumpkin};
use ff::{Field, PrimeFieldBits};
use pasta_curves::{arithmetic::CurveAffine, group::Curve, pallas, vesta};
use rand::rngs::OsRng;
@@ -768,7 +769,6 @@ mod tests {
is_infinity: bool,
}
#[cfg(test)]
impl<G> Point<G>
where
G: Group,
@@ -896,6 +896,9 @@ mod tests {
fn test_ecc_ops() {
test_ecc_ops_with::<pallas::Affine, pallas::Point>();
test_ecc_ops_with::<vesta::Affine, vesta::Point>();
test_ecc_ops_with::<bn256::Affine, bn256::Point>();
test_ecc_ops_with::<grumpkin::Affine, grumpkin::Point>();
}
fn test_ecc_ops_with<C, G>()
@@ -977,6 +980,9 @@ mod tests {
fn test_ecc_circuit_ops() {
test_ecc_circuit_ops_with::<pallas::Point, vesta::Point>();
test_ecc_circuit_ops_with::<vesta::Point, pallas::Point>();
test_ecc_circuit_ops_with::<bn256::Point, grumpkin::Point>();
test_ecc_circuit_ops_with::<grumpkin::Point, bn256::Point>();
}
fn test_ecc_circuit_ops_with<G1, G2>()
@@ -1027,6 +1033,9 @@ mod tests {
fn test_ecc_circuit_add_equal() {
test_ecc_circuit_add_equal_with::<pallas::Point, vesta::Point>();
test_ecc_circuit_add_equal_with::<vesta::Point, pallas::Point>();
test_ecc_circuit_add_equal_with::<bn256::Point, grumpkin::Point>();
test_ecc_circuit_add_equal_with::<grumpkin::Point, bn256::Point>();
}
fn test_ecc_circuit_add_equal_with<G1, G2>()
@@ -1081,6 +1090,9 @@ mod tests {
fn test_ecc_circuit_add_negation() {
test_ecc_circuit_add_negation_with::<pallas::Point, vesta::Point>();
test_ecc_circuit_add_negation_with::<vesta::Point, pallas::Point>();
test_ecc_circuit_add_negation_with::<bn256::Point, grumpkin::Point>();
test_ecc_circuit_add_negation_with::<grumpkin::Point, bn256::Point>();
}
fn test_ecc_circuit_add_negation_with<G1, G2>()