use crate::modulus::barrett::BarrettPrecomp; /// Montgomery is a generic struct storing /// an element in the Montgomery domain. #[derive(Clone, Copy, Debug, PartialEq, Eq)] pub struct Montgomery(pub O); /// Implements helper methods on the struct Montgomery. impl Montgomery{ #[inline(always)] pub fn new(lhs: O) -> Self{ Self(lhs) } #[inline(always)] pub fn value(&self) -> &O{ &self.0 } pub fn value_mut(&mut self) -> &mut O{ &mut self.0 } } /// MontgomeryPrecomp is a generic struct storing /// precomputations for Montgomery arithmetic. #[derive(Clone, Copy, Debug, PartialEq, Eq)] pub struct MontgomeryPrecomp{ pub q: O, pub barrett: BarrettPrecomp, pub q_inv: O, pub one: Montgomery, pub minus_one: Montgomery, }