From 58986950fc61569b3db495d6d3de11070d8709d0 Mon Sep 17 00:00:00 2001 From: Davide Galassi Date: Wed, 10 Jul 2024 19:27:16 +0200 Subject: [PATCH 1/5] Pass by reference where allowed --- ring/src/lib.rs | 4 ++-- ring/src/piop/mod.rs | 4 ++-- ring/src/ring.rs | 12 ++++++------ 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/ring/src/lib.rs b/ring/src/lib.rs index 9b7ea69..d0fc804 100644 --- a/ring/src/lib.rs +++ b/ring/src/lib.rs @@ -74,7 +74,7 @@ mod tests { let k = rng.gen_range(0..keyset_size); // prover's secret index let pk = pks[k].clone(); - let (prover_key, verifier_key) = index::<_, CS, _>(pcs_params, &piop_params, pks); + let (prover_key, verifier_key) = index::<_, CS, _>(&pcs_params, &piop_params, &pks); // PROOF generation let secret = Fr::rand(rng); // prover's secret scalar @@ -104,7 +104,7 @@ mod tests { let keyset_size: usize = rng.gen_range(0..max_keyset_size); let pks = random_vec::(keyset_size, rng); - let (_, verifier_key) = index::<_, KZG::, _>(pcs_params, &piop_params, pks.clone()); + let (_, verifier_key) = index::<_, KZG::, _>(&pcs_params, &piop_params, &pks); let ring = Ring::<_, Bls12_381, _>::with_keys(&piop_params, &pks, &ring_builder_key); diff --git a/ring/src/piop/mod.rs b/ring/src/piop/mod.rs index 2916579..d9471a8 100644 --- a/ring/src/piop/mod.rs +++ b/ring/src/piop/mod.rs @@ -220,9 +220,9 @@ impl VerifierKey> { pub fn index, Curve: SWCurveConfig>( - pcs_params: CS::Params, + pcs_params: &CS::Params, piop_params: &PiopParams, - keys: Vec>, + keys: &[Affine], ) -> (ProverKey>, VerifierKey) { let pcs_ck = pcs_params.ck(); let pcs_raw_vk = pcs_params.raw_vk(); diff --git a/ring/src/ring.rs b/ring/src/ring.rs index e40ac7e..2e4dbd8 100644 --- a/ring/src/ring.rs +++ b/ring/src/ring.rs @@ -231,7 +231,7 @@ impl> RingBuilderKey(ring.max_keys, rng); ring.append(&keys, srs); - let (monimial_cx, monimial_cy) = get_monomial_commitment(pcs_params, &piop_params, keys.clone()); + let (monimial_cx, monimial_cy) = get_monomial_commitment(&pcs_params, &piop_params, &keys); assert_eq!(ring.cx, monimial_cx); assert_eq!(ring.cy, monimial_cy); @@ -298,9 +298,9 @@ mod tests { assert_eq!(ring, same_ring); } - fn get_monomial_commitment(pcs_params: URS, piop_params: &PiopParams, keys: Vec) -> (G1Affine, G1Affine) { - let (_, verifier_key) = crate::piop::index::<_, KZG::, _>(pcs_params, &piop_params, keys); + fn get_monomial_commitment(pcs_params: &URS, piop_params: &PiopParams, keys: &[SWAffine]) -> (G1Affine, G1Affine) { + let (_, verifier_key) = crate::piop::index::<_, KZG::, _>(pcs_params, piop_params, keys); let [monimial_cx, monimial_cy] = verifier_key.fixed_columns_committed.points; (monimial_cx.0, monimial_cy.0) } -} \ No newline at end of file +} From f1c89786a5cea34dee850956a57b8597992726e3 Mon Sep 17 00:00:00 2001 From: Davide Galassi Date: Wed, 10 Jul 2024 19:57:06 +0200 Subject: [PATCH 2/5] Re-export mandatory dependencies for downstream users --- ring/src/lib.rs | 6 ++++++ ring/src/ring_prover.rs | 1 - 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ring/src/lib.rs b/ring/src/lib.rs index d0fc804..aa4edaa 100644 --- a/ring/src/lib.rs +++ b/ring/src/lib.rs @@ -20,6 +20,12 @@ pub mod ring_verifier; pub type RingProof = Proof>::C>, RingEvaluations>; +// Crates that are required by the downstream dependencies. +pub mod prelude { + pub use fflonk; + pub use merlin; +} + // Calling the method for a prime-order curve results in an infinite loop. pub fn find_complement_point() -> Affine { let mut x = Curve::BaseField::zero(); diff --git a/ring/src/ring_prover.rs b/ring/src/ring_prover.rs index fa0a4c5..07159e7 100644 --- a/ring/src/ring_prover.rs +++ b/ring/src/ring_prover.rs @@ -12,7 +12,6 @@ pub struct RingProver, Curve: SWCurveConfig, fixed_columns: FixedColumns>, k: usize, - plonk_prover: PlonkProver, } From 4a133afc3d6963bec25b43b1852a5a537362d797 Mon Sep 17 00:00:00 2001 From: Davide Galassi Date: Wed, 10 Jul 2024 21:14:47 +0200 Subject: [PATCH 3/5] Propagate asm to ark-ff --- common/Cargo.toml | 23 ++++++++++++++++++++--- ring/Cargo.toml | 30 +++++++++++++++++++++++++++--- 2 files changed, 47 insertions(+), 6 deletions(-) diff --git a/common/Cargo.toml b/common/Cargo.toml index b63025b..5658a32 100644 --- a/common/Cargo.toml +++ b/common/Cargo.toml @@ -24,7 +24,24 @@ ark-ed-on-bls12-381-bandersnatch = { version = "0.4", default-features = false } [features] default = ["std"] -std = ["ark-std/std", "ark-ff/std", "ark-ec/std", "ark-poly/std", "ark-serialize/std", "fflonk/std", "merlin/std", "getrandom_or_panic/std"] -parallel = ["std", "rayon", "ark-std/parallel", "ark-ff/parallel", "ark-ec/parallel", "ark-poly/parallel"] +std = [ + "ark-std/std", + "ark-ff/std", + "ark-ec/std", + "ark-poly/std", + "ark-serialize/std", + "fflonk/std", + "merlin/std", + "getrandom_or_panic/std" +] +parallel = [ + "std", + "rayon", + "fflonk/parallel", + "ark-std/parallel", + "ark-ff/parallel", + "ark-ec/parallel", + "ark-poly/parallel" +] print-trace = ["ark-std/print-trace"] - +asm = ["fflonk/asm"] diff --git a/ring/Cargo.toml b/ring/Cargo.toml index 7869a0c..10639ed 100644 --- a/ring/Cargo.toml +++ b/ring/Cargo.toml @@ -26,6 +26,30 @@ ark-ed-on-bls12-381-bandersnatch = { version = "0.4", default-features = false } [features] default = [] -std = ["ark-std/std", "ark-ff/std", "ark-ec/std", "ark-poly/std", "ark-serialize/std", "merlin/std", "fflonk/std", "common/std"] -parallel = ["std", "rayon", "ark-std/parallel", "ark-ff/parallel", "ark-ec/parallel", "ark-poly/parallel", "common/parallel"] -print-trace = ["ark-std/print-trace", "common/print-trace"] +std = [ + "ark-std/std", + "ark-ff/std", + "ark-ec/std", + "ark-poly/std", + "ark-serialize/std", + "merlin/std", + "fflonk/std", + "common/std" +] +parallel = [ + "std", + "rayon", + "ark-std/parallel", + "ark-ff/parallel", + "ark-ec/parallel", + "ark-poly/parallel", + "common/parallel", + "fflonk/parallel" +] +print-trace = [ + "ark-std/print-trace", + "common/print-trace" +] +asm = [ + "fflonk/asm" +] From 41562a02537d4653aac8a010a545bae67bb36b7e Mon Sep 17 00:00:00 2001 From: Davide Galassi Date: Thu, 11 Jul 2024 19:31:37 +0200 Subject: [PATCH 4/5] Specify resolver to remove warnings --- Cargo.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/Cargo.toml b/Cargo.toml index d456b1a..8208299 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,4 +1,5 @@ [workspace] +resolver = "2" members = [ "common", "ring", From 613e1534bec3792c09bd7742f5f81ecb2802068b Mon Sep 17 00:00:00 2001 From: Davide Galassi Date: Tue, 23 Jul 2024 10:49:48 +0200 Subject: [PATCH 5/5] Fix re-exports --- ring/src/lib.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ring/src/lib.rs b/ring/src/lib.rs index aa4edaa..ba4a385 100644 --- a/ring/src/lib.rs +++ b/ring/src/lib.rs @@ -20,11 +20,11 @@ pub mod ring_verifier; pub type RingProof = Proof>::C>, RingEvaluations>; -// Crates that are required by the downstream dependencies. -pub mod prelude { - pub use fflonk; - pub use merlin; -} +/// Polynomial Commitment Schemes. +pub use fflonk::pcs; + +/// Transcript for `RingProver` and `RingVerifier` construction. +pub use merlin::Transcript; // Calling the method for a prime-order curve results in an infinite loop. pub fn find_complement_point() -> Affine {