crypto_bigint/modular/fixed_monty_form/
neg.rs1use super::FixedMontyForm;
4use core::ops::Neg;
5
6impl<const LIMBS: usize> FixedMontyForm<LIMBS> {
7 #[must_use]
9 pub const fn neg(&self) -> Self {
10 Self {
11 montgomery_form: self
12 .montgomery_form
13 .neg_mod(self.params.modulus.as_nz_ref()),
14 params: self.params,
15 }
16 }
17}
18
19impl<const LIMBS: usize> Neg for FixedMontyForm<LIMBS> {
20 type Output = Self;
21 fn neg(self) -> Self {
22 FixedMontyForm::neg(&self)
23 }
24}
25
26impl<const LIMBS: usize> Neg for &FixedMontyForm<LIMBS> {
27 type Output = FixedMontyForm<LIMBS>;
28 fn neg(self) -> FixedMontyForm<LIMBS> {
29 FixedMontyForm::neg(self)
30 }
31}