mirror of
https://github.com/arnaucube/hyperplonk.git
synced 2026-01-10 16:11:29 +01:00
remove redundant apis
This commit is contained in:
committed by
chancharles92
parent
5e782910d4
commit
bee67686d0
@@ -7,9 +7,8 @@ mod virtual_polynomial;
|
||||
pub use errors::ArithErrors;
|
||||
pub use multilinear_polynomial::{
|
||||
evaluate_no_par, evaluate_opt, fix_last_variables, fix_last_variables_no_par, fix_variables,
|
||||
identity_permutation_mle, identity_permutation_mles, merge_polynomials, random_mle_list,
|
||||
random_permutation_mle, random_permutation_mles, random_zero_mle_list,
|
||||
DenseMultilinearExtension,
|
||||
identity_permutation_mles, merge_polynomials, random_mle_list, random_permutation_mles,
|
||||
random_zero_mle_list, DenseMultilinearExtension,
|
||||
};
|
||||
pub use univariate_polynomial::{build_l, get_uni_domain};
|
||||
pub use util::{bit_decompose, gen_eval_point, get_batched_nv, get_index};
|
||||
|
||||
@@ -72,35 +72,6 @@ pub fn random_zero_mle_list<F: PrimeField, R: RngCore>(
|
||||
list
|
||||
}
|
||||
|
||||
/// An MLE that represent an identity permutation: `f(index) \mapto index`
|
||||
/// TODO(binyi): remove
|
||||
pub fn identity_permutation_mle<F: PrimeField>(
|
||||
num_vars: usize,
|
||||
) -> Rc<DenseMultilinearExtension<F>> {
|
||||
let s_id_vec = (0..1u64 << num_vars).map(F::from).collect();
|
||||
Rc::new(DenseMultilinearExtension::from_evaluations_vec(
|
||||
num_vars, s_id_vec,
|
||||
))
|
||||
}
|
||||
|
||||
/// An MLE that represent a random permutation
|
||||
/// TODO(binyi): remove
|
||||
pub fn random_permutation_mle<F: PrimeField, R: RngCore>(
|
||||
num_vars: usize,
|
||||
rng: &mut R,
|
||||
) -> Rc<DenseMultilinearExtension<F>> {
|
||||
let len = 1u64 << num_vars;
|
||||
let mut s_id_vec: Vec<F> = (0..len).map(F::from).collect();
|
||||
let mut s_perm_vec = vec![];
|
||||
for _ in 0..len {
|
||||
let index = rng.next_u64() as usize % s_id_vec.len();
|
||||
s_perm_vec.push(s_id_vec.remove(index));
|
||||
}
|
||||
Rc::new(DenseMultilinearExtension::from_evaluations_vec(
|
||||
num_vars, s_perm_vec,
|
||||
))
|
||||
}
|
||||
|
||||
/// A list of MLEs that represents an identity permutation
|
||||
pub fn identity_permutation_mles<F: PrimeField>(
|
||||
num_vars: usize,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use arithmetic::identity_permutation_mle;
|
||||
use arithmetic::identity_permutation_mles;
|
||||
use ark_ff::PrimeField;
|
||||
use ark_poly::MultilinearExtension;
|
||||
use ark_std::{log2, test_rng};
|
||||
@@ -93,7 +93,7 @@ impl<F: PrimeField> MockCircuit<F> {
|
||||
gate_func: gate.clone(),
|
||||
};
|
||||
|
||||
let permutation = identity_permutation_mle(merged_nv as usize).to_evaluations();
|
||||
let permutation = identity_permutation_mles(merged_nv as usize, 1)[0].to_evaluations();
|
||||
let index = HyperPlonkIndex {
|
||||
params,
|
||||
permutation,
|
||||
|
||||
@@ -5,7 +5,7 @@ use crate::{
|
||||
witness::WitnessColumn,
|
||||
HyperPlonkSNARK,
|
||||
};
|
||||
use arithmetic::{evaluate_opt, identity_permutation_mle, merge_polynomials, VPAuxInfo};
|
||||
use arithmetic::{evaluate_opt, identity_permutation_mles, merge_polynomials, VPAuxInfo};
|
||||
use ark_ec::PairingEngine;
|
||||
use ark_poly::DenseMultilinearExtension;
|
||||
use ark_std::{end_timer, log2, start_timer, One, Zero};
|
||||
@@ -526,8 +526,8 @@ where
|
||||
|
||||
// we evaluate MLE directly instead of using s_id/s_perm PCS verify
|
||||
// Verification takes n pairings while evaluate takes 2^n field ops.
|
||||
let s_id = identity_permutation_mle::<E::Fr>(perm_check_point.len());
|
||||
let s_id_eval = evaluate_opt(&s_id, perm_check_point);
|
||||
let s_ids = identity_permutation_mles::<E::Fr>(perm_check_point.len(), 1);
|
||||
let s_id_eval = evaluate_opt(&s_ids[0], perm_check_point);
|
||||
let s_perm_eval = evaluate_opt(&vk.permutation_oracle, perm_check_point);
|
||||
|
||||
let q_x_rec = prod_evals[1] - prod_evals[2] * prod_evals[3]
|
||||
@@ -629,7 +629,7 @@ mod tests {
|
||||
custom_gate::CustomizedGates, selectors::SelectorColumn, structs::HyperPlonkParams,
|
||||
witness::WitnessColumn,
|
||||
};
|
||||
use arithmetic::random_permutation_mle;
|
||||
use arithmetic::random_permutation_mles;
|
||||
use ark_bls12_381::Bls12_381;
|
||||
use ark_std::test_rng;
|
||||
use subroutines::pcs::prelude::MultilinearKzgPCS;
|
||||
@@ -672,7 +672,9 @@ mod tests {
|
||||
num_pub_input,
|
||||
gate_func,
|
||||
};
|
||||
let permutation = identity_permutation_mle(merged_nv).evaluations.clone();
|
||||
let permutation = identity_permutation_mles(merged_nv, 1)[0]
|
||||
.evaluations
|
||||
.clone();
|
||||
let q1 = SelectorColumn(vec![E::Fr::one(), E::Fr::one(), E::Fr::one(), E::Fr::one()]);
|
||||
let index = HyperPlonkIndex {
|
||||
params,
|
||||
@@ -714,7 +716,7 @@ mod tests {
|
||||
)?;
|
||||
|
||||
// bad path 1: wrong permutation
|
||||
let rand_perm: Vec<E::Fr> = random_permutation_mle(merged_nv, &mut rng)
|
||||
let rand_perm: Vec<E::Fr> = random_permutation_mles(merged_nv, 1, &mut rng)[0]
|
||||
.evaluations
|
||||
.clone();
|
||||
let mut bad_index = index.clone();
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use arithmetic::{identity_permutation_mle, VPAuxInfo, VirtualPolynomial};
|
||||
use arithmetic::{identity_permutation_mles, VPAuxInfo, VirtualPolynomial};
|
||||
use ark_bls12_381::{Bls12_381, Fr};
|
||||
use ark_poly::{DenseMultilinearExtension, MultilinearExtension};
|
||||
use ark_std::test_rng;
|
||||
@@ -144,10 +144,10 @@ fn bench_permutation_check() -> Result<(), PolyIOPErrors> {
|
||||
10
|
||||
};
|
||||
|
||||
let w = Rc::new(DenseMultilinearExtension::rand(nv, &mut rng));
|
||||
let ws = vec![Rc::new(DenseMultilinearExtension::rand(nv, &mut rng))];
|
||||
|
||||
// s_perm is the identity map
|
||||
let s_perm = identity_permutation_mle(nv);
|
||||
// identity map
|
||||
let perms = identity_permutation_mles(nv, 1);
|
||||
|
||||
let proof = {
|
||||
let start = Instant::now();
|
||||
@@ -157,9 +157,9 @@ fn bench_permutation_check() -> Result<(), PolyIOPErrors> {
|
||||
|
||||
let (proof, _q_x) = <PolyIOP<Fr> as PermutationCheck<Bls12_381, KZG>>::prove(
|
||||
&pcs_param,
|
||||
&w,
|
||||
&w,
|
||||
&s_perm,
|
||||
&ws,
|
||||
&ws,
|
||||
&perms,
|
||||
&mut transcript,
|
||||
)?;
|
||||
|
||||
@@ -218,20 +218,21 @@ fn bench_prod_check() -> Result<(), PolyIOPErrors> {
|
||||
let f: DenseMultilinearExtension<Fr> = DenseMultilinearExtension::rand(nv, &mut rng);
|
||||
let mut g = f.clone();
|
||||
g.evaluations.reverse();
|
||||
let f = Rc::new(f);
|
||||
let g = Rc::new(g);
|
||||
let fs = vec![Rc::new(f)];
|
||||
let gs = vec![Rc::new(g)];
|
||||
|
||||
let proof = {
|
||||
let start = Instant::now();
|
||||
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(
|
||||
&pcs_param,
|
||||
&f,
|
||||
&g,
|
||||
&mut transcript,
|
||||
)?;
|
||||
let (proof, _prod_x, _frac_poly) =
|
||||
<PolyIOP<Fr> as ProductCheck<Bls12_381, KZG>>::prove(
|
||||
&pcs_param,
|
||||
&fs,
|
||||
&gs,
|
||||
&mut transcript,
|
||||
)?;
|
||||
|
||||
println!(
|
||||
"product check proving time for {} variables: {} ns",
|
||||
|
||||
Reference in New Issue
Block a user