use core::ops::{Add, AddAssign, Mul, MulAssign, Sub, SubAssign};
pub const P: u64 = 0xFFFF_FFFF_0000_0001;
const NEG_ORDER: u64 = P.wrapping_neg();
#[derive(Clone, Copy, Default, PartialEq, Eq, Hash)]
#[repr(transparent)]
pub struct Goldilocks {
value: u64,
}
impl Goldilocks {
pub const ZERO: Self = Self { value: 0 };
#[inline]
pub const fn new(value: u64) -> Self {
Self { value }
}
#[inline]
pub fn as_canonical_u64(self) -> u64 {
self.value.wrapping_sub(P & u64::from(self.value >= P).wrapping_neg())
}