Skip to content

Commit

Permalink
[chore] update rust toolchain to 1.76 nightly
Browse files Browse the repository at this point in the history
  • Loading branch information
lightsing committed Dec 4, 2023
1 parent ecd6757 commit b32c63c
Show file tree
Hide file tree
Showing 14 changed files with 1,149 additions and 612 deletions.
1,703 changes: 1,119 additions & 584 deletions Cargo.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ members = [
"snark-verifier",
"snark-verifier-sdk",
]
resolver = "2"

[profile.dev]
opt-level = 3
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain
Original file line number Diff line number Diff line change
@@ -1 +1 @@
nightly-2022-12-10
nightly-2023-12-03
3 changes: 1 addition & 2 deletions snark-verifier-sdk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ version = "0.0.1"
edition = "2021"

[dependencies]
itertools = "0.10.3"
lazy_static = "1.4.0"
itertools = "0.12"
num-bigint = "0.4.3"
num-integer = "0.1.45"
num-traits = "0.2.15"
Expand Down
4 changes: 2 additions & 2 deletions snark-verifier-sdk/src/aggregation.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#![allow(clippy::clone_on_copy)]
use crate::{
types::{BaseFieldEccChip, Halo2Loader, Plonk, PoseidonTranscript, POSEIDON_SPEC},
types::{BaseFieldEccChip, Halo2Loader, Plonk, PoseidonTranscript, get_poseidon_spec},
SnarkWitness,
};
#[cfg(feature = "display")]
Expand Down Expand Up @@ -94,7 +94,7 @@ where
let mut transcript = PoseidonTranscript::<Rc<Halo2Loader<'a>>, _>::from_spec(
loader,
Value::unknown(),
POSEIDON_SPEC.clone(),
get_poseidon_spec().clone(),
);

