impl KZG based multilinear pcs (#22)

This commit is contained in:
zhenfei
2022-05-19 16:23:44 -04:00
committed by GitHub
parent e881d7fabf
commit b9527f8e37
12 changed files with 741 additions and 37 deletions

View File

@@ -1,8 +1,7 @@
use std::time::Instant;
use ark_bls12_381::Fr;
use ark_std::test_rng;
use poly_iop::{PolyIOP, PolyIOPErrors, SumCheck, VirtualPolynomial, ZeroCheck};
use std::time::Instant;
fn main() -> Result<(), PolyIOPErrors> {
bench_sum_check()?;
@@ -27,8 +26,10 @@ fn bench_sum_check() -> Result<(), PolyIOPErrors> {
let poly_info = poly.domain_info.clone();
let proof = {
let start = Instant::now();
let mut transcript = <PolyIOP<Fr> as SumCheck<Fr>>::init_transcript();
let proof = <PolyIOP<Fr> as SumCheck<Fr>>::prove(&poly, &mut transcript)?;
for _ in 0..repetition {
let mut transcript = <PolyIOP<Fr> as SumCheck<Fr>>::init_transcript();
let _proof = <PolyIOP<Fr> as SumCheck<Fr>>::prove(&poly, &mut transcript)?;
}
println!(
"sum check proving time for {} variables and {} degree: {} ns",
@@ -36,26 +37,30 @@ fn bench_sum_check() -> Result<(), PolyIOPErrors> {
degree,
start.elapsed().as_nanos() / repetition as u128
);
proof
let mut transcript = <PolyIOP<Fr> as SumCheck<Fr>>::init_transcript();
<PolyIOP<Fr> as SumCheck<Fr>>::prove(&poly, &mut transcript)?
};
{
let start = Instant::now();
let mut transcript = <PolyIOP<Fr> as SumCheck<Fr>>::init_transcript();
let subclaim = <PolyIOP<Fr> as SumCheck<Fr>>::verify(
asserted_sum,
&proof,
&poly_info,
&mut transcript,
)?;
assert!(
poly.evaluate(&subclaim.point).unwrap() == subclaim.expected_evaluation,
"wrong subclaim"
);
for _ in 0..repetition {
let mut transcript = <PolyIOP<Fr> as SumCheck<Fr>>::init_transcript();
let subclaim = <PolyIOP<Fr> as SumCheck<Fr>>::verify(
asserted_sum,
&proof,
&poly_info,
&mut transcript,
)?;
assert!(
poly.evaluate(&subclaim.point).unwrap() == subclaim.expected_evaluation,
"wrong subclaim"
);
}
println!(
"sum check verification time for {} variables: {} ns",
"sum check verification time for {} variables and {} degree: {} ns",
nv,
degree,
start.elapsed().as_nanos() / repetition as u128
);
}
@@ -106,8 +111,9 @@ fn bench_zero_check() -> Result<(), PolyIOPErrors> {
"wrong subclaim"
);
println!(
"zero check verification time for {} variables: {} ns",
"zero check verification time for {} variables and {} degree:: {} ns",
nv,
degree,
start.elapsed().as_nanos() / repetition as u128
);
}