diff --git a/derive/src/field/arith.rs b/derive/src/field/arith.rs index 3102c578..f2edb888 100644 --- a/derive/src/field/arith.rs +++ b/derive/src/field/arith.rs @@ -177,6 +177,8 @@ fn impl_add(field: &syn::Ident, num_limbs: usize) -> TokenStream { gen.extend(quote! { let ( #d_i, carry) = adc(self.0[#i], rhs.0[#i], #carry); }); }); + // Attempt to subtract the modulus, to ensure the value + // is smaller than the modulus. (0..num_limbs).for_each(|i| { let borrow = select(i == 0, quote! {0}, quote! {borrow}); let d_i = fmtid!("d_{}", i); diff --git a/src/bn256/fq2.rs b/src/bn256/fq2.rs index 72fbe2ae..ad59f424 100644 --- a/src/bn256/fq2.rs +++ b/src/bn256/fq2.rs @@ -178,13 +178,6 @@ impl FromUniformBytes<96> for Fq2 { } } -const ZETA: Fq = Fq::from_raw([ - 0x5763473177fffffe, - 0xd4f263f1acdb5c4f, - 0x59e26bcea0d48bac, - 0x0000000000000000, -]); - #[cfg(test)] mod test { use super::*; diff --git a/src/derive/field/tower.rs b/src/derive/field/tower.rs index cb36af83..00dd101b 100644 --- a/src/derive/field/tower.rs +++ b/src/derive/field/tower.rs @@ -268,7 +268,7 @@ macro_rules! impl_tower2 { impl WithSmallOrderMulGroup<3> for $tower { // $field::ZETA ^2 const ZETA: Self = $tower { - c0: ZETA, + c0: $field::ZETA.mul_const(&$field::ZETA), c1: $field::ZERO, }; } diff --git a/src/pluto_eris/fp12.rs b/src/pluto_eris/fp12.rs index 7dfbde32..9b2bb892 100644 --- a/src/pluto_eris/fp12.rs +++ b/src/pluto_eris/fp12.rs @@ -187,10 +187,16 @@ impl Field for Fp12 { } fn sqrt(&self) -> CtOption { + // The square root method is typically only required for finding y-coordinate + // given the x-coordinate of an EC point. Fields over which we have not + // defined a curve do not need this method. unimplemented!() } fn sqrt_ratio(_num: &Self, _div: &Self) -> (Choice, Self) { + // The square root method is typically only required for finding y-coordinate + // given the x-coordinate of an EC point. Fields over which we have not + // defined a curve do not need this method. unimplemented!() } diff --git a/src/pluto_eris/fp2.rs b/src/pluto_eris/fp2.rs index 542f85a9..bf51954c 100644 --- a/src/pluto_eris/fp2.rs +++ b/src/pluto_eris/fp2.rs @@ -185,16 +185,6 @@ impl Fp2 { } } -const ZETA: Fp = Fp::from_raw([ - 0x8ffff80f80000002, - 0xd9fa5d8a200bc439, - 0x1b50d5e1ff708dc8, - 0xf43f8cddf9a5c478, - 0xa803ca76be3924a5, - 0x0130e0000d7f28e4, - 0x2400000000002400, -]); - #[cfg(test)] mod test { use super::*;