Skip to content

Commit 1aa8ed5

Browse files
authored
rm more useless generics (#878)
* rm more useless generics * rm useless code
1 parent 93fc31e commit 1aa8ed5

File tree

18 files changed

+38
-46
lines changed

18 files changed

+38
-46
lines changed

curves/curve-constraint-tests/src/lib.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ pub mod fields {
205205
AllocationMode::Constant,
206206
];
207207
for &mode in &modes {
208-
let cs = ConstraintSystem::<ConstraintF>::new_ref();
208+
let cs = ConstraintSystem::new_ref();
209209
let mut rng = test_rng();
210210
for i in 0..=maxpower {
211211
let mut a = F::rand(&mut rng);
@@ -246,7 +246,7 @@ pub mod curves {
246246
AllocationMode::Constant,
247247
];
248248
for &mode in &modes {
249-
let cs = ConstraintSystem::<ConstraintF>::new_ref();
249+
let cs = ConstraintSystem::new_ref();
250250

251251
let mut rng = test_rng();
252252
let a_native = C::rand(&mut rng);
@@ -539,8 +539,6 @@ pub mod pairing {
539539
use ark_relations::r1cs::{ConstraintSystem, SynthesisError};
540540
use ark_std::{test_rng, vec::*, UniformRand};
541541

542-
type BasePrimeField<P> = <<P as Pairing>::BaseField as Field>::BasePrimeField;
543-
544542
#[allow(dead_code)]
545543
pub fn bilinearity_test<E: Pairing, P: PairingVar<E>>() -> Result<(), SynthesisError>
546544
where
@@ -554,7 +552,7 @@ pub mod pairing {
554552
AllocationMode::Constant,
555553
];
556554
for &mode in &modes {
557-
let cs = ConstraintSystem::<BasePrimeField<E>>::new_ref();
555+
let cs = ConstraintSystem::new_ref();
558556

559557
let mut rng = test_rng();
560558
let a = E::G1::rand(&mut rng);

curves/mnt6_298/src/curves/mod.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,8 @@ pub type MNT6_298 = MNT6<Config>;
2222
pub struct Config;
2323

2424
impl MNT6Config for Config {
25-
const TWIST: Fp3<Self::Fp3Config> = Fp3::<Self::Fp3Config>::new(Fq::ZERO, Fq::ONE, Fq::ZERO);
26-
const TWIST_COEFF_A: Fp3<Self::Fp3Config> =
27-
Fp3::<Self::Fp3Config>::new(Fq::ZERO, Fq::ZERO, g1::Config::COEFF_A);
25+
const TWIST: Fp3<Self::Fp3Config> = Fp3::new(Fq::ZERO, Fq::ONE, Fq::ZERO);
26+
const TWIST_COEFF_A: Fp3<Self::Fp3Config> = Fp3::new(Fq::ZERO, Fq::ZERO, g1::Config::COEFF_A);
2827

2928
// https://github.com/o1-labs/snarky/blob/9c21ab2bb23874604640740d646a932e813432c3/snarkette/mnt6_80.ml#L118
3029
const ATE_LOOP_COUNT: &'static [i8] = &[

ec/src/hashing/curve_maps/elligator2.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ mod test {
226226
const COEFF_D: F101 = MontFp!("12");
227227

228228
const GENERATOR: Affine<TestElligator2MapToCurveConfig> =
229-
Affine::<TestElligator2MapToCurveConfig>::new_unchecked(MontFp!("23"), MontFp!("24"));
229+
Affine::new_unchecked(MontFp!("23"), MontFp!("24"));
230230

231231
type MontCurveConfig = TestElligator2MapToCurveConfig;
232232
}
@@ -286,10 +286,7 @@ mod test {
286286
// map is not constant on that set.
287287
for current_field_element in 0..101 {
288288
map_range.push(
289-
Elligator2Map::<TestElligator2MapToCurveConfig>::map_to_curve(F101::from(
290-
current_field_element as u64,
291-
))
292-
.unwrap(),
289+
Elligator2Map::map_to_curve(F101::from(current_field_element as u64)).unwrap(),
293290
);
294291
}
295292

ec/src/hashing/curve_maps/swu.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ mod test {
270270
let mut map_range: Vec<Affine<TestSWUMapToCurveConfig>> = vec![];
271271
for current_field_element in 0..127 {
272272
let element = F127::from(current_field_element as u64);
273-
map_range.push(SWUMap::<TestSWUMapToCurveConfig>::map_to_curve(element).unwrap());
273+
map_range.push(SWUMap::map_to_curve(element).unwrap());
274274
}
275275

276276
let mut counts =

ec/src/hashing/curve_maps/wb.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ impl<P: WBConfig> MapToCurve<Projective<P>> for WBMap<P> {
105105
element: <Affine<P> as AffineRepr>::BaseField,
106106
) -> Result<Affine<P>, HashToCurveError> {
107107
// first we need to map the field point to the isogenous curve
108-
let point_on_isogenious_curve = SWUMap::<P::IsogenousCurve>::map_to_curve(element).unwrap();
108+
let point_on_isogenious_curve = SWUMap::map_to_curve(element).unwrap();
109109
P::ISOGENY_MAP.apply(point_on_isogenious_curve)
110110
}
111111
}

ec/src/models/mnt4/g2.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,13 @@ impl<P: MNT4Config> From<G2Affine<P>> for G2Prepared<P> {
5252

5353
let neg_g = -g;
5454
for bit in P::ATE_LOOP_COUNT.iter().skip(1) {
55-
let (r2, coeff) = MNT4::<P>::doubling_for_flipped_miller_loop(&r);
55+
let (r2, coeff) = MNT4::doubling_for_flipped_miller_loop(&r);
5656
g_prep.double_coefficients.push(coeff);
5757
r = r2;
5858

5959
let (r_temp, add_coeff) = match bit {
60-
1 => MNT4::<P>::mixed_addition_for_flipped_miller_loop(&g.x, &g.y, &r),
61-
-1 => MNT4::<P>::mixed_addition_for_flipped_miller_loop(&neg_g.x, &neg_g.y, &r),
60+
1 => MNT4::mixed_addition_for_flipped_miller_loop(&g.x, &g.y, &r),
61+
-1 => MNT4::mixed_addition_for_flipped_miller_loop(&neg_g.x, &neg_g.y, &r),
6262
0 => continue,
6363
_ => unreachable!(),
6464
};
@@ -74,7 +74,7 @@ impl<P: MNT4Config> From<G2Affine<P>> for G2Prepared<P> {
7474
let minus_r_affine_x = r.x * &rz2_inv;
7575
let minus_r_affine_y = -r.y * &rz3_inv;
7676

77-
let add_result = MNT4::<P>::mixed_addition_for_flipped_miller_loop(
77+
let add_result = MNT4::mixed_addition_for_flipped_miller_loop(
7878
&minus_r_affine_x,
7979
&minus_r_affine_y,
8080
&r,

ec/src/models/mnt4/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ pub trait MNT4Config: 'static + Sized {
5454
.map(|(a, b)| (a.into(), b.into()))
5555
.collect::<Vec<_>>();
5656
let result = ark_std::cfg_into_iter!(pairs)
57-
.map(|(a, b)| MNT4::<Self>::ate_miller_loop(&a, &b))
57+
.map(|(a, b)| MNT4::ate_miller_loop(&a, &b))
5858
.product();
5959
MillerLoopOutput(result)
6060
}

ec/src/models/mnt6/g2.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,13 @@ impl<P: MNT6Config> From<G2Affine<P>> for G2Prepared<P> {
5252

5353
let neg_g = -g;
5454
for bit in P::ATE_LOOP_COUNT.iter().skip(1) {
55-
let (r2, coeff) = MNT6::<P>::doubling_for_flipped_miller_loop(&r);
55+
let (r2, coeff) = MNT6::doubling_for_flipped_miller_loop(&r);
5656
g_prep.double_coefficients.push(coeff);
5757
r = r2;
5858

5959
let (r_temp, add_coeff) = match bit {
60-
1 => MNT6::<P>::mixed_addition_for_flipper_miller_loop(&g.x, &g.y, &r),
61-
-1 => MNT6::<P>::mixed_addition_for_flipper_miller_loop(&neg_g.x, &neg_g.y, &r),
60+
1 => MNT6::mixed_addition_for_flipper_miller_loop(&g.x, &g.y, &r),
61+
-1 => MNT6::mixed_addition_for_flipper_miller_loop(&neg_g.x, &neg_g.y, &r),
6262
0 => continue,
6363
_ => unreachable!(),
6464
};
@@ -75,7 +75,7 @@ impl<P: MNT6Config> From<G2Affine<P>> for G2Prepared<P> {
7575
let minus_r_y = -r.y * &rz3_inv;
7676

7777
let add_result =
78-
MNT6::<P>::mixed_addition_for_flipper_miller_loop(&minus_r_x, &minus_r_y, &r);
78+
MNT6::mixed_addition_for_flipper_miller_loop(&minus_r_x, &minus_r_y, &r);
7979
g_prep.addition_coefficients.push(add_result.1);
8080
}
8181

ec/src/models/mnt6/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ pub trait MNT6Config: 'static + Sized {
5555
.map(|(a, b)| (a.into(), b.into()))
5656
.collect::<Vec<_>>();
5757
let result = ark_std::cfg_into_iter!(pairs)
58-
.map(|(a, b)| MNT6::<Self>::ate_miller_loop(&a, &b))
58+
.map(|(a, b)| MNT6::ate_miller_loop(&a, &b))
5959
.product();
6060
MillerLoopOutput(result)
6161
}

ec/src/scalar_mul/variable_base/stream_pippenger.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ impl<G: VariableBaseMSM> HashMapPippenger<G> {
7878
Self {
7979
buffer: HashMap::with_capacity_and_hasher(
8080
max_msm_buffer,
81-
core::hash::BuildHasherDefault::<DefaultHasher>::default(),
81+
core::hash::BuildHasherDefault::default(),
8282
),
8383
result: G::zero(),
8484
buf_size: max_msm_buffer,

0 commit comments

Comments
 (0)