Skip to content

Commit 67df311

Browse files
authored
Add ConstMontyForm::MODULUS constant (#982)
Adds an inherent associated constant for accessing the modulus. See also: #980
1 parent 224a40c commit 67df311

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

codecov.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
coverage:
2+
status:
3+
project:
4+
default:
5+
threshold: 1%

src/modular/const_monty_form.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use super::{
1515
div_by_2::div_by_2,
1616
reduction::{montgomery_reduction, montgomery_retrieve},
1717
};
18-
use crate::{ConstChoice, ConstOne, ConstZero, One, Uint, Zero};
18+
use crate::{ConstChoice, ConstOne, ConstZero, Odd, One, Uint, Zero};
1919
use core::{fmt::Debug, marker::PhantomData};
2020
use subtle::{Choice, ConditionallySelectable, ConstantTimeEq};
2121

@@ -77,6 +77,9 @@ impl<MOD: ConstMontyParams<LIMBS>, const LIMBS: usize> ConstMontyForm<MOD, LIMBS
7777
phantom: PhantomData,
7878
};
7979

80+
/// Modulus as an unsigned integer.
81+
pub const MODULUS: Odd<Uint<LIMBS>> = *MOD::PARAMS.modulus();
82+
8083
/// Instantiates a new [`ConstMontyForm`] that represents this `integer` mod `MOD`.
8184
pub const fn new(integer: &Uint<LIMBS>) -> Self {
8285
let product = integer.widening_mul(&MOD::PARAMS.r2);

0 commit comments

Comments
 (0)