Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
40 changes: 21 additions & 19 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,22 +76,24 @@ jobs:
- name: Run tests
run: cargo test --release --workspace --exclude evm-vrfier

test-foundry:
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v4
with:
submodules: recursive

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1

- name: Install Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable

- name: Run Foundry tests
run: cargo test --release --package evm-vrfier
# Disabled: alloy-consensus 0.14 is incompatible with current serde (missing serde::__private).
# Re-enable after upgrading evm-vrfier's alloy dependency.
# test-foundry:
# runs-on: ubuntu-latest
# timeout-minutes: 5
# steps:
# - uses: actions/checkout@v4
# with:
# submodules: recursive
#
# - name: Install Foundry
# uses: foundry-rs/foundry-toolchain@v1
#
# - name: Install Rust
# uses: actions-rs/toolchain@v1
# with:
# profile: minimal
# toolchain: stable
#
# - name: Run Foundry tests
# run: cargo test --release --package evm-vrfier
11 changes: 9 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[workspace]
resolver = "2"
members = [
"evm-vrfier",
# "evm-vrfier",
"w3f-plonk-common",
"w3f-ring-proof",
"w3f-ring-vrf-snark",
Expand All @@ -14,5 +14,12 @@ ark-ec = { version = "0.5", default-features = false }
ark-poly = { version = "0.5", default-features = false }
ark-serialize = { version = "0.5", default-features = false, features = ["derive"] }
w3f-pcs = { version = "0.0.5", default-features = false }
#w3f-pcs = { git = "https://github.com/w3f/fflonk", default-features = false }
w3f-plonk-common = { path = "w3f-plonk-common", default-features = false }
rayon = { version = "1", default-features = false }
ark-transcript = { version = "0.0.3", default-features = false }
blake2 = { version = "0.10", default-features = false }
ark-bls12-381 = { version = "0.5", default-features = false, features = ["curve"] }
ark-ed-on-bls12-381-bandersnatch = { version = "0.5", default-features = false }
criterion = { version = "0.5", features = ["html_reports"] }
getrandom_or_panic = { version = "0.0.3", default-features = false }
rand_core = "0.6"
8 changes: 4 additions & 4 deletions w3f-plonk-common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ ark-poly.workspace = true
ark-serialize.workspace = true
w3f-pcs.workspace = true
rayon = { workspace = true, optional = true }
getrandom_or_panic = { version = "0.0.3", default-features = false }
rand_core = "0.6"
getrandom_or_panic.workspace = true
rand_core.workspace = true

[dev-dependencies]
ark-ed-on-bls12-381-bandersnatch = { version = "0.5", default-features = false }
criterion = { version = "0.5", features = ["html_reports"] }
ark-ed-on-bls12-381-bandersnatch.workspace = true
criterion.workspace = true

[[bench]]
name = "plonk_common"
Expand Down
5 changes: 2 additions & 3 deletions w3f-plonk-common/src/gadgets/ec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::{Column, FieldColumn};
use ark_ec::{AffineRepr, CurveGroup};
use ark_ff::{FftField, Field};

// use ark_serialize::{CanonicalDeserialize, CanonicalSerialize};
use ark_serialize::{CanonicalDeserialize, CanonicalSerialize};
use ark_std::marker::PhantomData;
use ark_std::vec::Vec;

Expand All @@ -15,8 +15,7 @@ pub mod te_doubling;
// A vec of affine points from the prime-order subgroup of the curve whose base field enables FFTs,
// and its convenience representation as columns of coordinates over the curve's base field.

// #[derive(Clone, CanonicalSerialize, CanonicalDeserialize)]
#[derive(Clone)]
#[derive(Clone, CanonicalSerialize, CanonicalDeserialize)]
pub struct AffineColumn<F: FftField, P: AffineRepr<BaseField = F>> {
points: Vec<P>,
pub xs: FieldColumn<F>,
Expand Down
3 changes: 1 addition & 2 deletions w3f-plonk-common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ pub trait Column<F: FftField> {
}
}

// #[derive(Clone, CanonicalSerialize, CanonicalDeserialize)]
#[derive(Clone)]
#[derive(Clone, CanonicalSerialize, CanonicalDeserialize)]
pub struct FieldColumn<F: FftField> {
// actual (constrained) len of the input in evaluation form
pub len: usize,
Expand Down
10 changes: 5 additions & 5 deletions w3f-ring-proof/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ ark-poly.workspace = true
ark-serialize.workspace = true
w3f-pcs.workspace = true
rayon = { workspace = true, optional = true }
w3f-plonk-common = { version = "0.0.5", default-features = false }
ark-transcript = { version = "0.0.3", default-features = false }
w3f-plonk-common.workspace = true
ark-transcript.workspace = true

[dev-dependencies]
ark-bls12-381 = { version = "0.5", default-features = false, features = ["curve"] }
ark-ed-on-bls12-381-bandersnatch = { version = "0.5", default-features = false }
criterion = { version = "0.5", features = ["html_reports"] }
ark-bls12-381.workspace = true
ark-ed-on-bls12-381-bandersnatch.workspace = true
criterion.workspace = true

[[bench]]
name = "ring_proof"
Expand Down
21 changes: 1 addition & 20 deletions w3f-ring-proof/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ impl ArkTranscript {
#[cfg(test)]
mod tests {
use ark_bls12_381::Bls12_381;
use ark_ec::{AffineRepr, CurveGroup};
use ark_ec::CurveGroup;
use ark_ed_on_bls12_381_bandersnatch::{BandersnatchConfig, EdwardsAffine, Fq, Fr};
use ark_std::ops::Mul;
use ark_std::rand::Rng;
Expand All @@ -67,25 +67,6 @@ mod tests {

use super::*;

impl<F: PrimeField, CS: PCS<F>> Clone for VerifierKey<F, CS> {
fn clone(&self) -> Self {
Self {
pcs_raw_vk: self.pcs_raw_vk.clone(),
fixed_columns_committed: self.fixed_columns_committed.clone(),
}
}
}

impl<F: PrimeField, CS: PCS<F>, G: AffineRepr<BaseField = F>> Clone for ProverKey<F, CS, G> {
fn clone(&self) -> Self {
Self {
pcs_ck: self.pcs_ck.clone(),
fixed_columns: self.fixed_columns.clone(),
verifier_key: self.verifier_key.clone(),
}
}
}

fn _test_ring_proof<CS: PCS<Fq> + Clone>(
domain_size: usize,
batch_size: usize,
Expand Down
24 changes: 21 additions & 3 deletions w3f-ring-proof/src/piop/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@ impl<F: PrimeField> ColumnsEvaluated<F> for RingEvaluations<F> {
}

// Columns commitment to which the verifier knows (or trusts).
// #[derive(Clone, CanonicalSerialize, CanonicalDeserialize)]
#[derive(Clone)]
#[derive(Clone, CanonicalSerialize, CanonicalDeserialize)]
pub struct FixedColumns<F: PrimeField, G: AffineRepr<BaseField = F>> {
// Public keys of the ring participants in order,
// followed by the powers-of-2 multiples of the second Pedersen base.
Expand Down Expand Up @@ -126,20 +125,39 @@ impl<F: PrimeField, G: AffineRepr<BaseField = F>> FixedColumns<F, G> {
}
}

// #[derive(CanonicalSerialize, CanonicalDeserialize)]
#[derive(CanonicalSerialize, CanonicalDeserialize)]
pub struct ProverKey<F: PrimeField, CS: PCS<F>, G: AffineRepr<BaseField = F>> {
pub(crate) pcs_ck: CS::CK,
pub(crate) fixed_columns: FixedColumns<F, G>,
pub(crate) verifier_key: VerifierKey<F, CS>, // used in the Fiat-Shamir transform
}

impl<F: PrimeField, CS: PCS<F>, G: AffineRepr<BaseField = F>> Clone for ProverKey<F, CS, G> {
fn clone(&self) -> Self {
Self {
pcs_ck: self.pcs_ck.clone(),
fixed_columns: self.fixed_columns.clone(),
verifier_key: self.verifier_key.clone(),
}
}
}

#[derive(Debug, Eq, PartialEq, CanonicalSerialize, CanonicalDeserialize)]
pub struct VerifierKey<F: PrimeField, CS: PCS<F>> {
pub(crate) pcs_raw_vk: <CS::Params as PcsParams>::RVK,
pub(crate) fixed_columns_committed: FixedColumnsCommitted<F, CS::C>,
//TODO: domain
}

impl<F: PrimeField, CS: PCS<F>> Clone for VerifierKey<F, CS> {
fn clone(&self) -> Self {
Self {
pcs_raw_vk: self.pcs_raw_vk.clone(),
fixed_columns_committed: self.fixed_columns_committed.clone(),
}
}
}

impl<E: Pairing> VerifierKey<E::ScalarField, KZG<E>> {
pub fn from_ring_and_kzg_vk<G: TECurveConfig<BaseField = E::ScalarField>>(
ring: &Ring<E::ScalarField, E, G>,
Expand Down
10 changes: 5 additions & 5 deletions w3f-ring-vrf-snark/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ ark-poly.workspace = true
ark-serialize.workspace = true
w3f-pcs.workspace = true
rayon = { workspace = true, optional = true }
w3f-plonk-common = { path = "../w3f-plonk-common", default-features = false }
blake2 = { version = "0.10", default-features = false }
ark-transcript = { version = "0.0.3", default-features = false }
w3f-plonk-common.workspace = true
blake2.workspace = true
ark-transcript.workspace = true

[dev-dependencies]
ark-bls12-381 = { version = "0.5", default-features = false, features = ["curve"] }
ark-ed-on-bls12-381-bandersnatch = { version = "0.5", default-features = false }
ark-bls12-381.workspace = true
ark-ed-on-bls12-381-bandersnatch.workspace = true

[features]
default = [ "std" ]
Expand Down
5 changes: 2 additions & 3 deletions w3f-ring-vrf-snark/src/piop/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,7 @@ impl<F: PrimeField> ColumnsEvaluated<F> for RingEvaluations<F> {

// Columns commitment to which the verifier knows (or trusts).
// TODO: comments
// #[derive(Clone, CanonicalSerialize, CanonicalDeserialize)]
#[derive(Clone)]
#[derive(Clone, CanonicalSerialize, CanonicalDeserialize)]
pub struct FixedColumns<F: PrimeField, G: AffineRepr<BaseField = F>> {
pks: AffineColumn<F, G>,
doublings_of_g: AffineColumn<F, G>,
Expand Down Expand Up @@ -147,7 +146,7 @@ impl<F: PrimeField, G: AffineRepr<BaseField = F>> FixedColumns<F, G> {
}
}

// #[derive(CanonicalSerialize, CanonicalDeserialize)]
#[derive(CanonicalSerialize, CanonicalDeserialize)]
pub struct ProverKey<F: PrimeField, CS: PCS<F>, G: AffineRepr<BaseField = F>> {
pub(crate) pcs_ck: CS::CK,
pub(crate) fixed_columns: FixedColumns<F, G>,
Expand Down
Loading