mirror of https://github.com/zcash/halo2.git
reafactor: move vp, pp as types of params
Remove params use from `verify_proof`. It only uses the generator of G1, and this is fixed in the curve.
This commit is contained in:
parent
bd385c3625
commit
2f032a6910
|
@ -45,6 +45,12 @@ pub trait Params<'params, C: CurveAffine>: Sized + Clone + Debug {
|
||||||
/// Multiscalar multiplication engine
|
/// Multiscalar multiplication engine
|
||||||
type MSM: MSM<C> + 'params;
|
type MSM: MSM<C> + 'params;
|
||||||
|
|
||||||
|
/// Verifier parameters.
|
||||||
|
type ParamsVerifier: ParamsVerifier<'params, C>;
|
||||||
|
|
||||||
|
/// Prover parameters.
|
||||||
|
type ParamsProver: ParamsProver<'params, C>;
|
||||||
|
|
||||||
/// Logarithmic size of the circuit
|
/// Logarithmic size of the circuit
|
||||||
fn k(&self) -> u32;
|
fn k(&self) -> u32;
|
||||||
|
|
||||||
|
@ -58,6 +64,9 @@ pub trait Params<'params, C: CurveAffine>: Sized + Clone + Debug {
|
||||||
/// appropriate params.
|
/// appropriate params.
|
||||||
fn empty_msm(&'params self) -> Self::MSM;
|
fn empty_msm(&'params self) -> Self::MSM;
|
||||||
|
|
||||||
|
/// Returns verification parameters.
|
||||||
|
fn verifier_params(&'params self) -> &'params Self::ParamsVerifier;
|
||||||
|
|
||||||
/// This commits to a polynomial using its evaluations over the $2^k$ size
|
/// This commits to a polynomial using its evaluations over the $2^k$ size
|
||||||
/// evaluation domain. The commitment will be blinded by the blinding factor
|
/// evaluation domain. The commitment will be blinded by the blinding factor
|
||||||
/// `r`.
|
/// `r`.
|
||||||
|
@ -77,9 +86,6 @@ pub trait Params<'params, C: CurveAffine>: Sized + Clone + Debug {
|
||||||
|
|
||||||
/// Parameters for circuit synthesis and prover parameters.
|
/// Parameters for circuit synthesis and prover parameters.
|
||||||
pub trait ParamsProver<'params, C: CurveAffine>: Params<'params, C> {
|
pub trait ParamsProver<'params, C: CurveAffine>: Params<'params, C> {
|
||||||
/// Constant verifier parameters.
|
|
||||||
type ParamsVerifier: ParamsVerifier<'params, C>;
|
|
||||||
|
|
||||||
/// Returns new instance of parameters
|
/// Returns new instance of parameters
|
||||||
fn new(k: u32) -> Self;
|
fn new(k: u32) -> Self;
|
||||||
|
|
||||||
|
@ -95,9 +101,6 @@ pub trait ParamsProver<'params, C: CurveAffine>: Params<'params, C> {
|
||||||
|
|
||||||
/// Getter for g generators
|
/// Getter for g generators
|
||||||
fn get_g(&self) -> &[C];
|
fn get_g(&self) -> &[C];
|
||||||
|
|
||||||
/// Returns verification parameters.
|
|
||||||
fn verifier_params(&'params self) -> &'params Self::ParamsVerifier;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Verifier specific functionality with circuit constraints
|
/// Verifier specific functionality with circuit constraints
|
||||||
|
|
|
@ -62,6 +62,9 @@ impl<'params, C: CurveAffine> ParamsVerifier<'params, C> for ParamsIPA<C> {}
|
||||||
impl<'params, C: CurveAffine> Params<'params, C> for ParamsIPA<C> {
|
impl<'params, C: CurveAffine> Params<'params, C> for ParamsIPA<C> {
|
||||||
type MSM = MSMIPA<'params, C>;
|
type MSM = MSMIPA<'params, C>;
|
||||||
|
|
||||||
|
type ParamsVerifier = Self;
|
||||||
|
type ParamsProver = Self;
|
||||||
|
|
||||||
fn k(&self) -> u32 {
|
fn k(&self) -> u32 {
|
||||||
self.k
|
self.k
|
||||||
}
|
}
|
||||||
|
@ -83,6 +86,10 @@ impl<'params, C: CurveAffine> Params<'params, C> for ParamsIPA<C> {
|
||||||
MSMIPA::new(self)
|
MSMIPA::new(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn verifier_params(&'params self) -> &'params Self::ParamsVerifier {
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
/// This commits to a polynomial using its evaluations over the $2^k$ size
|
/// This commits to a polynomial using its evaluations over the $2^k$ size
|
||||||
/// evaluation domain. The commitment will be blinded by the blinding factor
|
/// evaluation domain. The commitment will be blinded by the blinding factor
|
||||||
/// `r`.
|
/// `r`.
|
||||||
|
@ -145,12 +152,6 @@ impl<'params, C: CurveAffine> Params<'params, C> for ParamsIPA<C> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'params, C: CurveAffine> ParamsProver<'params, C> for ParamsIPA<C> {
|
impl<'params, C: CurveAffine> ParamsProver<'params, C> for ParamsIPA<C> {
|
||||||
type ParamsVerifier = ParamsVerifierIPA<C>;
|
|
||||||
|
|
||||||
fn verifier_params(&'params self) -> &'params Self::ParamsVerifier {
|
|
||||||
self
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Initializes parameters for the curve, given a random oracle to draw
|
/// Initializes parameters for the curve, given a random oracle to draw
|
||||||
/// points from.
|
/// points from.
|
||||||
fn new(k: u32) -> Self {
|
fn new(k: u32) -> Self {
|
||||||
|
|
|
@ -280,6 +280,12 @@ where
|
||||||
{
|
{
|
||||||
type MSM = MSMKZG<E>;
|
type MSM = MSMKZG<E>;
|
||||||
|
|
||||||
|
/// Verifier parameters.
|
||||||
|
type ParamsVerifier = ParamsVerifierKZG<E>;
|
||||||
|
|
||||||
|
/// Prover parameters.
|
||||||
|
type ParamsProver = Self;
|
||||||
|
|
||||||
fn k(&self) -> u32 {
|
fn k(&self) -> u32 {
|
||||||
self.k
|
self.k
|
||||||
}
|
}
|
||||||
|
@ -302,6 +308,10 @@ where
|
||||||
MSMKZG::new()
|
MSMKZG::new()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn verifier_params(&'params self) -> &'params Self::ParamsVerifier {
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
fn commit_lagrange(
|
fn commit_lagrange(
|
||||||
&self,
|
&self,
|
||||||
engine: &impl MsmAccel<E::G1Affine>,
|
engine: &impl MsmAccel<E::G1Affine>,
|
||||||
|
@ -341,12 +351,6 @@ where
|
||||||
E::G1: CurveExt<AffineExt = E::G1Affine>,
|
E::G1: CurveExt<AffineExt = E::G1Affine>,
|
||||||
E::G2Affine: SerdeCurveAffine,
|
E::G2Affine: SerdeCurveAffine,
|
||||||
{
|
{
|
||||||
type ParamsVerifier = ParamsVerifierKZG<E>;
|
|
||||||
|
|
||||||
fn verifier_params(&'params self) -> &'params Self::ParamsVerifier {
|
|
||||||
self
|
|
||||||
}
|
|
||||||
|
|
||||||
fn new(k: u32) -> Self {
|
fn new(k: u32) -> Self {
|
||||||
Self::setup(k, OsRng)
|
Self::setup(k, OsRng)
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,8 @@ use crate::poly::query::{CommitmentReference, VerifierQuery};
|
||||||
use crate::poly::Error;
|
use crate::poly::Error;
|
||||||
use crate::transcript::{EncodedChallenge, TranscriptRead};
|
use crate::transcript::{EncodedChallenge, TranscriptRead};
|
||||||
|
|
||||||
|
use group::prime::PrimeCurve;
|
||||||
|
use group::prime::PrimeCurveAffine;
|
||||||
use halo2_middleware::ff::Field;
|
use halo2_middleware::ff::Field;
|
||||||
use halo2curves::pairing::{Engine, MultiMillerLoop};
|
use halo2curves::pairing::{Engine, MultiMillerLoop};
|
||||||
use halo2curves::CurveExt;
|
use halo2curves::CurveExt;
|
||||||
|
@ -116,7 +118,7 @@ where
|
||||||
|
|
||||||
msm_accumulator.right.add_msm(&witness_with_aux);
|
msm_accumulator.right.add_msm(&witness_with_aux);
|
||||||
msm_accumulator.right.add_msm(&commitment_multi);
|
msm_accumulator.right.add_msm(&commitment_multi);
|
||||||
let g0: E::G1 = self.params.g[0].into();
|
let g0: E::G1 = <E::G1Affine as PrimeCurveAffine>::generator().into();
|
||||||
msm_accumulator.right.append_term(eval_multi, -g0);
|
msm_accumulator.right.append_term(eval_multi, -g0);
|
||||||
|
|
||||||
Ok(Self::Guard::new(msm_accumulator))
|
Ok(Self::Guard::new(msm_accumulator))
|
||||||
|
|
|
@ -15,6 +15,7 @@ use crate::poly::kzg::strategy::GuardKZG;
|
||||||
use crate::poly::query::{CommitmentReference, VerifierQuery};
|
use crate::poly::query::{CommitmentReference, VerifierQuery};
|
||||||
use crate::poly::Error;
|
use crate::poly::Error;
|
||||||
use crate::transcript::{EncodedChallenge, TranscriptRead};
|
use crate::transcript::{EncodedChallenge, TranscriptRead};
|
||||||
|
use group::prime::PrimeCurveAffine;
|
||||||
use halo2_middleware::ff::Field;
|
use halo2_middleware::ff::Field;
|
||||||
use halo2curves::pairing::{Engine, MultiMillerLoop};
|
use halo2curves::pairing::{Engine, MultiMillerLoop};
|
||||||
use halo2curves::CurveExt;
|
use halo2curves::CurveExt;
|
||||||
|
@ -126,7 +127,7 @@ where
|
||||||
r_outer_acc += power_of_v * r_inner_acc * z_diff_i;
|
r_outer_acc += power_of_v * r_inner_acc * z_diff_i;
|
||||||
}
|
}
|
||||||
let mut outer_msm = outer_msm.normalize();
|
let mut outer_msm = outer_msm.normalize();
|
||||||
let g1: E::G1 = self.params.g[0].into();
|
let g1: E::G1 = <E::G1Affine as PrimeCurveAffine>::generator().into();
|
||||||
outer_msm.append_term(-r_outer_acc, g1);
|
outer_msm.append_term(-r_outer_acc, g1);
|
||||||
outer_msm.append_term(-z_0, h1.into());
|
outer_msm.append_term(-z_0, h1.into());
|
||||||
outer_msm.append_term(*u, h2.into());
|
outer_msm.append_term(*u, h2.into());
|
||||||
|
|
|
@ -28,7 +28,7 @@ use halo2_frontend::{
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
use halo2_middleware::{ff::Field, poly::Rotation};
|
use halo2_middleware::{ff::Field, poly::Rotation};
|
||||||
use halo2_proofs::poly::commitment::ParamsProver;
|
use halo2_proofs::poly::commitment::Params;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
|
|
|
@ -7,7 +7,6 @@ use halo2_middleware::zal::{
|
||||||
impls::{PlonkEngine, PlonkEngineConfig},
|
impls::{PlonkEngine, PlonkEngineConfig},
|
||||||
traits::MsmAccel,
|
traits::MsmAccel,
|
||||||
};
|
};
|
||||||
use halo2_proofs::arithmetic::Field;
|
|
||||||
use halo2_proofs::circuit::{Cell, Layouter, SimpleFloorPlanner, Value};
|
use halo2_proofs::circuit::{Cell, Layouter, SimpleFloorPlanner, Value};
|
||||||
use halo2_proofs::dev::MockProver;
|
use halo2_proofs::dev::MockProver;
|
||||||
use halo2_proofs::plonk::{
|
use halo2_proofs::plonk::{
|
||||||
|
@ -22,6 +21,7 @@ use halo2_proofs::transcript::{
|
||||||
Blake2bRead, Blake2bWrite, Challenge255, EncodedChallenge, TranscriptReadBuffer,
|
Blake2bRead, Blake2bWrite, Challenge255, EncodedChallenge, TranscriptReadBuffer,
|
||||||
TranscriptWriterBuffer,
|
TranscriptWriterBuffer,
|
||||||
};
|
};
|
||||||
|
use halo2_proofs::{arithmetic::Field, poly::commitment::Params};
|
||||||
use rand_core::{OsRng, RngCore};
|
use rand_core::{OsRng, RngCore};
|
||||||
use std::marker::PhantomData;
|
use std::marker::PhantomData;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue