Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
306fd69
simplify benches
zhenfeizhang May 16, 2025
5447786
wip
zhenfeizhang May 20, 2025
598d574
wip
zhenfeizhang May 20, 2025
86dbbd5
kzg batch verify works
zhenfeizhang May 20, 2025
f525e60
clean up
zhenfeizhang May 20, 2025
6cef0f8
bring back the tests
zhenfeizhang May 20, 2025
310683e
fmt
zhenfeizhang May 20, 2025
5bd3d3e
better API
zhenfeizhang May 20, 2025
c0b64ed
update gkr verifier
zhenfeizhang May 20, 2025
22d47da
clippy
zhenfeizhang May 20, 2025
19fdff9
wip
zhenfeizhang May 21, 2025
65b8778
hyrax batch opening now works properly
zhenfeizhang May 21, 2025
330425e
update bench
zhenfeizhang May 21, 2025
51474a7
cargo fmt
zhenfeizhang May 21, 2025
4b304fa
Merge branch 'main' into zz/defer_kzg_pairing_check
zhenfeizhang May 23, 2025
ab05261
Merge branch 'zz/defer_kzg_pairing_check' into zz/hyrax_batch_verify
zhenfeizhang May 24, 2025
0278307
ExpanderPCS api
zhenfeizhang May 27, 2025
a3e0063
impl batch opening for kzg
zhenfeizhang May 27, 2025
7cc57f8
clean up
zhenfeizhang May 27, 2025
231844d
add bench
zhenfeizhang May 27, 2025
606c9f6
fix warning
zhenfeizhang May 27, 2025
09fafa3
lint
zhenfeizhang May 27, 2025
46ba7dd
fix warnings
zhenfeizhang May 27, 2025
7d97254
refactor pcs trait
zhenfeizhang May 28, 2025
1cb3117
finally gets sumcheck correct
zhenfeizhang May 28, 2025
01c0b49
finished sumcheck
zhenfeizhang May 28, 2025
4624176
clean up generic sumcheck
zhenfeizhang May 28, 2025
aed30f2
wip
zhenfeizhang May 28, 2025
9979816
wip
zhenfeizhang May 28, 2025
1e67e25
wip
zhenfeizhang May 29, 2025
fa5cd00
degree 2 sumcheck
zhenfeizhang May 29, 2025
1c99242
works now!
zhenfeizhang May 29, 2025
e66e0ba
hyrax works properly now
zhenfeizhang May 29, 2025
83e8eb4
kzg works now
zhenfeizhang May 29, 2025
ff83111
fix ci
zhenfeizhang May 29, 2025
accad15
remove pairing accumulator
zhenfeizhang May 29, 2025
9b2aba8
clean up
zhenfeizhang May 29, 2025
fb3f5d6
Update test_kzg.rs
zhenfeizhang May 29, 2025
425eb5d
refactor hyrax
zhenfeizhang May 29, 2025
c38d5b3
fix
zhenfeizhang May 29, 2025
9c44e62
fix clippy
zhenfeizhang May 29, 2025
428567b
refactoring kzg
zhenfeizhang May 30, 2025
c9faa9d
wip
zhenfeizhang May 30, 2025
4be7c38
wip
zhenfeizhang May 30, 2025
7dde99c
wip
zhenfeizhang May 30, 2025
ebdb4e0
refactor bikzg and unikzg
zhenfeizhang May 30, 2025
8257bf5
performance tuning
zhenfeizhang May 30, 2025
9ec57e5
mirco benches
zhenfeizhang May 30, 2025
f72e2eb
performance tuning
zhenfeizhang May 30, 2025
a8ede0f
performance tuning
zhenfeizhang May 30, 2025
c733eb7
Merge branch 'main' into zz/hyrax_batch_verify
zhenfeizhang Jun 3, 2025
b74ed0f
fix after merge
zhenfeizhang Jun 3, 2025
1f0d4e6
fix tests
zhenfeizhang Jun 3, 2025
f1e9dc7
batch with variable length polys
zhenfeizhang Jun 4, 2025
22022d8
zz/whir api
zhenfeizhang Jun 10, 2025
834595f
fix bug with scratch pad
zhenfeizhang Jun 10, 2025
9035ab8
clean up
zhenfeizhang Jun 12, 2025
c52e7f9
Merge remote-tracking branch 'origin/main' into zz/whir_api
zhenfeizhang Jun 14, 2025
d3acbf8
fix clippy
zhenfeizhang Jun 14, 2025
e00e69e
clean up
zhenfeizhang Jun 14, 2025
6361e3f
clean up
zhenfeizhang Jun 14, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
912 changes: 683 additions & 229 deletions Cargo.lock

Large diffs are not rendered by default.

