diff --git a/bls12_377/src/fields/fq2.rs b/bls12_377/src/fields/fq2.rs index 52f7e18..fa479e1 100644 --- a/bls12_377/src/fields/fq2.rs +++ b/bls12_377/src/fields/fq2.rs @@ -22,11 +22,8 @@ impl Fp2Config for Fq2Config { #[inline(always)] fn mul_fp_by_nonresidue_in_place(fe: &mut Self::Fp) -> &mut Self::Fp { - let original = *fe; fe.neg_in_place(); - fe.double_in_place(); - fe.double_in_place(); - *fe -= original; + *fe = *fe + fe.double_in_place().double_in_place(); fe } @@ -39,12 +36,12 @@ impl Fp2Config for Fq2Config { } #[inline(always)] - fn add_and_mul_fp_by_nonresidue_plus_one(y: &mut Self::Fp, x: &Self::Fp) { + fn mul_fp_by_nonresidue_plus_one_and_add(y: &mut Self::Fp, x: &Self::Fp) { y.double_in_place().double_in_place().neg_in_place(); *y += x; } - fn add_and_mul_fp_by_nonresidue_in_place(y: &mut Self::Fp, x: &Self::Fp) { + fn mul_fp_by_nonresidue_in_place_and_add(y: &mut Self::Fp, x: &Self::Fp) { let mut original = *y; original.double_in_place().double_in_place(); original += &*y; diff --git a/bls12_381/src/fields/fq2.rs b/bls12_381/src/fields/fq2.rs index 3abfb61..34f0f6c 100644 --- a/bls12_381/src/fields/fq2.rs +++ b/bls12_381/src/fields/fq2.rs @@ -31,11 +31,11 @@ impl Fp2Config for Fq2Config { } #[inline(always)] - fn add_and_mul_fp_by_nonresidue_plus_one(y: &mut Self::Fp, x: &Self::Fp) { + fn mul_fp_by_nonresidue_plus_one_and_add(y: &mut Self::Fp, x: &Self::Fp) { *y = *x; } - fn add_and_mul_fp_by_nonresidue_in_place(y: &mut Self::Fp, x: &Self::Fp) { + fn mul_fp_by_nonresidue_in_place_and_add(y: &mut Self::Fp, x: &Self::Fp) { y.neg_in_place(); *y += x; }