let mut accumulators = snarks
Expand Down
6 changes: 3 additions & 3 deletions snark-verifier-sdk/src/aggregation/aggregation_circuit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use crate::{
aggregation::{
aggregate,
config::{AggregationConfig, AggregationConfigParams},
flatten_accumulator, POSEIDON_SPEC,
flatten_accumulator, get_poseidon_spec,
},
types::{Halo2Loader, KzgAs, KzgBDFG, PoseidonTranscript, Shplonk, Svk},
CircuitExt, Snark, SnarkWitness, BITS, LIMBS,
Expand Down Expand Up @@ -54,7 +54,7 @@ impl AggregationCircuit {
// TODO: this is all redundant calculation to get the public output
// Halo2 should just be able to expose public output to instance column directly
let mut transcript_read =
PoseidonTranscript::<NativeLoader, &[u8]>::from_spec(&[], POSEIDON_SPEC.clone());
PoseidonTranscript::<NativeLoader, &[u8]>::from_spec(&[], get_poseidon_spec().clone());
let accumulators = snarks
.iter()
.flat_map(|snark| {
Expand All @@ -72,7 +72,7 @@ impl AggregationCircuit {
let (accumulator, as_proof) = {
let mut transcript_write = PoseidonTranscript::<NativeLoader, Vec<u8>>::from_spec(
vec![],
POSEIDON_SPEC.clone(),
get_poseidon_spec().clone(),
);
// We always use SHPLONK for accumulation scheme when aggregating proofs
let accumulator =
Expand Down
6 changes: 3 additions & 3 deletions snark-verifier-sdk/src/halo2_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use crate::{
circuit_ext::CircuitExt,
file_io::{read_pk, read_snark},
read_instances,
types::{PoseidonTranscript, POSEIDON_SPEC},
types::{PoseidonTranscript, get_poseidon_spec},
write_instances, Snark,
};

Expand All @@ -30,7 +30,7 @@ use halo2_base::halo2_proofs::{
VerificationStrategy,
},
transcript::TranscriptReadBuffer,
SerdeFormat, {self},
SerdeFormat,
};
use itertools::Itertools;
use rand::Rng;
Expand Down Expand Up @@ -125,7 +125,7 @@ where
let proof_time = start_timer!(|| "Create proof");

let mut transcript =
PoseidonTranscript::<NativeLoader, Vec<u8>>::from_spec(vec![], POSEIDON_SPEC.clone());
PoseidonTranscript::<NativeLoader, Vec<u8>>::from_spec(vec![], get_poseidon_spec().clone());
create_proof::<_, P, _, _, _, _>(params, pk, &[circuit], &[&instances], rng, &mut transcript)
.unwrap();
let proof = transcript.finalize();
Expand Down
7 changes: 4 additions & 3 deletions snark-verifier-sdk/src/types.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
//! This module concretize generic types with Bn256 curve and BDFG KZG scheme.

use std::sync::OnceLock;
use super::{BITS, LIMBS};
use halo2_base::halo2_proofs::halo2curves::bn256::{Bn256, Fr, G1Affine};
use lazy_static::lazy_static;
use snark_verifier::{
loader::halo2::{halo2_ecc::ecc::BaseFieldEccChip as EccChip, Halo2Loader as Loader},
pcs::kzg::{
Expand All @@ -13,8 +13,9 @@ use snark_verifier::{

use crate::param::{RATE, R_F, R_P, T};

lazy_static! {
pub static ref POSEIDON_SPEC: PoseidonSpec<Fr, T, RATE> = PoseidonSpec::new(R_F, R_P);
pub fn get_poseidon_spec() -> &'static PoseidonSpec<Fr, T, RATE> {
static POSEIDON_SPEC: OnceLock<PoseidonSpec<Fr, T, RATE>> = OnceLock::new();
POSEIDON_SPEC.get_or_init(|| PoseidonSpec::new(R_F, R_P))
}

/// Transcript instantiated with Poseidon
Expand Down
5 changes: 2 additions & 3 deletions snark-verifier/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ version = "0.1.0"
edition = "2021"

[dependencies]
itertools = "0.10.3"
lazy_static = "1.4.0"
itertools = "0.12"
num-bigint = "0.4.3"
num-integer = "0.1.45"
num-traits = "0.2.15"
Expand All @@ -21,7 +20,7 @@ poseidon-axiom = { git = "https://github.com/axiom-crypto/halo2.git", branch = "
poseidon= { git = "https://github.com/privacy-scaling-explorations/poseidon", optional = true }

# parallel
rayon = { version = "1.5.3", optional = true }
rayon = { version = "1.8", optional = true }

# loader_evm
ethereum-types = { version = "0.14", default-features = false, features = ["std"], optional = true }
Expand Down
1 change: 1 addition & 0 deletions snark-verifier/src/loader/halo2/shim.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ mod halo2_lib {
fields::FieldChip,
};
use std::ops::Deref;
use crate::util::arithmetic::PrimeField as _;

type AssignedInteger<C> = CRTInteger<<C as CurveAffine>::ScalarExt>;
type AssignedEcPoint<C> = EcPoint<<C as CurveAffine>::ScalarExt, AssignedInteger<C>>;
Expand Down
15 changes: 8 additions & 7 deletions snark-verifier/src/loader/native.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ use crate::{
util::arithmetic::{Curve, CurveAffine, FieldOps, PrimeField},
Error,
};
use lazy_static::lazy_static;
use std::fmt::Debug;
use std::sync::OnceLock;

lazy_static! {
/// NativeLoader instance for [`LoadedEcPoint::loader`] and
/// [`LoadedScalar::loader`] referencing.
pub static ref LOADER: NativeLoader = NativeLoader;
/// NativeLoader instance for [`LoadedEcPoint::loader`] and
/// [`LoadedScalar::loader`] referencing.
pub fn get_loader() -> &'static NativeLoader {
static LOADER: OnceLock<NativeLoader> = OnceLock::new();
LOADER.get_or_init(|| NativeLoader)
}

/// `Loader` implementation in native rust.
Expand All @@ -21,7 +22,7 @@ impl<C: CurveAffine> LoadedEcPoint<C> for C {
type Loader = NativeLoader;

fn loader(&self) -> &NativeLoader {
&LOADER
get_loader()
}
}

Expand All @@ -35,7 +36,7 @@ impl<F: PrimeField> LoadedScalar<F> for F {
type Loader = NativeLoader;

fn loader(&self) -> &NativeLoader {
&LOADER
get_loader()
}
}

Expand Down
4 changes: 2 additions & 2 deletions snark-verifier/src/system/halo2/transcript.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pub mod halo2;

impl<C: CurveAffine, R: Read> Transcript<C, NativeLoader> for Blake2bRead<R, C, Challenge255<C>> {
fn loader(&self) -> &NativeLoader {
&native::LOADER
native::get_loader()
}

fn squeeze_challenge(&mut self) -> C::Scalar {
Expand Down Expand Up @@ -56,7 +56,7 @@ impl<C: CurveAffine, R: Read> TranscriptRead<C, NativeLoader>

impl<C: CurveAffine, W: Write> Transcript<C, NativeLoader> for Blake2bWrite<W, C, Challenge255<C>> {
fn loader(&self) -> &NativeLoader {
&native::LOADER
native::get_loader()
}

fn squeeze_challenge(&mut self) -> C::Scalar {
Expand Down
2 changes: 1 addition & 1 deletion snark-verifier/src/system/halo2/transcript/evm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ where
C::Scalar: PrimeField<Repr = [u8; 0x20]>,
{
fn loader(&self) -> &NativeLoader {
&native::LOADER
native::get_loader()
}

fn squeeze_challenge(&mut self) -> C::Scalar {
Expand Down
2 changes: 1 addition & 1 deletion snark-verifier/src/system/halo2/transcript/halo2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ impl<C: CurveAffine, S, const T: usize, const RATE: usize, const R_F: usize, con
Transcript<C, NativeLoader> for PoseidonTranscript<C, NativeLoader, S, T, RATE, R_F, R_P>
{
fn loader(&self) -> &NativeLoader {
&native::LOADER
native::get_loader()
}

fn squeeze_challenge(&mut self) -> C::Scalar {
Expand Down

0 comments on commit b32c63c

Please sign in to comment.