25 changes: 16 additions & 9 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,35 +25,42 @@ members = [
resolver = "2"

[workspace.dependencies]
ark-std = "0.4"
ark-bn254 = "0.4.0"
ark-ec = "0.4.0"
ark-ff = { version = "0.4" }
ark-std = { version = "0.5", features = ["std"] }
ark-bn254 = "0.5.0"
ark-ec = "0.5.0"
ark-ff = { version = "0.5", features = ["asm", "std"] }

bytes = "1.6.0"
chrono = "0.4.38"
clap = { version = "4.1", features = ["derive"] }
cfg-if = "1.0"
criterion = { version = "0.5", features = ["html_reports"] }
derivative = "2.2.0"
env_logger = "0.11.3"
ethnum = "1.5.0"
halo2curves = { git = "https://github.com/PolyhedraZK/halo2curves", default-features = false, features = [
"bits",
] }
syn = "2.0" # For parsing Rust code
spongefish = { git = "https://github.com/arkworks-rs/spongefish", features = [
"arkworks-algebra",
] }
spongefish-pow = { git = "https://github.com/arkworks-rs/spongefish" }
quote = "1.0" # For generating code
proc-macro2 = "1.0" # For working with tokens
itertools = "0.13"
log = "0.4"
mpi = "0.8.0"
rand = "0.8.5"
rand_chacha = "0.3.1"
raw-cpuid = "11.1.0"
rayon = "1.10"
sha2 = "0.10.8"
thiserror = "1.0.63"
tiny-keccak = { version = "2.0.2", features = [ "sha3", "keccak" ] }
tokio = { version = "1.38.0", features = ["full"] }
transpose = "0.2.3"
tynm = { version = "0.1.6", default-features = false }
warp = "0.3.7"
thiserror = "1.0.63"
ethnum = "1.5.0"
rand_chacha = "0.3.1"
derivative = "2.2.0"
transpose = "0.2.3"
# whir = { git = "https://github.com/WizardOfMenlo/whir", rev = "9d7a97b169542f8d0787db482ee58f7b9b660848" }
whir = { git = "https://github.com/zhenfeizhang/whir" }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Pinning the whir dependency to a specific commit hash or tag improves reproducibility and prevents unexpected changes from upstream.

2 changes: 2 additions & 0 deletions arith/goldilocks/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ edition = "2021"
arith = { path = ".." }
serdes = { path = "../../serdes" }

ark-ff.workspace = true
ark-std.workspace = true
ethnum.workspace = true
rand.workspace = true
whir.workspace = true

[[bench]]
name = "goldilocks"
Expand Down
33 changes: 33 additions & 0 deletions arith/goldilocks/src/goldilocks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ use std::{
};

use arith::{field_common, FFTField, Field, SimdField};
use ark_ff::{BigInteger64, PrimeField};
use ethnum::U256;
use rand::RngCore;
use serdes::{ExpSerde, SerdeResult};
use whir::crypto::fields::Field64;

use crate::goldilocks::p2_instructions::{assume, branch_hint, reduce128, try_inverse_u64};

Expand Down Expand Up @@ -603,3 +605,34 @@ pub(crate) mod p2_instructions {
// )
// }
}

impl From<Field64> for Goldilocks {
#[inline(always)]
fn from(x: Field64) -> Self {
Goldilocks {
v: x.into_bigint().0[0],
}
}
}

impl From<&Field64> for Goldilocks {
#[inline(always)]
fn from(x: &Field64) -> Self {
Goldilocks {
v: x.into_bigint().0[0],
}
}
}

impl From<Goldilocks> for Field64 {
#[inline(always)]
fn from(x: Goldilocks) -> Self {
Field64::from_bigint(BigInteger64::new([x.v])).unwrap()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Clarify the assumption that x.v is always a canonical Goldilocks field element to ensure from_bigint doesn't fail.

}
}
impl From<&Goldilocks> for Field64 {
#[inline(always)]
fn from(x: &Goldilocks) -> Self {
Field64::from_bigint(BigInteger64::new([x.v])).unwrap()
}
}
38 changes: 38 additions & 0 deletions arith/goldilocks/src/goldilocks_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use arith::{field_common, ExtensionField, FFTField, Field, SimdField};
use ethnum::U256;
use rand::RngCore;
use serdes::ExpSerde;
use whir::crypto::fields::Field64_2;

use crate::{
goldilocks::{mod_reduce_u64, Goldilocks},
Expand Down Expand Up @@ -412,3 +413,40 @@ impl Mul<Goldilocksx8> for GoldilocksExt2 {
}
}
}

impl From<Field64_2> for GoldilocksExt2 {
#[inline(always)]
fn from(x: Field64_2) -> Self {
GoldilocksExt2 {
v: [x.c0.into(), x.c1.into()],
}
}
}

impl From<&Field64_2> for GoldilocksExt2 {
#[inline(always)]
fn from(x: &Field64_2) -> Self {
GoldilocksExt2 {
v: [x.c0.into(), x.c1.into()],
}
}
}

