mirror of
https://github.com/arnaucube/hyperplonk.git
synced 2026-01-11 16:41:28 +01:00
PCS crate moved to other repository.
This commit is contained in:
@@ -20,7 +20,8 @@ rayon = { version = "1.5.2", default-features = false, optional = true }
|
||||
|
||||
transcript = { path = "../transcript" }
|
||||
arithmetic = { path = "../arithmetic" }
|
||||
pcs = { path = "../pcs" }
|
||||
|
||||
jf-primitives = { git = "https://github.com/EspressoSystems/jellyfish" }
|
||||
|
||||
[dev-dependencies]
|
||||
ark-ec = { version = "^0.3.0", default-features = false }
|
||||
@@ -40,10 +41,10 @@ parallel = [
|
||||
"ark-std/parallel",
|
||||
"ark-ff/parallel",
|
||||
"ark-poly/parallel",
|
||||
"pcs/parallel",
|
||||
"jf-primitives/parallel",
|
||||
]
|
||||
print-trace = [
|
||||
"arithmetic/print-trace",
|
||||
"ark-std/print-trace",
|
||||
"pcs/print-trace",
|
||||
"jf-primitives/print-trace",
|
||||
]
|
||||
@@ -2,14 +2,14 @@ use arithmetic::{VPAuxInfo, VirtualPolynomial};
|
||||
use ark_bls12_381::{Bls12_381, Fr};
|
||||
use ark_poly::{DenseMultilinearExtension, MultilinearExtension};
|
||||
use ark_std::test_rng;
|
||||
use pcs::{prelude::KZGMultilinearPCS, PolynomialCommitmentScheme};
|
||||
use jf_primitives::pcs::{prelude::MultilinearKzgPCS, PolynomialCommitmentScheme};
|
||||
use poly_iop::prelude::{
|
||||
identity_permutation_mle, PermutationCheck, PolyIOP, PolyIOPErrors, ProductCheck, SumCheck,
|
||||
ZeroCheck,
|
||||
};
|
||||
use std::{marker::PhantomData, rc::Rc, time::Instant};
|
||||
|
||||
type KZG = KZGMultilinearPCS<Bls12_381>;
|
||||
type Kzg = MultilinearKzgPCS<Bls12_381>;
|
||||
|
||||
fn main() -> Result<(), PolyIOPErrors> {
|
||||
bench_permutation_check()?;
|
||||
@@ -140,8 +140,8 @@ fn bench_permutation_check() -> Result<(), PolyIOPErrors> {
|
||||
let mut rng = test_rng();
|
||||
|
||||
for nv in 4..20 {
|
||||
let srs = KZG::gen_srs_for_testing(&mut rng, nv + 1)?;
|
||||
let (pcs_param, _) = KZG::trim(&srs, nv + 1, Some(nv + 1))?;
|
||||
let srs = Kzg::gen_srs_for_testing(&mut rng, nv + 1)?;
|
||||
let (pcs_param, _) = Kzg::trim(&srs, nv + 1, Some(nv + 1))?;
|
||||
|
||||
let repetition = if nv < 10 {
|
||||
100
|
||||
@@ -159,10 +159,10 @@ fn bench_permutation_check() -> Result<(), PolyIOPErrors> {
|
||||
let proof = {
|
||||
let start = Instant::now();
|
||||
let mut transcript =
|
||||
<PolyIOP<Fr> as PermutationCheck<Bls12_381, KZG>>::init_transcript();
|
||||
<PolyIOP<Fr> as PermutationCheck<Bls12_381, Kzg>>::init_transcript();
|
||||
transcript.append_message(b"testing", b"initializing transcript for testing")?;
|
||||
|
||||
let (proof, _q_x) = <PolyIOP<Fr> as PermutationCheck<Bls12_381, KZG>>::prove(
|
||||
let (proof, _q_x) = <PolyIOP<Fr> as PermutationCheck<Bls12_381, Kzg>>::prove(
|
||||
&pcs_param,
|
||||
&w,
|
||||
&w,
|
||||
@@ -187,9 +187,9 @@ fn bench_permutation_check() -> Result<(), PolyIOPErrors> {
|
||||
|
||||
let start = Instant::now();
|
||||
let mut transcript =
|
||||
<PolyIOP<Fr> as PermutationCheck<Bls12_381, KZG>>::init_transcript();
|
||||
<PolyIOP<Fr> as PermutationCheck<Bls12_381, Kzg>>::init_transcript();
|
||||
transcript.append_message(b"testing", b"initializing transcript for testing")?;
|
||||
let _perm_check_sum_claim = <PolyIOP<Fr> as PermutationCheck<Bls12_381, KZG>>::verify(
|
||||
let _perm_check_sum_claim = <PolyIOP<Fr> as PermutationCheck<Bls12_381, Kzg>>::verify(
|
||||
&proof,
|
||||
&poly_info,
|
||||
&mut transcript,
|
||||
@@ -211,8 +211,8 @@ fn bench_prod_check() -> Result<(), PolyIOPErrors> {
|
||||
let mut rng = test_rng();
|
||||
|
||||
for nv in 4..20 {
|
||||
let srs = KZG::gen_srs_for_testing(&mut rng, nv + 1)?;
|
||||
let (pcs_param, _) = KZG::trim(&srs, nv + 1, Some(nv + 1))?;
|
||||
let srs = Kzg::gen_srs_for_testing(&mut rng, nv + 1)?;
|
||||
let (pcs_param, _) = Kzg::trim(&srs, nv + 1, Some(nv + 1))?;
|
||||
|
||||
let repetition = if nv < 10 {
|
||||
100
|
||||
@@ -230,10 +230,10 @@ fn bench_prod_check() -> Result<(), PolyIOPErrors> {
|
||||
|
||||
let proof = {
|
||||
let start = Instant::now();
|
||||
let mut transcript = <PolyIOP<Fr> as ProductCheck<Bls12_381, KZG>>::init_transcript();
|
||||
let mut transcript = <PolyIOP<Fr> as ProductCheck<Bls12_381, Kzg>>::init_transcript();
|
||||
transcript.append_message(b"testing", b"initializing transcript for testing")?;
|
||||
|
||||
let (proof, _prod_x) = <PolyIOP<Fr> as ProductCheck<Bls12_381, KZG>>::prove(
|
||||
let (proof, _prod_x) = <PolyIOP<Fr> as ProductCheck<Bls12_381, Kzg>>::prove(
|
||||
&pcs_param,
|
||||
&f,
|
||||
&g,
|
||||
@@ -256,9 +256,9 @@ fn bench_prod_check() -> Result<(), PolyIOPErrors> {
|
||||
};
|
||||
|
||||
let start = Instant::now();
|
||||
let mut transcript = <PolyIOP<Fr> as ProductCheck<Bls12_381, KZG>>::init_transcript();
|
||||
let mut transcript = <PolyIOP<Fr> as ProductCheck<Bls12_381, Kzg>>::init_transcript();
|
||||
transcript.append_message(b"testing", b"initializing transcript for testing")?;
|
||||
let _perm_check_sum_claim = <PolyIOP<Fr> as ProductCheck<Bls12_381, KZG>>::verify(
|
||||
let _perm_check_sum_claim = <PolyIOP<Fr> as ProductCheck<Bls12_381, Kzg>>::verify(
|
||||
&proof,
|
||||
&poly_info,
|
||||
&mut transcript,
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
use arithmetic::ArithErrors;
|
||||
use ark_std::string::String;
|
||||
use displaydoc::Display;
|
||||
use pcs::prelude::PCSErrors;
|
||||
use jf_primitives::pcs::errors::PCSError;
|
||||
use transcript::TranscriptErrors;
|
||||
|
||||
/// A `enum` specifying the possible failure modes of the PolyIOP.
|
||||
@@ -28,7 +28,7 @@ pub enum PolyIOPErrors {
|
||||
/// Arithmetic Error: {0}
|
||||
ArithmeticErrors(ArithErrors),
|
||||
/// PCS error {0}
|
||||
PCSErrors(PCSErrors),
|
||||
PCSError(PCSError),
|
||||
}
|
||||
|
||||
impl From<ark_serialize::SerializationError> for PolyIOPErrors {
|
||||
@@ -49,8 +49,8 @@ impl From<ArithErrors> for PolyIOPErrors {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<PCSErrors> for PolyIOPErrors {
|
||||
fn from(e: PCSErrors) -> Self {
|
||||
Self::PCSErrors(e)
|
||||
impl From<PCSError> for PolyIOPErrors {
|
||||
fn from(e: PCSError) -> Self {
|
||||
Self::PCSError(e)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ use crate::{errors::PolyIOPErrors, prelude::ProductCheck, PolyIOP};
|
||||
use ark_ec::PairingEngine;
|
||||
use ark_poly::DenseMultilinearExtension;
|
||||
use ark_std::{end_timer, start_timer};
|
||||
use pcs::PolynomialCommitmentScheme;
|
||||
use jf_primitives::pcs::PolynomialCommitmentScheme;
|
||||
use std::rc::Rc;
|
||||
use transcript::IOPTranscript;
|
||||
|
||||
@@ -163,10 +163,10 @@ mod test {
|
||||
use ark_ec::PairingEngine;
|
||||
use ark_poly::{DenseMultilinearExtension, MultilinearExtension};
|
||||
use ark_std::test_rng;
|
||||
use pcs::{prelude::KZGMultilinearPCS, PolynomialCommitmentScheme};
|
||||
use jf_primitives::pcs::{prelude::MultilinearKzgPCS, PolynomialCommitmentScheme};
|
||||
use std::{marker::PhantomData, rc::Rc};
|
||||
|
||||
type KZG = KZGMultilinearPCS<Bls12_381>;
|
||||
type Kzg = MultilinearKzgPCS<Bls12_381>;
|
||||
|
||||
fn test_permutation_check_helper<E, PCS>(
|
||||
pcs_param: &PCS::ProverParam,
|
||||
@@ -220,15 +220,15 @@ mod test {
|
||||
fn test_permutation_check(nv: usize) -> Result<(), PolyIOPErrors> {
|
||||
let mut rng = test_rng();
|
||||
|
||||
let srs = KZGMultilinearPCS::<Bls12_381>::gen_srs_for_testing(&mut rng, nv + 1)?;
|
||||
let (pcs_param, _) = KZGMultilinearPCS::<Bls12_381>::trim(&srs, nv + 1, Some(nv + 1))?;
|
||||
let srs = MultilinearKzgPCS::<Bls12_381>::gen_srs_for_testing(&mut rng, nv + 1)?;
|
||||
let (pcs_param, _) = MultilinearKzgPCS::<Bls12_381>::trim(&srs, nv + 1, Some(nv + 1))?;
|
||||
|
||||
{
|
||||
// good path: w is a permutation of w itself under the identify map
|
||||
let w = Rc::new(DenseMultilinearExtension::rand(nv, &mut rng));
|
||||
// s_perm is the identity map
|
||||
let s_perm = identity_permutation_mle(nv);
|
||||
test_permutation_check_helper::<Bls12_381, KZG>(&pcs_param, &w, &w, &s_perm)?;
|
||||
test_permutation_check_helper::<Bls12_381, Kzg>(&pcs_param, &w, &w, &s_perm)?;
|
||||
}
|
||||
|
||||
{
|
||||
@@ -238,9 +238,9 @@ mod test {
|
||||
let s_perm = random_permutation_mle(nv, &mut rng);
|
||||
|
||||
if nv == 1 {
|
||||
test_permutation_check_helper::<Bls12_381, KZG>(&pcs_param, &w, &w, &s_perm)?;
|
||||
test_permutation_check_helper::<Bls12_381, Kzg>(&pcs_param, &w, &w, &s_perm)?;
|
||||
} else {
|
||||
assert!(test_permutation_check_helper::<Bls12_381, KZG>(
|
||||
assert!(test_permutation_check_helper::<Bls12_381, Kzg>(
|
||||
&pcs_param, &w, &w, &s_perm
|
||||
)
|
||||
.is_err());
|
||||
@@ -255,7 +255,7 @@ mod test {
|
||||
let s_perm = identity_permutation_mle(nv);
|
||||
|
||||
assert!(
|
||||
test_permutation_check_helper::<Bls12_381, KZG>(&pcs_param, &f, &g, &s_perm)
|
||||
test_permutation_check_helper::<Bls12_381, Kzg>(&pcs_param, &f, &g, &s_perm)
|
||||
.is_err()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ use ark_ec::PairingEngine;
|
||||
use ark_ff::{One, PrimeField, Zero};
|
||||
use ark_poly::DenseMultilinearExtension;
|
||||
use ark_std::{end_timer, start_timer};
|
||||
use pcs::prelude::PolynomialCommitmentScheme;
|
||||
use jf_primitives::pcs::prelude::PolynomialCommitmentScheme;
|
||||
use std::rc::Rc;
|
||||
use transcript::IOPTranscript;
|
||||
|
||||
@@ -207,7 +207,7 @@ mod test {
|
||||
use ark_ec::PairingEngine;
|
||||
use ark_poly::{DenseMultilinearExtension, MultilinearExtension};
|
||||
use ark_std::test_rng;
|
||||
use pcs::{prelude::KZGMultilinearPCS, PolynomialCommitmentScheme};
|
||||
use jf_primitives::pcs::{prelude::MultilinearKzgPCS, PolynomialCommitmentScheme};
|
||||
use std::{marker::PhantomData, rc::Rc};
|
||||
|
||||
// f and g are guaranteed to have the same product
|
||||
@@ -254,7 +254,7 @@ mod test {
|
||||
let (bad_proof, prod_x_bad) = <PolyIOP<E::Fr> as ProductCheck<E, PCS>>::prove(
|
||||
pcs_param,
|
||||
&Rc::new(f.clone()),
|
||||
&Rc::new(h.clone()),
|
||||
&Rc::new(h),
|
||||
&mut transcript,
|
||||
)?;
|
||||
|
||||
@@ -281,10 +281,10 @@ mod test {
|
||||
let mut g = f.clone();
|
||||
g.evaluations.reverse();
|
||||
|
||||
let srs = KZGMultilinearPCS::<Bls12_381>::gen_srs_for_testing(&mut rng, nv + 1)?;
|
||||
let (pcs_param, _) = KZGMultilinearPCS::<Bls12_381>::trim(&srs, nv + 1, Some(nv + 1))?;
|
||||
let srs = MultilinearKzgPCS::<Bls12_381>::gen_srs_for_testing(&mut rng, nv + 1)?;
|
||||
let (pcs_param, _) = MultilinearKzgPCS::<Bls12_381>::trim(&srs, nv + 1, Some(nv + 1))?;
|
||||
|
||||
test_product_check_helper::<Bls12_381, KZGMultilinearPCS<Bls12_381>>(&f, &g, &pcs_param)?;
|
||||
test_product_check_helper::<Bls12_381, MultilinearKzgPCS<Bls12_381>>(&f, &g, &pcs_param)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user