diff --git a/src/core/fields/cm31.rs b/src/core/fields/cm31.rs index a294ab1f0..c585855b6 100644 --- a/src/core/fields/cm31.rs +++ b/src/core/fields/cm31.rs @@ -1,4 +1,4 @@ -use std::fmt::Display; +use std::fmt::{Debug, Display}; use std::ops::{ Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Rem, RemAssign, Sub, SubAssign, }; @@ -12,7 +12,7 @@ pub const P2: u64 = 4611686014132420609; // (2 ** 31 - 1) ** 2 /// Complex extension field of M31. /// Equivalent to M31\[x\] over (x^2 + 1) as the irreducible polynomial. /// Represented as (a, b) of a + bi. -#[derive(Copy, Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)] +#[derive(Copy, Clone, Default, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct CM31(pub M31, pub M31); impl_field!(CM31, P2); @@ -34,6 +34,12 @@ impl Display for CM31 { } } +impl Debug for CM31 { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "{} + {}i", self.0, self.1) + } +} + impl Mul for CM31 { type Output = Self; diff --git a/src/core/fields/qm31.rs b/src/core/fields/qm31.rs index 0692f3847..b2df12dd2 100644 --- a/src/core/fields/qm31.rs +++ b/src/core/fields/qm31.rs @@ -1,4 +1,4 @@ -use std::fmt::Display; +use std::fmt::{Debug, Display}; use std::ops::{ Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Rem, RemAssign, Sub, SubAssign, }; @@ -15,7 +15,7 @@ pub const R: CM31 = CM31::from_u32_unchecked(1, 2); /// Extension field of CM31. /// Equivalent to CM31\[x\] over (x^2 - 1 - 2i) as the irreducible polynomial. /// Represented as ((a, b), (c, d)) of (a + bi) + (c + di)u. -#[derive(Copy, Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)] +#[derive(Copy, Clone, Default, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct QM31(pub CM31, pub CM31); pub type SecureField = QM31; @@ -49,6 +49,12 @@ impl Display for QM31 { } } +impl Debug for QM31 { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "({}) + ({})u", self.0, self.1) + } +} + impl Mul for QM31 { type Output = Self;