diff --git a/src/field/extension_field/mod.rs b/src/field/extension_field/mod.rs index 7d1f1adf..67329c3c 100644 --- a/src/field/extension_field/mod.rs +++ b/src/field/extension_field/mod.rs @@ -86,6 +86,7 @@ pub fn unflatten(l: &[F]) -> Vec where F: Extendable, { + debug_assert_eq!(l.len() % D, 0); l.chunks_exact(D) .map(|c| { let mut arr = [F::ZERO; D]; diff --git a/src/field/extension_field/quadratic.rs b/src/field/extension_field/quadratic.rs index 0b6f26f0..90c41f9d 100644 --- a/src/field/extension_field/quadratic.rs +++ b/src/field/extension_field/quadratic.rs @@ -32,8 +32,6 @@ pub trait QuadraticFieldExtension: Self::from_canonical_representation([a0, a1 * z]) } - - fn scalar_mul(&self, c: Self::BaseField) -> Self; } #[derive(Copy, Clone)] @@ -52,11 +50,6 @@ impl QuadraticFieldExtension for QuadraticCrandallField { fn from_canonical_representation(v: [Self::BaseField; 2]) -> Self { Self(v) } - - fn scalar_mul(&self, c: Self::BaseField) -> Self { - let [a0, a1] = self.to_canonical_representation(); - Self([a0 * c, a1 * c]) - } } impl From<::BaseField> for QuadraticCrandallField { @@ -104,7 +97,7 @@ impl Field for QuadraticCrandallField { let a_pow_r = a_pow_r_minus_1 * *self; debug_assert!(a_pow_r.is_in_basefield()); - Some(a_pow_r_minus_1.scalar_mul(a_pow_r.0[0].inverse())) + Some(a_pow_r_minus_1 * a_pow_r.0[0].inverse().into()) } // It's important that the primitive roots of unity are the same as the ones in the base field, @@ -273,7 +266,7 @@ mod tests { assert_eq!(-x, F::ZERO - x); assert_eq!( x + x, - x.scalar_mul(::BaseField::TWO) + x * ::BaseField::TWO.into() ); assert_eq!(x * (-x), -x.square()); assert_eq!(x + y, y + x); diff --git a/src/field/extension_field/quartic.rs b/src/field/extension_field/quartic.rs index ecf9bfd2..c317db32 100644 --- a/src/field/extension_field/quartic.rs +++ b/src/field/extension_field/quartic.rs @@ -38,8 +38,6 @@ pub trait QuarticFieldExtension: Field + From<::B Self::from_canonical_representation([b0, b1, b2, b3]) } - - fn scalar_mul(&self, c: Self::BaseField) -> Self; } #[derive(Copy, Clone)] @@ -58,11 +56,6 @@ impl QuarticFieldExtension for QuarticCrandallField { fn from_canonical_representation(v: [Self::BaseField; 4]) -> Self { Self(v) } - - fn scalar_mul(&self, c: Self::BaseField) -> Self { - let [a0, a1, a2, a3] = self.to_canonical_representation(); - Self([a0 * c, a1 * c, a2 * c, a3 * c]) - } } impl From<::BaseField> for QuarticCrandallField { @@ -142,7 +135,7 @@ impl Field for QuarticCrandallField { let a_pow_r = a_pow_r_minus_1 * *self; debug_assert!(a_pow_r.is_in_basefield()); - Some(a_pow_r_minus_1.scalar_mul(a_pow_r.0[0].inverse())) + Some(a_pow_r_minus_1 * a_pow_r.0[0].inverse().into()) } // It's important that the primitive roots of unity are the same as the ones in the base field, @@ -329,7 +322,7 @@ mod tests { assert_eq!(-x, F::ZERO - x); assert_eq!( x + x, - x.scalar_mul(::BaseField::TWO) + x * ::BaseField::TWO.into() ); assert_eq!(x * (-x), -x.square()); assert_eq!(x + y, y + x);