Skip to content

Commit aa9d373

Browse files
committed
master merged
2 parents 2156172 + d2feffa commit aa9d373

32 files changed

+119
-104
lines changed

Cargo.toml

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
[workspace]
22
resolver = "2"
33
members = [
4-
"common",
5-
"ring",
4+
"w3f-plonk-common",
5+
"w3f-ring-proof",
66
]
77

88
[workspace.dependencies]
@@ -11,5 +11,5 @@ ark-ff = { version = "0.5", default-features = false }
1111
ark-ec = { version = "0.5", default-features = false }
1212
ark-poly = { version = "0.5", default-features = false }
1313
ark-serialize = { version = "0.5", default-features = false, features = ["derive"] }
14-
fflonk = { git = "https://github.com/w3f/fflonk", default-features = false }
14+
w3f-pcs = { version = "0.0.1", default-features = false }
1515
rayon = { version = "1", default-features = false }

LICENSE LICENSE-APACHE

File renamed without changes.

LICENSE-MIT

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 Web3 Foundation
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

+4-16
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,8 @@
1+
### The code has not been audited. Use on your own risk.
2+
13
## Contents
24

3-
* [`common`](common) provides infrastucture for creating plonk-like proofs.
4-
* [`ring`](ring) for a vector commitment to a list of public keys, and a Pedersen commitment to one of the secret keys,
5+
* [`w3f-plonk-common`](w3f-plonk-common) provides infrastructure for creating plonkish proofs.
6+
* [`w3f-ring-proof`](w3f-ring-proof) for a vector commitment to a list of public keys, and a Pedersen commitment to one of the secret keys,
57
implements a zk proof of knowledge of the blinding factor for the Pedersen commitment, and the position of the
68
corresponding public key in the list.
7-
8-
## TODOs
9-
10-
* Fix FiatShamir:
11-
- add instance to the transcript,
12-
- verifier uses Fiat-Shamir rng to batch verify the pairings,
13-
- remove test_rng from not_test,
14-
* Verifier evaluates selectors efficiently
15-
* Find points from the prime-subgroup complements to seed the acc. How should it be encapsulated?
16-
* Check paddings for the precommitted columns
17-
* Refactor common/piop.rs to have types shared between prover nad verifier
18-
* Add zk
19-
* Batch verification
20-
* Batch proving

common/Cargo.toml w3f-plonk-common/Cargo.toml

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
2-
name = "common"
3-
version = "0.1.0"
2+
name = "w3f-plonk-common"
3+
version = "0.0.1"
44
edition = "2021"
55
authors = ["Sergey Vasilyev <[email protected]>"]
66
license = "MIT/Apache-2.0"
@@ -13,7 +13,7 @@ ark-ff.workspace = true
1313
ark-ec.workspace = true
1414
ark-poly.workspace = true
1515
ark-serialize.workspace = true
16-
fflonk.workspace = true
16+
w3f-pcs.workspace = true
1717
rayon = { workspace = true, optional = true }
1818
getrandom_or_panic = { version = "0.0.3", default-features = false }
1919
rand_core = "0.6"
@@ -29,18 +29,18 @@ std = [
2929
"ark-ec/std",
3030
"ark-poly/std",
3131
"ark-serialize/std",
32-
"fflonk/std",
32+
"w3f-pcs/std",
3333
"getrandom_or_panic/std",
34-
"rand_core/std"
34+
"rand_core/std",
3535
]
3636
parallel = [
3737
"std",
3838
"rayon",
39-
"fflonk/parallel",
4039
"ark-std/parallel",
4140
"ark-ff/parallel",
4241
"ark-ec/parallel",
43-
"ark-poly/parallel"
42+
"ark-poly/parallel",
43+
"w3f-pcs/parallel",
4444
]
4545
print-trace = ["ark-std/print-trace"]
46-
asm = ["fflonk/asm"]
46+
asm = ["w3f-pcs/asm"]

