Skip to content

Commit

Permalink
simplify trait bound
Browse files Browse the repository at this point in the history
  • Loading branch information
hero78119 committed Feb 1, 2024
1 parent bba681c commit 8e62ca3
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 17 deletions.
10 changes: 3 additions & 7 deletions snark-verifier/src/pcs/kzg/decider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,9 @@ mod evm {
impl<M, MOS> AccumulationDecider<M::G1Affine, Rc<EvmLoader>> for KzgAs<M, MOS>
where
M: MultiMillerLoop,
M::G1Affine: CurveAffine,
M::Fr: PrimeField<Repr = [u8; 0x20]>,
M::G1Affine: CurveAffine<ScalarExt = M::Fr>,
M::G2Affine: CurveAffine,
<M::G1Affine as CurveAffine>::ScalarExt: PrimeField<Repr = [u8; 0x20]>,
MOS: Clone + Debug,
{
type DecidingKey = KzgDecidingKey<M>;
Expand Down Expand Up @@ -183,11 +183,7 @@ mod evm {
loader.code_mut().runtime_append(code);
let challenge = loader.scalar(Value::Memory(challenge_ptr));

let powers_of_challenge =
LoadedScalar::<<M::G1Affine as CurveAffine>::ScalarExt>::powers(
&challenge,
lhs.len(),
);
let powers_of_challenge = LoadedScalar::<M::Fr>::powers(&challenge, lhs.len());
let [lhs, rhs] = [lhs, rhs].map(|msms| {
msms.iter()
.zip(powers_of_challenge.iter())
Expand Down
9 changes: 5 additions & 4 deletions snark-verifier/src/pcs/kzg/multiopen/bdfg21.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use halo2_curves::{ff::PrimeField, group::prime::PrimeCurveAffine};
use halo2_curves::ff::PrimeField;

use crate::{
cost::{Cost, CostEstimation},
Expand Down Expand Up @@ -29,7 +29,8 @@ pub struct Bdfg21;
impl<M, L> PolynomialCommitmentScheme<M::G1Affine, L> for KzgAs<M, Bdfg21>
where
M: MultiMillerLoop,
M::G1Affine: CurveAffine,
M::Fr: Ord,
M::G1Affine: CurveAffine<ScalarExt = M::Fr>,
L: Loader<M::G1Affine>,
{
type VerifyingKey = KzgSuccinctVerifyingKey<M::G1Affine>;
Expand All @@ -38,7 +39,7 @@ where

fn read_proof<T>(
_: &KzgSuccinctVerifyingKey<M::G1Affine>,
_: &[Query<<M::G1Affine as PrimeCurveAffine>::Scalar>],
_: &[Query<M::Fr>],
transcript: &mut T,
) -> Result<Bdfg21Proof<M::G1Affine, L>, Error>
where
Expand All @@ -51,7 +52,7 @@ where
svk: &KzgSuccinctVerifyingKey<M::G1Affine>,
commitments: &[Msm<M::G1Affine, L>],
z: &L::LoadedScalar,
queries: &[Query<<M::G1Affine as PrimeCurveAffine>::Scalar, L::LoadedScalar>],
queries: &[Query<M::Fr, L::LoadedScalar>],
proof: &Bdfg21Proof<M::G1Affine, L>,
) -> Result<Self::Output, Error> {
let sets = query_sets(queries);
Expand Down
9 changes: 4 additions & 5 deletions snark-verifier/src/pcs/kzg/multiopen/gwc19.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use halo2_curves::group::prime::PrimeCurveAffine;

use crate::{
cost::{Cost, CostEstimation},
loader::{LoadedScalar, Loader},
Expand All @@ -25,7 +23,8 @@ pub struct Gwc19;
impl<M, L> PolynomialCommitmentScheme<M::G1Affine, L> for KzgAs<M, Gwc19>
where
M: MultiMillerLoop,
M::G1Affine: CurveAffine,
M::Fr: Ord,
M::G1Affine: CurveAffine<ScalarExt = M::Fr>,
L: Loader<M::G1Affine>,
{
type VerifyingKey = KzgSuccinctVerifyingKey<M::G1Affine>;
Expand All @@ -34,7 +33,7 @@ where

fn read_proof<T>(
_: &Self::VerifyingKey,
queries: &[Query<<M::G1Affine as PrimeCurveAffine>::Scalar>],
queries: &[Query<M::Fr>],
transcript: &mut T,
) -> Result<Self::Proof, Error>
where
Expand All @@ -47,7 +46,7 @@ where
svk: &Self::VerifyingKey,
commitments: &[Msm<M::G1Affine, L>],
z: &L::LoadedScalar,
queries: &[Query<<M::G1Affine as PrimeCurveAffine>::Scalar, L::LoadedScalar>],
queries: &[Query<M::Fr, L::LoadedScalar>],
proof: &Self::Proof,
) -> Result<Self::Output, Error> {
let sets = query_sets(queries);
Expand Down
2 changes: 1 addition & 1 deletion snark-verifier/src/system/halo2/test/kzg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ where
pub fn main_gate_with_range_with_mock_kzg_accumulator<
C: CurveAffine,
M: MultiMillerLoop<G1Affine = C, Fr = C::ScalarExt, G1 = C::CurveExt>,
>() -> MainGateWithRange<<M::G1Affine as CurveAffine>::ScalarExt>
>() -> MainGateWithRange<M::Fr>
where
M::G2Affine: CurveAffine + SerdeObject,
M::G1Affine: CurveAffine + SerdeObject,
Expand Down

0 comments on commit 8e62ca3

Please sign in to comment.