Skip to content

Commit bdffd13

Browse files
committed
fix
1 parent 6606d9b commit bdffd13

File tree

6 files changed

+81
-89
lines changed

6 files changed

+81
-89
lines changed

src/groups/curves/short_weierstrass/bls12/mod.rs

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use ark_ec::{
2-
bls12::{Bls12Parameters, G1Prepared, G2Prepared, TwistType},
2+
bls12::{Bls12Config, G1Prepared, G2Prepared, TwistType},
33
short_weierstrass::Affine as GroupAffine,
44
};
55
use ark_ff::{BitIteratorBE, Field, One};
@@ -13,29 +13,27 @@ use crate::{
1313
use core::fmt::Debug;
1414

1515
/// Represents a projective point in G1.
16-
pub type G1Var<P> =
17-
ProjectiveVar<<P as Bls12Parameters>::G1Parameters, FpVar<<P as Bls12Parameters>::Fp>>;
16+
pub type G1Var<P> = ProjectiveVar<<P as Bls12Config>::G1Config, FpVar<<P as Bls12Config>::Fp>>;
1817

1918
/// Represents an affine point on G1. Should be used only for comparison and
2019
/// when a canonical representation of a point is required, and not for
2120
/// arithmetic.
22-
pub type G1AffineVar<P> =
23-
AffineVar<<P as Bls12Parameters>::G1Parameters, FpVar<<P as Bls12Parameters>::Fp>>;
21+
pub type G1AffineVar<P> = AffineVar<<P as Bls12Config>::G1Config, FpVar<<P as Bls12Config>::Fp>>;
2422

2523
/// Represents a projective point in G2.
26-
pub type G2Var<P> = ProjectiveVar<<P as Bls12Parameters>::G2Parameters, Fp2G<P>>;
24+
pub type G2Var<P> = ProjectiveVar<<P as Bls12Config>::G2Config, Fp2G<P>>;
2725
/// Represents an affine point on G2. Should be used only for comparison and
2826
/// when a canonical representation of a point is required, and not for
2927
/// arithmetic.
30-
pub type G2AffineVar<P> = AffineVar<<P as Bls12Parameters>::G2Parameters, Fp2G<P>>;
28+
pub type G2AffineVar<P> = AffineVar<<P as Bls12Config>::G2Config, Fp2G<P>>;
3129

3230
/// Represents the cached precomputation that can be performed on a G1 element
3331
/// which enables speeding up pairing computation.
3432
#[derive(Derivative)]
3533
#[derivative(Clone(bound = "G1Var<P>: Clone"), Debug(bound = "G1Var<P>: Debug"))]
36-
pub struct G1PreparedVar<P: Bls12Parameters>(pub AffineVar<P::G1Parameters, FpVar<P::Fp>>);
34+
pub struct G1PreparedVar<P: Bls12Config>(pub AffineVar<P::G1Config, FpVar<P::Fp>>);
3735

38-
impl<P: Bls12Parameters> G1PreparedVar<P> {
36+
impl<P: Bls12Config> G1PreparedVar<P> {
3937
/// Returns the value assigned to `self` in the underlying constraint
4038
/// system.
4139
pub fn value(&self) -> Result<G1Prepared<P>, SynthesisError> {
@@ -56,7 +54,7 @@ impl<P: Bls12Parameters> G1PreparedVar<P> {
5654
}
5755
}
5856

59-
impl<P: Bls12Parameters> AllocVar<G1Prepared<P>, P::Fp> for G1PreparedVar<P> {
57+
impl<P: Bls12Config> AllocVar<G1Prepared<P>, P::Fp> for G1PreparedVar<P> {
6058
fn new_variable<T: Borrow<G1Prepared<P>>>(
6159
cs: impl Into<Namespace<P::Fp>>,
6260
f: impl FnOnce() -> Result<T, SynthesisError>,
@@ -78,7 +76,7 @@ impl<P: Bls12Parameters> AllocVar<G1Prepared<P>, P::Fp> for G1PreparedVar<P> {
7876
}
7977
}
8078

81-
impl<P: Bls12Parameters> ToBytesGadget<P::Fp> for G1PreparedVar<P> {
79+
impl<P: Bls12Config> ToBytesGadget<P::Fp> for G1PreparedVar<P> {
8280
#[inline]
8381
#[tracing::instrument(target = "r1cs")]
8482
fn to_bytes(&self) -> Result<Vec<UInt8<P::Fp>>, SynthesisError> {
@@ -101,7 +99,7 @@ impl<P: Bls12Parameters> ToBytesGadget<P::Fp> for G1PreparedVar<P> {
10199
}
102100
}
103101

104-
type Fp2G<P> = Fp2Var<<P as Bls12Parameters>::Fp2Config>;
102+
type Fp2G<P> = Fp2Var<<P as Bls12Config>::Fp2Config>;
105103
type LCoeff<P> = (Fp2G<P>, Fp2G<P>);
106104
/// Represents the cached precomputation that can be performed on a G2 element
107105
/// which enables speeding up pairing computation.
@@ -110,12 +108,12 @@ type LCoeff<P> = (Fp2G<P>, Fp2G<P>);
110108
Clone(bound = "Fp2Var<P::Fp2Config>: Clone"),
111109
Debug(bound = "Fp2Var<P::Fp2Config>: Debug")
112110
)]
113-
pub struct G2PreparedVar<P: Bls12Parameters> {
111+
pub struct G2PreparedVar<P: Bls12Config> {
114112
#[doc(hidden)]
115113
pub ell_coeffs: Vec<LCoeff<P>>,
116114
}
117115

118-
impl<P: Bls12Parameters> AllocVar<G2Prepared<P>, P::Fp> for G2PreparedVar<P> {
116+
impl<P: Bls12Config> AllocVar<G2Prepared<P>, P::Fp> for G2PreparedVar<P> {
119117
#[tracing::instrument(target = "r1cs", skip(cs, f, mode))]
120118
fn new_variable<T: Borrow<G2Prepared<P>>>(
121119
cs: impl Into<Namespace<P::Fp>>,
@@ -173,7 +171,7 @@ impl<P: Bls12Parameters> AllocVar<G2Prepared<P>, P::Fp> for G2PreparedVar<P> {
173171
}
174172
}
175173

176-
impl<P: Bls12Parameters> ToBytesGadget<P::Fp> for G2PreparedVar<P> {
174+
impl<P: Bls12Config> ToBytesGadget<P::Fp> for G2PreparedVar<P> {
177175
#[inline]
178176
#[tracing::instrument(target = "r1cs")]
179177
fn to_bytes(&self) -> Result<Vec<UInt8<P::Fp>>, SynthesisError> {
@@ -196,7 +194,7 @@ impl<P: Bls12Parameters> ToBytesGadget<P::Fp> for G2PreparedVar<P> {
196194
}
197195
}
198196

199-
impl<P: Bls12Parameters> G2PreparedVar<P> {
197+
impl<P: Bls12Config> G2PreparedVar<P> {
200198
/// Constructs `Self` from a `G2Var`.
201199
#[tracing::instrument(target = "r1cs")]
202200
pub fn from_group_var(q: &G2Var<P>) -> Result<Self, SynthesisError> {

src/groups/curves/short_weierstrass/mnt4/mod.rs

Lines changed: 25 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use ark_ec::mnt4::{
22
g2::{AteAdditionCoefficients, AteDoubleCoefficients},
3-
G1Prepared, G2Prepared, MNT4Parameters,
3+
G1Prepared, G2Prepared, MNT4Config,
44
};
55
use ark_ff::Field;
66
use ark_relations::r1cs::{Namespace, SynthesisError};
@@ -15,17 +15,16 @@ use crate::{
1515
use core::borrow::Borrow;
1616

1717
/// Represents a projective point in G1.
18-
pub type G1Var<P> =
19-
ProjectiveVar<<P as MNT4Parameters>::G1Parameters, FpVar<<P as MNT4Parameters>::Fp>>;
18+
pub type G1Var<P> = ProjectiveVar<<P as MNT4Config>::G1Config, FpVar<<P as MNT4Config>::Fp>>;
2019

2120
/// Represents a projective point in G2.
22-
pub type G2Var<P> = ProjectiveVar<<P as MNT4Parameters>::G2Parameters, Fp2G<P>>;
21+
pub type G2Var<P> = ProjectiveVar<<P as MNT4Config>::G2Config, Fp2G<P>>;
2322

2423
/// Represents the cached precomputation that can be performed on a G1 element
2524
/// which enables speeding up pairing computation.
2625
#[derive(Derivative)]
27-
#[derivative(Clone(bound = "P: MNT4Parameters"), Debug(bound = "P: MNT4Parameters"))]
28-
pub struct G1PreparedVar<P: MNT4Parameters> {
26+
#[derivative(Clone(bound = "P: MNT4Config"), Debug(bound = "P: MNT4Config"))]
27+
pub struct G1PreparedVar<P: MNT4Config> {
2928
#[doc(hidden)]
3029
pub x: FpVar<P::Fp>,
3130
#[doc(hidden)]
@@ -36,7 +35,7 @@ pub struct G1PreparedVar<P: MNT4Parameters> {
3635
pub y_twist: Fp2Var<P::Fp2Config>,
3736
}
3837

39-
impl<P: MNT4Parameters> AllocVar<G1Prepared<P>, P::Fp> for G1PreparedVar<P> {
38+
impl<P: MNT4Config> AllocVar<G1Prepared<P>, P::Fp> for G1PreparedVar<P> {
4039
#[tracing::instrument(target = "r1cs", skip(cs, f))]
4140
fn new_variable<T: Borrow<G1Prepared<P>>>(
4241
cs: impl Into<Namespace<P::Fp>>,
@@ -69,7 +68,7 @@ impl<P: MNT4Parameters> AllocVar<G1Prepared<P>, P::Fp> for G1PreparedVar<P> {
6968
}
7069
}
7170

72-
impl<P: MNT4Parameters> G1PreparedVar<P> {
71+
impl<P: MNT4Config> G1PreparedVar<P> {
7372
/// Returns the value assigned to `self` in the underlying constraint
7473
/// system.
7574
pub fn value(&self) -> Result<G1Prepared<P>, SynthesisError> {
@@ -102,7 +101,7 @@ impl<P: MNT4Parameters> G1PreparedVar<P> {
102101
}
103102
}
104103

105-
impl<P: MNT4Parameters> ToBytesGadget<P::Fp> for G1PreparedVar<P> {
104+
impl<P: MNT4Config> ToBytesGadget<P::Fp> for G1PreparedVar<P> {
106105
#[inline]
107106
#[tracing::instrument(target = "r1cs")]
108107
fn to_bytes(&self) -> Result<Vec<UInt8<P::Fp>>, SynthesisError> {
@@ -131,13 +130,13 @@ impl<P: MNT4Parameters> ToBytesGadget<P::Fp> for G1PreparedVar<P> {
131130
}
132131
}
133132

134-
type Fp2G<P> = Fp2Var<<P as MNT4Parameters>::Fp2Config>;
133+
type Fp2G<P> = Fp2Var<<P as MNT4Config>::Fp2Config>;
135134

136135
/// Represents the cached precomputation that can be performed on a G2 element
137136
/// which enables speeding up pairing computation.
138137
#[derive(Derivative)]
139-
#[derivative(Clone(bound = "P: MNT4Parameters"), Debug(bound = "P: MNT4Parameters"))]
140-
pub struct G2PreparedVar<P: MNT4Parameters> {
138+
#[derivative(Clone(bound = "P: MNT4Config"), Debug(bound = "P: MNT4Config"))]
139+
pub struct G2PreparedVar<P: MNT4Config> {
141140
#[doc(hidden)]
142141
pub x: Fp2Var<P::Fp2Config>,
143142
#[doc(hidden)]
@@ -152,7 +151,7 @@ pub struct G2PreparedVar<P: MNT4Parameters> {
152151
pub addition_coefficients: Vec<AteAdditionCoefficientsVar<P>>,
153152
}
154153

155-
impl<P: MNT4Parameters> AllocVar<G2Prepared<P>, P::Fp> for G2PreparedVar<P> {
154+
impl<P: MNT4Config> AllocVar<G2Prepared<P>, P::Fp> for G2PreparedVar<P> {
156155
#[tracing::instrument(target = "r1cs", skip(cs, f))]
157156
fn new_variable<T: Borrow<G2Prepared<P>>>(
158157
cs: impl Into<Namespace<P::Fp>>,
@@ -198,7 +197,7 @@ impl<P: MNT4Parameters> AllocVar<G2Prepared<P>, P::Fp> for G2PreparedVar<P> {
198197
}
199198
}
200199

201-
impl<P: MNT4Parameters> ToBytesGadget<P::Fp> for G2PreparedVar<P> {
200+
impl<P: MNT4Config> ToBytesGadget<P::Fp> for G2PreparedVar<P> {
202201
#[inline]
203202
#[tracing::instrument(target = "r1cs")]
204203
fn to_bytes(&self) -> Result<Vec<UInt8<P::Fp>>, SynthesisError> {
@@ -241,7 +240,7 @@ impl<P: MNT4Parameters> ToBytesGadget<P::Fp> for G2PreparedVar<P> {
241240
}
242241
}
243242

244-
impl<P: MNT4Parameters> G2PreparedVar<P> {
243+
impl<P: MNT4Config> G2PreparedVar<P> {
245244
/// Returns the value assigned to `self` in the underlying constraint
246245
/// system.
247246
pub fn value(&self) -> Result<G2Prepared<P>, SynthesisError> {
@@ -341,15 +340,15 @@ impl<P: MNT4Parameters> G2PreparedVar<P> {
341340

342341
#[doc(hidden)]
343342
#[derive(Derivative)]
344-
#[derivative(Clone(bound = "P: MNT4Parameters"), Debug(bound = "P: MNT4Parameters"))]
345-
pub struct AteDoubleCoefficientsVar<P: MNT4Parameters> {
343+
#[derivative(Clone(bound = "P: MNT4Config"), Debug(bound = "P: MNT4Config"))]
344+
pub struct AteDoubleCoefficientsVar<P: MNT4Config> {
346345
pub c_h: Fp2Var<P::Fp2Config>,
347346
pub c_4c: Fp2Var<P::Fp2Config>,
348347
pub c_j: Fp2Var<P::Fp2Config>,
349348
pub c_l: Fp2Var<P::Fp2Config>,
350349
}
351350

352-
impl<P: MNT4Parameters> AllocVar<AteDoubleCoefficients<P>, P::Fp> for AteDoubleCoefficientsVar<P> {
351+
impl<P: MNT4Config> AllocVar<AteDoubleCoefficients<P>, P::Fp> for AteDoubleCoefficientsVar<P> {
353352
#[tracing::instrument(target = "r1cs", skip(cs, f))]
354353
fn new_variable<T: Borrow<AteDoubleCoefficients<P>>>(
355354
cs: impl Into<Namespace<P::Fp>>,
@@ -376,7 +375,7 @@ impl<P: MNT4Parameters> AllocVar<AteDoubleCoefficients<P>, P::Fp> for AteDoubleC
376375
}
377376
}
378377

379-
impl<P: MNT4Parameters> ToBytesGadget<P::Fp> for AteDoubleCoefficientsVar<P> {
378+
impl<P: MNT4Config> ToBytesGadget<P::Fp> for AteDoubleCoefficientsVar<P> {
380379
#[inline]
381380
#[tracing::instrument(target = "r1cs")]
382381
fn to_bytes(&self) -> Result<Vec<UInt8<P::Fp>>, SynthesisError> {
@@ -405,7 +404,7 @@ impl<P: MNT4Parameters> ToBytesGadget<P::Fp> for AteDoubleCoefficientsVar<P> {
405404
}
406405
}
407406

408-
impl<P: MNT4Parameters> AteDoubleCoefficientsVar<P> {
407+
impl<P: MNT4Config> AteDoubleCoefficientsVar<P> {
409408
/// Returns the value assigned to `self` in the underlying constraint
410409
/// system.
411410
pub fn value(&self) -> Result<AteDoubleCoefficients<P>, SynthesisError> {
@@ -426,15 +425,13 @@ impl<P: MNT4Parameters> AteDoubleCoefficientsVar<P> {
426425

427426
#[doc(hidden)]
428427
#[derive(Derivative)]
429-
#[derivative(Clone(bound = "P: MNT4Parameters"), Debug(bound = "P: MNT4Parameters"))]
430-
pub struct AteAdditionCoefficientsVar<P: MNT4Parameters> {
428+
#[derivative(Clone(bound = "P: MNT4Config"), Debug(bound = "P: MNT4Config"))]
429+
pub struct AteAdditionCoefficientsVar<P: MNT4Config> {
431430
pub c_l1: Fp2Var<P::Fp2Config>,
432431
pub c_rz: Fp2Var<P::Fp2Config>,
433432
}
434433

435-
impl<P: MNT4Parameters> AllocVar<AteAdditionCoefficients<P>, P::Fp>
436-
for AteAdditionCoefficientsVar<P>
437-
{
434+
impl<P: MNT4Config> AllocVar<AteAdditionCoefficients<P>, P::Fp> for AteAdditionCoefficientsVar<P> {
438435
#[tracing::instrument(target = "r1cs", skip(cs, f))]
439436
fn new_variable<T: Borrow<AteAdditionCoefficients<P>>>(
440437
cs: impl Into<Namespace<P::Fp>>,
@@ -455,7 +452,7 @@ impl<P: MNT4Parameters> AllocVar<AteAdditionCoefficients<P>, P::Fp>
455452
}
456453
}
457454

458-
impl<P: MNT4Parameters> ToBytesGadget<P::Fp> for AteAdditionCoefficientsVar<P> {
455+
impl<P: MNT4Config> ToBytesGadget<P::Fp> for AteAdditionCoefficientsVar<P> {
459456
#[inline]
460457
#[tracing::instrument(target = "r1cs")]
461458
fn to_bytes(&self) -> Result<Vec<UInt8<P::Fp>>, SynthesisError> {
@@ -476,7 +473,7 @@ impl<P: MNT4Parameters> ToBytesGadget<P::Fp> for AteAdditionCoefficientsVar<P> {
476473
}
477474
}
478475

479-
impl<P: MNT4Parameters> AteAdditionCoefficientsVar<P> {
476+
impl<P: MNT4Config> AteAdditionCoefficientsVar<P> {
480477
/// Returns the value assigned to `self` in the underlying constraint
481478
/// system.
482479
pub fn value(&self) -> Result<AteAdditionCoefficients<P>, SynthesisError> {
@@ -486,7 +483,7 @@ impl<P: MNT4Parameters> AteAdditionCoefficientsVar<P> {
486483
}
487484

488485
#[doc(hidden)]
489-
pub struct G2ProjectiveExtendedVar<P: MNT4Parameters> {
486+
pub struct G2ProjectiveExtendedVar<P: MNT4Config> {
490487
pub x: Fp2Var<P::Fp2Config>,
491488
pub y: Fp2Var<P::Fp2Config>,
492489
pub z: Fp2Var<P::Fp2Config>,

0 commit comments

Comments
 (0)