Skip to content

Commit

Permalink
rm generics when useless (#877)
Browse files Browse the repository at this point in the history
  • Loading branch information
tcoratger authored Nov 14, 2024
1 parent 3468974 commit e6d2f33
Show file tree
Hide file tree
Showing 11 changed files with 21 additions and 21 deletions.
8 changes: 4 additions & 4 deletions curves/curve-constraint-tests/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -406,8 +406,8 @@ pub mod curves {

let cs = ConstraintSystem::<<P::BaseField as Field>::BasePrimeField>::new_ref();

let a = SWProjective::<P>::rand(&mut rng);
let b = SWProjective::<P>::rand(&mut rng);
let a = SWProjective::rand(&mut rng);
let b = SWProjective::rand(&mut rng);
let a_affine = a.into_affine();
let b_affine = b.into_affine();

Expand Down Expand Up @@ -477,8 +477,8 @@ pub mod curves {

let cs = ConstraintSystem::<<P::BaseField as Field>::BasePrimeField>::new_ref();

let a = TEProjective::<P>::rand(&mut rng);
let b = TEProjective::<P>::rand(&mut rng);
let a = TEProjective::rand(&mut rng);
let b = TEProjective::rand(&mut rng);
let a_affine = a.into_affine();
let b_affine = b.into_affine();

Expand Down
2 changes: 1 addition & 1 deletion ec/src/hashing/curve_maps/elligator2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ impl<P: Elligator2Config> MapToCurve<Projective<P>> for Elligator2Map<P> {
(v, w)
};

let point_on_curve = Affine::<P>::new_unchecked(v, w);
let point_on_curve = Affine::new_unchecked(v, w);
debug_assert!(
point_on_curve.is_on_curve(),
"Elligator2 mapped to a point off the curve"
Expand Down
2 changes: 1 addition & 1 deletion ec/src/hashing/curve_maps/swu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ impl<P: SWUConfig> MapToCurve<Projective<P>> for SWUMap<P> {
} else {
y
};
let point_on_curve = Affine::<P>::new_unchecked(x_affine, y_affine);
let point_on_curve = Affine::new_unchecked(x_affine, y_affine);
debug_assert!(
point_on_curve.is_on_curve(),
"swu mapped to a point off the curve"
Expand Down
2 changes: 1 addition & 1 deletion ec/src/hashing/curve_maps/wb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ where
batch_inversion(&mut v);
let img_x = x_num.evaluate(&x) * v[0];
let img_y = (y_num.evaluate(&x) * y) * v[1];
Ok(Affine::<Codomain>::new_unchecked(img_x, img_y))
Ok(Affine::new_unchecked(img_x, img_y))
},
None => Ok(Affine::identity()),
}
Expand Down
2 changes: 1 addition & 1 deletion ec/src/models/short_weierstrass/group.rs
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ impl<P: SWCurveConfig> CanonicalSerialize for Projective<P> {
writer: W,
compress: Compress,
) -> Result<(), SerializationError> {
let aff = Affine::<P>::from(*self);
let aff = Affine::from(*self);
P::serialize_with_mode(&aff, writer, compress)
}

Expand Down
4 changes: 2 additions & 2 deletions ec/src/models/short_weierstrass/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,9 @@ pub trait SWCurveConfig: super::CurveConfig {
},
};
if flags.is_infinity() {
Ok(Affine::<Self>::identity())
Ok(Affine::identity())
} else {
let point = Affine::<Self>::new_unchecked(x, y);
let point = Affine::new_unchecked(x, y);
if let Validate::Yes = validate {
point.check()?;
}
Expand Down
2 changes: 1 addition & 1 deletion ec/src/models/twisted_edwards/group.rs
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ impl<P: TECurveConfig> CanonicalSerialize for Projective<P> {
writer: W,
compress: Compress,
) -> Result<(), SerializationError> {
let aff = Affine::<P>::from(*self);
let aff = Affine::from(*self);
P::serialize_with_mode(&aff, writer, compress)
}

Expand Down
6 changes: 3 additions & 3 deletions ec/src/models/twisted_edwards/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ pub trait TECurveConfig: super::CurveConfig {
/// Default implementation of group multiplication for projective
/// coordinates
fn mul_projective(base: &Projective<Self>, scalar: &[u64]) -> Projective<Self> {
let mut res = Projective::<Self>::zero();
let mut res = Projective::zero();
for b in ark_ff::BitIteratorBE::without_leading_zeros(scalar) {
res.double_in_place();
if b {
Expand All @@ -74,7 +74,7 @@ pub trait TECurveConfig: super::CurveConfig {
/// Default implementation of group multiplication for affine
/// coordinates
fn mul_affine(base: &Affine<Self>, scalar: &[u64]) -> Projective<Self> {
let mut res = Projective::<Self>::zero();
let mut res = Projective::zero();
for b in ark_ff::BitIteratorBE::without_leading_zeros(scalar) {
res.double_in_place();
if b {
Expand Down Expand Up @@ -141,7 +141,7 @@ pub trait TECurveConfig: super::CurveConfig {
(x, y)
},
};
let point = Affine::<Self>::new_unchecked(x, y);
let point = Affine::new_unchecked(x, y);
if let Validate::Yes = validate {
point.check()?;
}
Expand Down
4 changes: 2 additions & 2 deletions ec/src/scalar_mul/glv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ pub trait GLVConfig: Send + Sync + 'static + SWCurveConfig {
let iter_k1 = ark_ff::BitIteratorBE::new(k1.into_bigint());
let iter_k2 = ark_ff::BitIteratorBE::new(k2.into_bigint());

let mut res = Projective::<Self>::zero();
let mut res = Projective::zero();
let mut skip_zeros = true;
for pair in iter_k1.zip(iter_k2) {
if skip_zeros && pair == (false, false) {
Expand Down Expand Up @@ -141,7 +141,7 @@ pub trait GLVConfig: Send + Sync + 'static + SWCurveConfig {
let iter_k1 = ark_ff::BitIteratorBE::new(k1.into_bigint());
let iter_k2 = ark_ff::BitIteratorBE::new(k2.into_bigint());

let mut res = Projective::<Self>::zero();
let mut res = Projective::zero();
let mut skip_zeros = true;
for pair in iter_k1.zip(iter_k2) {
if skip_zeros && pair == (false, false) {
Expand Down
4 changes: 2 additions & 2 deletions ec/src/scalar_mul/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pub fn sw_double_and_add_affine<P: SWCurveConfig>(
base: &Affine<P>,
scalar: impl AsRef<[u64]>,
) -> Projective<P> {
let mut res = Projective::<P>::zero();
let mut res = Projective::zero();
for b in ark_ff::BitIteratorBE::without_leading_zeros(scalar) {
res.double_in_place();
if b {
Expand All @@ -49,7 +49,7 @@ pub fn sw_double_and_add_projective<P: SWCurveConfig>(
base: &Projective<P>,
scalar: impl AsRef<[u64]>,
) -> Projective<P> {
let mut res = Projective::<P>::zero();
let mut res = Projective::zero();
for b in ark_ff::BitIteratorBE::without_leading_zeros(scalar) {
res.double_in_place();
if b {
Expand Down
6 changes: 3 additions & 3 deletions test-templates/src/glv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ pub fn glv_scalar_decomposition<P: GLVConfig>() {
}

pub fn glv_endomorphism_eigenvalue<P: GLVConfig>() {
let g = Projective::<P>::generator();
let g = Projective::generator();
let endo_g = <P as GLVConfig>::endomorphism(&g);
assert_eq!(endo_g, g.mul(P::LAMBDA));
}
Expand All @@ -52,7 +52,7 @@ pub fn glv_projective<P: GLVConfig>() {
// check that glv_mul indeed computes the scalar multiplication
let mut rng = ark_std::test_rng();

let g = Projective::<P>::generator();
let g = Projective::generator();
for _i in 0..100 {
let k = P::ScalarField::rand(&mut rng);

Expand All @@ -66,7 +66,7 @@ pub fn glv_affine<P: GLVConfig>() {
// check that glv_mul indeed computes the scalar multiplication
let mut rng = ark_std::test_rng();

let g = Affine::<P>::generator();
let g = Affine::generator();
for _i in 0..100 {
let k = P::ScalarField::rand(&mut rng);

Expand Down

0 comments on commit e6d2f33

Please sign in to comment.