diff --git a/Cargo.toml b/Cargo.toml index a0fb5aa..695bb66 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,7 +27,7 @@ ark-bls12-381 = { version = "0.4.0", default-features = false, optional = true } sha2 = { version = "0.10", default-features = false } # Ring VRF (waiting for crates.io) fflonk = { git = "https://github.com/w3f/fflonk", default-features = false, optional = true } -ring-proof = { package = "ring", git = "https://github.com/w3f/ring-proof", rev = "b273d33", default-features = false, optional = true } +ring-proof = { package = "ring", git = "https://github.com/davxy/ring-proof", branch = "extended", default-features = false, optional = true } [dev-dependencies] ark-ed25519 = "0.4" @@ -78,3 +78,6 @@ full = [ "curves", "ring", ] +test-vectors = [ + "ring-proof?/test-vectors" +] diff --git a/src/ring.rs b/src/ring.rs index 2a21851..5d406ff 100644 --- a/src/ring.rs +++ b/src/ring.rs @@ -2,6 +2,11 @@ use crate::*; use ark_ec::short_weierstrass::SWCurveConfig; use pedersen::{PedersenSuite, Proof as PedersenProof}; +pub mod prelude { + pub use fflonk; + pub use ring_proof; +} + #[cfg(feature = "parallel")] use rayon::prelude::*; @@ -12,29 +17,40 @@ pub trait RingSuite: PedersenSuite { } /// KZG Polynomial Commitment Scheme. -type Pcs = fflonk::pcs::kzg::KZG<::Pairing>; +pub type Pcs = fflonk::pcs::kzg::KZG<::Pairing>; + +/// KZG commitment. +pub type PcsCommitment = fflonk::pcs::kzg::commitment::KzgCommitment<::Pairing>; -/// KZG Setup Parameters. +/// KZG setup parameters. /// -/// Basically the powers of tau URS. -type PcsParams = fflonk::pcs::kzg::urs::URS<::Pairing>; +/// Basically the powers of tau SRS. +pub type PcsParams = fflonk::pcs::kzg::urs::URS<::Pairing>; + +/// Ring proof application specific setup parameters. +pub type PiopParams = ring_proof::PiopParams, CurveConfig>; +/// Ring keys commitment. +pub type RingCommitment = ring_proof::FixedColumnsCommitted, PcsCommitment>; + +/// Ring prover key. pub type ProverKey = ring_proof::ProverKey, Pcs, ark_ec::short_weierstrass::Affine>>; +/// Ring verifier key. pub type VerifierKey = ring_proof::VerifierKey, Pcs>; +/// Ring prover. pub type RingProver = ring_proof::ring_prover::RingProver, Pcs, CurveConfig>; +/// Ring verifier. pub type RingVerifier = ring_proof::ring_verifier::RingVerifier, Pcs, CurveConfig>; +/// Ring proof. pub type RingProof = ring_proof::RingProof, Pcs>; -pub type PiopParams = ring_proof::PiopParams, CurveConfig>; - -const TRANSCRIPT_LABEL: &[u8] = b""; - +/// Ring proof. #[derive(Clone, CanonicalSerialize, CanonicalDeserialize)] pub struct Proof where @@ -147,7 +163,7 @@ where pub fn new_random(domain_size: usize, rng: &mut R) -> Self { use fflonk::pcs::PCS; - let pcs_params = >::setup(3 * domain_size, rng); + let pcs_params = Pcs::::setup(3 * domain_size, rng); let piop_params = make_piop_params::(domain_size); Self { pcs_params, @@ -185,7 +201,7 @@ where prover_key, self.piop_params.clone(), key_index, - merlin::Transcript::new(TRANSCRIPT_LABEL), + merlin::Transcript::new(b""), ) } @@ -193,7 +209,7 @@ where RingVerifier::::init( verifier_key, self.piop_params.clone(), - merlin::Transcript::new(TRANSCRIPT_LABEL), + merlin::Transcript::new(b""), ) } } @@ -287,20 +303,3 @@ where S::COMPLEMENT_POINT.into_sw(), ) } - -pub fn make_ring_verifier( - verifier_key: VerifierKey, - domain_size: usize, -) -> RingVerifier -where - BaseField: ark_ff::PrimeField, - CurveConfig: SWCurveConfig, - AffinePoint: IntoSW>, -{ - let piop_params = make_piop_params::(domain_size); - RingVerifier::::init( - verifier_key, - piop_params, - merlin::Transcript::new(TRANSCRIPT_LABEL), - ) -}