Skip to content

Commit

Permalink
Update halo2curves version (#343)
Browse files Browse the repository at this point in the history
* upgrade halo2curves 0.7.0

* version 0.39.0

* simplify trait impl, with latest halo2curves

* export field and point types

* small cleanup

* update to the latest

* cargo fmt

* fix names

* fix hash
  • Loading branch information
srinathsetty authored Dec 30, 2024
1 parent 604399b commit e184658
Show file tree
Hide file tree
Showing 23 changed files with 112 additions and 267 deletions.
14 changes: 6 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "nova-snark"
version = "0.38.0"
version = "0.39.0"
authors = ["Srinath Setty <[email protected]>"]
edition = "2021"
description = "High-speed recursive arguments from folding schemes"
Expand All @@ -19,23 +19,21 @@ rayon = "1.10"
rand_core = { version = "0.6", default-features = false }
rand_chacha = "0.3"
subtle = "2.6.1"
pasta_curves = { version = "0.5", features = ["repr-c", "serde"] }
halo2curves = { version = "0.6.0", features = ["bits", "derive_serde"] }
halo2curves = { version = "0.8.0", features = ["bits", "derive_serde"] }
generic-array = "1.1"
num-bigint = { version = "0.4.6", features = ["serde", "rand"] }
num-traits = "0.2.19"
num-integer = "0.1.46"
serde = { version = "1.0.216", features = ["derive"] }
serde = { version = "1.0.217", features = ["derive"] }
bincode = "1.3"
bitvec = "1.0"
byteorder = "1.4.3"
thiserror = "2.0"
group = "0.13.0"
thiserror = "2.0.9"
once_cell = "1.18.0"
itertools = "0.13.0"

[target.'cfg(target_arch = "wasm32")'.dependencies]
getrandom = { version = "0.2", default-features = false, features = ["js"] }
getrandom = { version = "0.2.15", default-features = false, features = ["js"] }

[dev-dependencies]
criterion = { version = "0.5", features = ["html_reports"] }
Expand All @@ -46,7 +44,7 @@ cfg-if = "1.0.0"
sha2 = "0.10.7"
proptest = "1.6.0"
rand = "0.8.5"
expect-test = "1.5.0"
expect-test = "1.5.1"

[[bench]]
name = "recursive-snark"
Expand Down
5 changes: 1 addition & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,4 @@ This project may contain trademarks or logos for projects, products, or services
trademarks or logos is subject to and must follow
[Microsoft's Trademark & Brand Guidelines](https://www.microsoft.com/en-us/legal/intellectualproperty/trademarks/usage/general).
Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship.
Any use of third-party trademarks or logos are subject to those third-party's policies.

## Acknowledgments
See the contributors list [here](https://github.com/microsoft/Nova/graphs/contributors)
Any use of third-party trademarks or logos are subject to those third-party's policies.
3 changes: 1 addition & 2 deletions src/digest.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
use crate::constants::NUM_HASH_BITS;
use bincode::Options;
use ff::PrimeField;
use serde::Serialize;
use sha3::{Digest, Sha3_256};
use std::{io, marker::PhantomData};

use crate::constants::NUM_HASH_BITS;

/// Trait for components with potentially discrete digests to be included in their container's digest.
pub trait Digestible {
/// Write the byte representation of Self in a byte buffer
Expand Down
3 changes: 1 addition & 2 deletions src/errors.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
//! This module defines errors returned by the library.
use crate::frontend::SynthesisError;
use core::fmt::Debug;
use thiserror::Error;

use crate::frontend::SynthesisError;

/// Errors returned by Nova
#[derive(Clone, Debug, Eq, PartialEq, Error)]
#[non_exhaustive]
Expand Down
3 changes: 2 additions & 1 deletion src/gadgets/ecc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -787,13 +787,14 @@ mod tests {
},
provider::{
bn256_grumpkin::{bn256, grumpkin},
pasta::{pallas, vesta},
secp_secq::{secp256k1, secq256k1},
Bn256EngineKZG, GrumpkinEngine, PallasEngine, Secp256k1Engine, Secq256k1Engine, VestaEngine,
},
traits::snark::default_ck_hint,
};
use ff::{Field, PrimeFieldBits};
use pasta_curves::{arithmetic::CurveAffine, group::Curve, pallas, vesta};
use halo2curves::{group::Curve, CurveAffine};
use rand::rngs::OsRng;

#[derive(Debug, Clone)]
Expand Down
6 changes: 4 additions & 2 deletions src/gadgets/nonnative/bignat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -782,8 +782,10 @@ impl<Scalar: PrimeField> Polynomial<Scalar> {
#[cfg(test)]
mod tests {
use super::*;
use crate::frontend::{test_cs::TestConstraintSystem, Circuit};
use pasta_curves::pallas::Scalar;
use crate::{
frontend::{test_cs::TestConstraintSystem, Circuit},
provider::pasta::pallas::Scalar,
};
use proptest::prelude::*;

pub struct PolynomialMultiplier<Scalar: PrimeField> {
Expand Down
11 changes: 5 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,10 @@ pub mod provider;
pub mod spartan;
pub mod traits;

use once_cell::sync::OnceCell;

use crate::digest::{DigestComputer, SimpleDigestible};
use circuit::{NovaAugmentedCircuit, NovaAugmentedCircuitInputs, NovaAugmentedCircuitParams};
use constants::{BN_LIMB_WIDTH, BN_N_LIMBS, NUM_FE_WITHOUT_IO_FOR_CRHF, NUM_HASH_BITS};
use core::marker::PhantomData;
use digest::{DigestComputer, SimpleDigestible};
use errors::NovaError;
use ff::Field;
use frontend::{
Expand All @@ -41,6 +39,7 @@ use frontend::{
};
use gadgets::utils::scalar_as_base;
use nifs::{NIFSRelaxed, NIFS};
use once_cell::sync::OnceCell;
use r1cs::{
CommitmentKeyHint, R1CSInstance, R1CSShape, R1CSWitness, RelaxedR1CSInstance, RelaxedR1CSWitness,
};
Expand Down Expand Up @@ -1088,19 +1087,19 @@ mod tests {
test_pp_digest_with::<PallasEngine, VestaEngine, _, _>(
&TrivialCircuit::<_>::default(),
&TrivialCircuit::<_>::default(),
&expect!["ba7ff40bc60f95f7157350608b2f1892dc33b2470ccf52c3fae0464c61db9501"],
&expect!["b3da591d9a3c7dc2632e550e009f2b745d60cf919956cf02e9ca68e8e5e17603"],
);

test_pp_digest_with::<Bn256EngineIPA, GrumpkinEngine, _, _>(
&TrivialCircuit::<_>::default(),
&TrivialCircuit::<_>::default(),
&expect!["e0d75ecff901aee5b22223a4be82af30d7988a5f2cbd40815fda88dd79a22a01"],
&expect!["aaf1f0b723e281603838004327e73a02f3a2b5e2f2087e34b6f4f2c8f34e8401"],
);

test_pp_digest_with::<Secp256k1Engine, Secq256k1Engine, _, _>(
&TrivialCircuit::<_>::default(),
&TrivialCircuit::<_>::default(),
&expect!["ee4bd444ffe1f1be8224a09dae09bdf4532035655fd3f25e70955eaa13c48d03"],
&expect!["890b992d9c431625610659fe62b5c00859188e60802a5852cf5db0d10ca59403"],
);
}

Expand Down
1 change: 0 additions & 1 deletion src/nifs.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
//! This module implements a non-interactive folding scheme
#![allow(non_snake_case)]

use crate::{
constants::{NUM_CHALLENGE_BITS, NUM_FE_FOR_RO, NUM_FE_FOR_RO_RELAXED},
errors::NovaError,
Expand Down
20 changes: 10 additions & 10 deletions src/provider/bn256_grumpkin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ use crate::{
traits::{Group, PrimeFieldExt, TranscriptReprTrait},
};
use digest::{ExtendableOutput, Update};
use ff::{FromUniformBytes, PrimeField};
use group::{cofactor::CofactorCurveAffine, Curve, Group as AnotherGroup};
use num_bigint::BigInt;
use num_traits::Num;
// Remove this when https://github.com/zcash/pasta_curves/issues/41 resolves
use ff::FromUniformBytes;
use halo2curves::{
bn256::{pairing, G1Affine as Bn256Affine, G2Affine, G2Compressed, Gt, G1 as Bn256Point, G2},
bn256::{Bn256, G1Affine as Bn256Affine, G2Affine, G2Compressed, Gt, G1 as Bn256Point, G2},
group::{cofactor::CofactorCurveAffine, Curve, Group as AnotherGroup},
grumpkin::{G1Affine as GrumpkinAffine, G1 as GrumpkinPoint},
msm::best_multiexp,
msm::msm_best,
pairing::Engine as H2CEngine,
CurveAffine, CurveExt,
};
use pasta_curves::arithmetic::{CurveAffine, CurveExt};
use num_bigint::BigInt;
use num_traits::Num;
use rayon::prelude::*;
use sha3::Shake256;
use std::io::Read;
Expand Down Expand Up @@ -51,7 +51,7 @@ impl PairingGroup for Bn256Point {
type GT = Gt;

fn pairing(p: &Self, q: &Self::G2) -> Self::GT {
pairing(&p.affine(), &q.affine())
<Bn256 as H2CEngine>::pairing(&p.affine(), &q.affine())
}
}

Expand Down Expand Up @@ -81,7 +81,7 @@ impl DlogGroup for G2 {
type AffineGroupElement = G2Affine;

fn vartime_multiscalar_mul(scalars: &[Self::Scalar], bases: &[Self::AffineGroupElement]) -> Self {
best_multiexp(scalars, bases)
msm_best(scalars, bases)
}

fn affine(&self) -> Self::AffineGroupElement {
Expand Down
24 changes: 11 additions & 13 deletions src/provider/mod.rs
Original file line number Diff line number Diff line change
@@ -1,32 +1,30 @@
//! This module implements Nova's traits using the following several different combinations
// public modules to be used as an evaluation engine with Spartan
pub mod bn256_grumpkin;
pub mod hyperkzg;
pub mod ipa_pc;

// crate-public modules, made crate-public mostly for tests
pub(crate) mod bn256_grumpkin;
pub(crate) mod pasta;
pub(crate) mod pedersen;
pub mod pasta;
pub mod poseidon;
pub(crate) mod secp_secq;
pub(crate) mod traits;
pub mod secp_secq;

// crate-private modules
mod keccak;
pub(crate) mod keccak;
pub(crate) mod pedersen;
pub(crate) mod traits;

use crate::{
provider::{
bn256_grumpkin::{bn256, grumpkin},
hyperkzg::CommitmentEngine as HyperKZGCommitmentEngine,
keccak::Keccak256Transcript,
pasta::{pallas, vesta},
pedersen::CommitmentEngine as PedersenCommitmentEngine,
poseidon::{PoseidonRO, PoseidonROCircuit},
secp_secq::{secp256k1, secq256k1},
},
traits::Engine,
};
use pasta_curves::{pallas, vesta};
use serde::{Deserialize, Serialize};

/// An implementation of Nova traits with HyperKZG over the BN256 curve
Expand Down Expand Up @@ -129,11 +127,11 @@ impl Engine for VestaEngine {

#[cfg(test)]
mod tests {
use crate::provider::{bn256_grumpkin::bn256, secp_secq::secp256k1, traits::DlogGroup};
use crate::provider::{
bn256_grumpkin::bn256, pasta::pallas, secp_secq::secp256k1, traits::DlogGroup,
};
use digest::{ExtendableOutput, Update};
use group::Curve;
use halo2curves::CurveExt;
use pasta_curves::pallas;
use halo2curves::{group::Curve, CurveExt};
use sha3::Shake256;
use std::io::Read;

Expand Down
Loading

0 comments on commit e184658

Please sign in to comment.