w3f-plonk-common/README.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
### The code has not been audited. Use on your own risk.
2+
3+
Infrastructure for creating plonkish proofs.
File renamed without changes.
File renamed without changes.
File renamed without changes.

common/src/gadgets/ec/sw_cond_add.rs w3f-plonk-common/src/gadgets/ec/sw_cond_add.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -198,4 +198,4 @@ mod tests {
198198
_test_sw_cond_add_gadget(false);
199199
_test_sw_cond_add_gadget(true);
200200
}
201-
}
201+
}
File renamed without changes.
File renamed without changes.
File renamed without changes.

common/src/lib.rs w3f-plonk-common/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use ark_poly::univariate::DensePolynomial;
55
use ark_poly::{EvaluationDomain, Evaluations, GeneralEvaluationDomain, Polynomial};
66
use ark_serialize::{CanonicalDeserialize, CanonicalSerialize};
77
use ark_std::{vec, vec::Vec};
8-
use fflonk::pcs::{Commitment, PCS};
8+
use w3f_pcs::pcs::{Commitment, PCS};
99

1010
pub mod domain;
1111
pub mod gadgets;

common/src/piop.rs w3f-plonk-common/src/piop.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use ark_poly::univariate::DensePolynomial;
33
use ark_poly::Evaluations;
44
use ark_serialize::{CanonicalDeserialize, CanonicalSerialize};
55
use ark_std::vec::Vec;
6-
use fflonk::pcs::Commitment;
6+
use w3f_pcs::pcs::Commitment;
77

88
use crate::domain::{Domain, EvaluatedDomain};
99
use crate::{ColumnsCommited, ColumnsEvaluated};

common/src/prover.rs w3f-plonk-common/src/prover.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ use ark_ff::PrimeField;
22
use ark_poly::{Evaluations, Polynomial};
33
use ark_serialize::CanonicalSerialize;
44
use ark_std::vec;
5-
use fflonk::aggregation::single::aggregate_polys;
6-
use fflonk::pcs::PCS;
5+
use w3f_pcs::aggregation::single::aggregate_polys;
6+
use w3f_pcs::pcs::PCS;
77

88
use crate::piop::ProverPiop;
99
use crate::transcript::PlonkTranscript;

common/src/setup.rs w3f-plonk-common/src/setup.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use ark_ff::PrimeField;
22
use ark_poly::{EvaluationDomain, GeneralEvaluationDomain};
33
use ark_std::rand::Rng;
4-
use fflonk::pcs::{PCS, PcsParams};
4+
use w3f_pcs::pcs::{PCS, PcsParams};
55

66
use crate::{Column, FieldColumn};
77

File renamed without changes.

common/src/transcript.rs w3f-plonk-common/src/transcript.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use ark_ff::PrimeField;
22
use ark_poly::GeneralEvaluationDomain;
33
use ark_serialize::CanonicalSerialize;
44
use ark_std::vec::Vec;
5-
use fflonk::pcs::{PcsParams, PCS};
5+
use w3f_pcs::pcs::{PcsParams, PCS};
66
use rand_core::RngCore;
77

88
use crate::{ColumnsCommited, ColumnsEvaluated};

common/src/verifier.rs w3f-plonk-common/src/verifier.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use ark_ff::{Field, PrimeField};
22
use ark_serialize::CanonicalSerialize;
33
use ark_std::rand::Rng;
44
use ark_std::{vec, vec::Vec};
5-
use fflonk::pcs::{Commitment, PcsParams, PCS};
5+
use w3f_pcs::pcs::{Commitment, PcsParams, PCS};
66
use rand_core::RngCore;
77

88
use crate::piop::VerifierPiop;

ring/Cargo.toml w3f-ring-proof/Cargo.toml

