Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Take references where allowed and re-exports #25

Merged
merged 5 commits into from
Jul 23, 2024
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
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[workspace]
resolver = "2"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Apparently not when you use a workspace:

warning: virtual workspace defaulting to `resolver = "1"` despite one or more workspace members being on edition 2021 which implies `resolver
 = "2"`
note: to keep the current resolver, specify `workspace.resolver = "1"` in the workspace root's manifest
note: to use the edition 2021 resolver, specify `workspace.resolver = "2"` in the workspace root's manifest
note: for more details see https://doc.rust-lang.org/cargo/reference/resolver.html#resolver-versions

members = [
"common",
"ring",
Expand Down
23 changes: 20 additions & 3 deletions common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
30 changes: 27 additions & 3 deletions ring/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
10 changes: 8 additions & 2 deletions ring/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ pub mod ring_verifier;

pub type RingProof<F, CS> = Proof<F, CS, RingCommitments<F, <CS as PCS<F>>::C>, RingEvaluations<F>>;

/// 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<Curve: SWCurveConfig>() -> Affine<Curve> {
let mut x = Curve::BaseField::zero();
Expand Down Expand Up @@ -74,7 +80,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
Expand Down Expand Up @@ -104,7 +110,7 @@ mod tests {
let keyset_size: usize = rng.gen_range(0..max_keyset_size);
let pks = random_vec::<SWAffine, _>(keyset_size, rng);

let (_, verifier_key) = index::<_, KZG::<Bls12_381>, _>(pcs_params, &piop_params, pks.clone());
let (_, verifier_key) = index::<_, KZG::<Bls12_381>, _>(&pcs_params, &piop_params, &pks);

let ring = Ring::<_, Bls12_381, _>::with_keys(&piop_params, &pks, &ring_builder_key);

Expand Down
4 changes: 2 additions & 2 deletions ring/src/piop/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,9 +220,9 @@ impl<E: Pairing> VerifierKey<E::ScalarField, KZG<E>> {


pub fn index<F: PrimeField, CS: PCS<F>, Curve: SWCurveConfig<BaseField=F>>(
pcs_params: CS::Params,
pcs_params: &CS::Params,
piop_params: &PiopParams<F, Curve>,
keys: Vec<Affine<Curve>>,
keys: &[Affine<Curve>],
) -> (ProverKey<F, CS, Affine<Curve>>, VerifierKey<F, CS>) {
let pcs_ck = pcs_params.ck();
let pcs_raw_vk = pcs_params.raw_vk();
Expand Down
12 changes: 6 additions & 6 deletions ring/src/ring.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ impl<F: PrimeField, KzgCurve: Pairing<ScalarField=F>> RingBuilderKey<F, KzgCurve
mod tests {
use ark_bls12_381::{Bls12_381, Fr, G1Affine};
use ark_ed_on_bls12_381_bandersnatch::{BandersnatchConfig, SWAffine};
use ark_std::{test_rng, UniformRand, vec};
use ark_std::{test_rng, UniformRand};
use fflonk::pcs::kzg::KZG;
use fflonk::pcs::kzg::urs::URS;
use fflonk::pcs::PCS;
Expand Down Expand Up @@ -263,13 +263,13 @@ mod tests {
let piop_params = PiopParams::setup(domain, h, seed);

let mut ring = TestRing::empty(&piop_params, srs, ring_builder_key.g1);
let (monimial_cx, monimial_cy) = get_monomial_commitment(pcs_params.clone(), &piop_params, vec![]);
let (monimial_cx, monimial_cy) = get_monomial_commitment(&pcs_params, &piop_params, &[]);
assert_eq!(ring.cx, monimial_cx);
assert_eq!(ring.cy, monimial_cy);

let keys = random_vec::<SWAffine, _>(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);

Expand Down Expand Up @@ -298,9 +298,9 @@ mod tests {
assert_eq!(ring, same_ring);
}

fn get_monomial_commitment(pcs_params: URS<Bls12_381>, piop_params: &PiopParams<Fr, BandersnatchConfig>, keys: Vec<SWAffine>) -> (G1Affine, G1Affine) {
let (_, verifier_key) = crate::piop::index::<_, KZG::<Bls12_381>, _>(pcs_params, &piop_params, keys);
fn get_monomial_commitment(pcs_params: &URS<Bls12_381>, piop_params: &PiopParams<Fr, BandersnatchConfig>, keys: &[SWAffine]) -> (G1Affine, G1Affine) {
let (_, verifier_key) = crate::piop::index::<_, KZG::<Bls12_381>, _>(pcs_params, piop_params, keys);
let [monimial_cx, monimial_cy] = verifier_key.fixed_columns_committed.points;
(monimial_cx.0, monimial_cy.0)
}
}
}
1 change: 0 additions & 1 deletion ring/src/ring_prover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ pub struct RingProver<F: PrimeField, CS: PCS<F>, Curve: SWCurveConfig<BaseField=
piop_params: PiopParams<F, Curve>,
fixed_columns: FixedColumns<F, Affine<Curve>>,
k: usize,

plonk_prover: PlonkProver<F, CS, merlin::Transcript>,
}

Expand Down
Loading