impl From<GoldilocksExt2> for Field64_2 {
#[inline(always)]
fn from(x: GoldilocksExt2) -> Self {
Field64_2 {
c0: x.v[0].into(),
c1: x.v[1].into(),
}
}
}
impl From<&GoldilocksExt2> for Field64_2 {
#[inline(always)]
fn from(x: &GoldilocksExt2) -> Self {
Field64_2 {
c0: x.v[0].into(),
c1: x.v[1].into(),
}
}
}
32 changes: 32 additions & 0 deletions arith/goldilocks/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use ark_std::test_rng;
use ethnum::U256;
use rand::thread_rng;
use serdes::ExpSerde;
use whir::crypto::fields::{Field64, Field64_2};

use crate::{
goldilocks::mod_reduce_u64, Goldilocks, GoldilocksExt2, GoldilocksExt2x8, Goldilocksx8,
Expand Down Expand Up @@ -239,3 +240,34 @@ fn test_edge_cases() {
let x = GoldilocksExt2::X;
assert_eq!(x * x, GoldilocksExt2::from(Goldilocks::from(7u32)));
}

#[test]
fn convert_from_and_to_arkworks() {
let mut rng = thread_rng();

let one = Goldilocks::one();
let ark_one = Field64::from(1u32);

assert_eq!(one, Goldilocks::from(ark_one));
assert_eq!(Field64::from(one), ark_one);

for _ in 0..100 {
let x = Goldilocks::random_unsafe(&mut rng);
let ark_x = Field64::from(x);
assert_eq!(x, Goldilocks::from(ark_x));
assert_eq!(Field64::from(x), ark_x);
}

let one = GoldilocksExt2::one();
let ark_one = Field64_2::from(1u32);

assert_eq!(one, GoldilocksExt2::from(ark_one));
assert_eq!(Field64_2::from(one), ark_one);

for _ in 0..100 {
let x = GoldilocksExt2::random_unsafe(&mut rng);
let ark_x = Field64_2::from(x);
assert_eq!(x, GoldilocksExt2::from(ark_x));
assert_eq!(Field64_2::from(x), ark_x);
}
}
4 changes: 4 additions & 0 deletions poly_commit/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ edition = "2021"
arith = { path = "../arith" }
gf2 = { path = "../arith/gf2" }
gkr_engine = { path = "../gkr_engine" }
goldilocks = { path = "../arith/goldilocks" }
polynomials = { path = "../arith/polynomials"}
serdes = { path = "../serdes" }
transcript = { path = "../transcript" }
Expand All @@ -21,8 +22,11 @@ halo2curves.workspace = true
itertools.workspace = true
rand.workspace = true
rayon.workspace = true
spongefish.workspace = true
spongefish-pow.workspace = true
transpose.workspace = true
thiserror.workspace = true
whir.workspace = true

[dev-dependencies]
gf2_128 = { path = "../arith/gf2_128" }
Expand Down
5 changes: 3 additions & 2 deletions poly_commit/benches/hyrax.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ fn hyrax_opening_benchmark_helper(
let (srs, _) = HyraxPCS::<G1Affine>::gen_srs_for_testing(&num_vars, &mut rng);
let eval_point: Vec<_> = (0..num_vars).map(|_| Fr::random_unsafe(&mut rng)).collect();

let _ = HyraxPCS::<G1Affine>::commit(&num_vars, &srs, &poly, &mut scratch_pad);
let com = HyraxPCS::<G1Affine>::commit(&num_vars, &srs, &poly, &mut scratch_pad);

group
.bench_function(
Expand All @@ -73,10 +73,11 @@ fn hyrax_opening_benchmark_helper(
b.iter(|| {
_ = black_box(HyraxPCS::<G1Affine>::open(
&num_vars,
&com,
&srs,
&poly,
&eval_point,
&scratch_pad,
&mut scratch_pad,
&mut transcript,
))
})
Expand Down
5 changes: 3 additions & 2 deletions poly_commit/benches/kzg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ fn hyperkzg_opening_benchmark_helper(
let (srs, _) = HyperBiKZGPCS::<Bn256>::gen_srs_for_testing(&num_vars, &mut rng);
let eval_point: Vec<_> = (0..num_vars).map(|_| Fr::random_unsafe(&mut rng)).collect();

let _ = HyperBiKZGPCS::<Bn256>::commit(&num_vars, &srs, &poly, &mut scratch_pad);
let com = HyperBiKZGPCS::<Bn256>::commit(&num_vars, &srs, &poly, &mut scratch_pad);

group
.bench_function(
Expand All @@ -73,10 +73,11 @@ fn hyperkzg_opening_benchmark_helper(
b.iter(|| {
_ = black_box(HyperBiKZGPCS::<Bn256>::open(
&num_vars,
&com,
&srs,
&poly,
&eval_point,
&scratch_pad,
&mut scratch_pad,
&mut transcript,
))
})
Expand Down
Loading
Loading