+11-11
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
2-
name = "ring"
3-
version = "0.1.0"
2+
name = "w3f-ring-proof"
3+
version = "0.0.1"
44
edition = "2021"
55
authors = ["Sergey Vasilyev <[email protected]>"]
66
license = "MIT/Apache-2.0"
@@ -13,11 +13,11 @@ ark-ff.workspace = true
1313
ark-ec.workspace = true
1414
ark-poly.workspace = true
1515
ark-serialize.workspace = true
16-
fflonk.workspace = true
16+
w3f-pcs.workspace = true
1717
rayon = { workspace = true, optional = true }
18-
common = { path = "../common", default-features = false }
18+
w3f-plonk-common = { path="../w3f-plonk-common", default-features = false }
1919
blake2 = { version = "0.10", default-features = false }
20-
ark-transcript = { git = "https://github.com/w3f/ark-transcript", default-features = false }
20+
ark-transcript = { version = "0.0.3", default-features = false }
2121

2222
[dev-dependencies]
2323
ark-bls12-381 = { version = "0.5", default-features = false, features = ["curve"] }
@@ -31,8 +31,8 @@ std = [
3131
"ark-ec/std",
3232
"ark-poly/std",
3333
"ark-serialize/std",
34-
"fflonk/std",
35-
"common/std"
34+
"w3f-pcs/std",
35+
"w3f-plonk-common/std"
3636
]
3737
parallel = [
3838
"std",
@@ -41,11 +41,11 @@ parallel = [
4141
"ark-ff/parallel",
4242
"ark-ec/parallel",
4343
"ark-poly/parallel",
44-
"common/parallel",
45-
"fflonk/parallel"
44+
"w3f-plonk-common/parallel",
45+
"w3f-pcs/parallel"
4646
]
4747
print-trace = [
4848
"ark-std/print-trace",
49-
"common/print-trace"
49+
"w3f-plonk-common/print-trace"
5050
]
51-
asm = [ "fflonk/asm" ]
51+
asm = [ "w3f-pcs/asm" ]

w3f-ring-proof/README.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
### The code has not been audited. Use on your own risk.
2+
3+
For a vector commitment to a list of public keys, and a Pedersen commitment to one of the secret keys, implements a zk proof of knowledge of the blinding factor for the Pedersen commitment, and the position of the corresponding public key in the list.

ring/src/lib.rs w3f-ring-proof/src/lib.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ use ark_ec::{
77
use ark_ff::{One, PrimeField, Zero};
88
use ark_serialize::CanonicalSerialize;
99
use ark_std::rand::RngCore;
10-
use fflonk::pcs::PCS;
10+
use w3f_pcs::pcs::PCS;
1111

12-
pub use common::domain::Domain;
13-
use common::Proof;
12+
pub use w3f_plonk_common::domain::Domain;
13+
use w3f_plonk_common::Proof;
1414
pub use piop::index;
1515

1616
pub use crate::piop::{params::PiopParams, FixedColumnsCommitted, ProverKey, VerifierKey};
@@ -24,7 +24,7 @@ pub mod ring_verifier;
2424
pub type RingProof<F, CS> = Proof<F, CS, RingCommitments<F, <CS as PCS<F>>::C>, RingEvaluations<F>>;
2525

2626
/// Polynomial Commitment Schemes.
27-
pub use fflonk::pcs;
27+
pub use w3f_pcs::pcs;
2828

2929
// Calling the method for a prime-order curve results in an infinite loop.
3030
pub fn find_complement_point<Curve: SWCurveConfig>() -> Affine<Curve> {
@@ -61,7 +61,7 @@ pub(crate) fn hash_to_curve<F: PrimeField, Curve: SWCurveConfig<BaseField = F>>(
6161
#[derive(Clone)]
6262
pub struct ArkTranscript(ark_transcript::Transcript);
6363

64-
impl<F: PrimeField, CS: PCS<F>> common::transcript::PlonkTranscript<F, CS> for ArkTranscript {
64+
impl<F: PrimeField, CS: PCS<F>> w3f_plonk_common::transcript::PlonkTranscript<F, CS> for ArkTranscript {
6565
fn _128_bit_point(&mut self, label: &'static [u8]) -> F {
6666
self.0.challenge(label).read_reduce()
6767
}
@@ -91,9 +91,9 @@ mod tests {
9191
use ark_std::ops::Mul;
9292
use ark_std::rand::Rng;
9393
use ark_std::{end_timer, start_timer, test_rng, UniformRand};
94-
use fflonk::pcs::kzg::KZG;
94+
use w3f_pcs::pcs::kzg::KZG;
9595

96-
use common::test_helpers::random_vec;
96+
use w3f_plonk_common::test_helpers::random_vec;
9797

9898
use crate::piop::FixedColumnsCommitted;
9999
use crate::ring::{Ring, RingBuilderKey};
@@ -122,7 +122,7 @@ mod tests {
122122
prover_key,
123123
piop_params.clone(),
124124
k,
125-
ArkTranscript::new(b"ring-vrf-test"),
125+
ArkTranscript::new(b"w3f-ring-proof-test"),
126126
);
127127
let t_prove = start_timer!(|| "Prove");
128128
let proof = ring_prover.prove(secret);
@@ -131,7 +131,7 @@ mod tests {
131131
let ring_verifier = RingVerifier::init(
132132
verifier_key,
133133
piop_params,
134-
ArkTranscript::new(b"ring-vrf-test"),
134+
ArkTranscript::new(b"w3f-ring-proof-test"),
135135
);
136136
let t_verify = start_timer!(|| "Verify");
137137
let res = ring_verifier.verify_ring_proof(proof, result.into_affine());
@@ -201,6 +201,6 @@ mod tests {
201201

202202
#[test]
203203
fn test_ring_proof_id() {
204-
_test_ring_proof::<fflonk::pcs::IdentityCommitment>(2usize.pow(10));
204+
_test_ring_proof::<w3f_pcs::pcs::IdentityCommitment>(2usize.pow(10));
205205
}
206206
}

ring/src/piop/mod.rs w3f-ring-proof/src/piop/mod.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ use ark_ff::PrimeField;
55
use ark_serialize::{CanonicalDeserialize, CanonicalSerialize};
66
use ark_std::marker::PhantomData;
77
use ark_std::{vec, vec::Vec};
8-
use fflonk::pcs::kzg::commitment::KzgCommitment;
9-
use fflonk::pcs::kzg::params::RawKzgVerifierKey;
10-
use fflonk::pcs::kzg::KZG;
11-
use fflonk::pcs::{Commitment, PcsParams, PCS};
8+
use w3f_pcs::pcs::kzg::commitment::KzgCommitment;
9+
use w3f_pcs::pcs::kzg::params::RawKzgVerifierKey;
10+
use w3f_pcs::pcs::kzg::KZG;
11+
use w3f_pcs::pcs::{Commitment, PcsParams, PCS};
1212

13-
use common::gadgets::ec::AffineColumn;
14-
use common::{Column, ColumnsCommited, ColumnsEvaluated, FieldColumn};
13+
use w3f_plonk_common::gadgets::ec::AffineColumn;
14+
use w3f_plonk_common::{Column, ColumnsCommited, ColumnsEvaluated, FieldColumn};
1515
pub(crate) use prover::PiopProver;
1616
pub(crate) use verifier::PiopVerifier;
1717

@@ -82,8 +82,8 @@ pub struct FixedColumns<F: PrimeField, G: AffineRepr<BaseField = F>> {
8282
#[derive(Clone, CanonicalSerialize, CanonicalDeserialize, PartialEq, Eq, Debug)]
8383
pub struct FixedColumnsCommitted<F: PrimeField, C: Commitment<F>> {
8484
pub points: [C; 2],
85-
ring_selector: C,
86-
phantom: PhantomData<F>,
85+
pub ring_selector: C,
86+
pub phantom: PhantomData<F>,
8787
}
8888

8989
impl<F: PrimeField, C: Commitment<F>> FixedColumnsCommitted<F, C> {

ring/src/piop/params.rs w3f-ring-proof/src/piop/params.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ use ark_ec::{AdditiveGroup, AffineRepr, CurveGroup};
33
use ark_ff::{BigInteger, PrimeField};
44
use ark_std::{vec, vec::Vec};
55

6-
use common::domain::Domain;
7-
use common::gadgets::ec::AffineColumn;
6+
use w3f_plonk_common::domain::Domain;
7+
use w3f_plonk_common::gadgets::ec::AffineColumn;
88

99
use crate::piop::FixedColumns;
1010

@@ -32,7 +32,7 @@ pub struct PiopParams<F: PrimeField, Curve: SWCurveConfig<BaseField = F>> {
3232

3333
impl<F: PrimeField, Curve: SWCurveConfig<BaseField = F>> PiopParams<F, Curve> {
3434
pub fn setup(domain: Domain<F>, h: Affine<Curve>, seed: Affine<Curve>) -> Self {
35-
let padding_point = crate::hash_to_curve(b"/w3f/ring-proof/padding");
35+
let padding_point = crate::hash_to_curve(b"/w3f/w3f-ring-proof/padding");
3636
let scalar_bitlen = Curve::ScalarField::MODULUS_BIT_SIZE as usize;
3737
// 1 accounts for the last cells of the points and bits columns that remain unconstrained
3838
let keyset_part_size = domain.capacity - scalar_bitlen - 1;
@@ -97,8 +97,8 @@ mod tests {
9797
use ark_std::ops::Mul;
9898
use ark_std::{test_rng, UniformRand};
9999

100-
use common::domain::Domain;
101-
use common::test_helpers::cond_sum;
100+
use w3f_plonk_common::domain::Domain;
101+
use w3f_plonk_common::test_helpers::cond_sum;
102102

103103
use crate::piop::params::PiopParams;
104104

ring/src/piop/prover.rs w3f-ring-proof/src/piop/prover.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,20 @@ use ark_poly::univariate::DensePolynomial;
44
use ark_poly::Evaluations;
55
use ark_std::marker::PhantomData;
66
use ark_std::{vec, vec::Vec};
7-
use fflonk::pcs::Commitment;
7+
use w3f_pcs::pcs::Commitment;
88

99
use crate::piop::params::PiopParams;
1010
use crate::piop::FixedColumns;
1111
use crate::piop::{RingCommitments, RingEvaluations};
12-
use common::domain::Domain;
13-
use common::gadgets::booleanity::{BitColumn, Booleanity};
14-
use common::gadgets::ec::AffineColumn;
15-
use common::gadgets::ec::CondAdd;
16-
use common::gadgets::fixed_cells::FixedCells;
17-
use common::gadgets::inner_prod::InnerProd;
18-
use common::gadgets::ProverGadget;
19-
use common::piop::ProverPiop;
20-
use common::{Column, FieldColumn};
12+
use w3f_plonk_common::domain::Domain;
13+
use w3f_plonk_common::gadgets::booleanity::{BitColumn, Booleanity};
14+
use w3f_plonk_common::gadgets::ec::AffineColumn;
15+
use w3f_plonk_common::gadgets::ec::CondAdd;
16+
use w3f_plonk_common::gadgets::fixed_cells::FixedCells;
17+
use w3f_plonk_common::gadgets::inner_prod::InnerProd;
18+
use w3f_plonk_common::gadgets::ProverGadget;
19+
use w3f_plonk_common::piop::ProverPiop;
20+
use w3f_plonk_common::{Column, FieldColumn};
2121

2222
// The 'table': columns representing the execution trace of the computation
2323
// and the constraints -- polynomials that vanish on every 2 consecutive rows.

0 commit comments

Comments
 (0)