arithmetic: Allow use of N0
from outside of arithmetic
.
Allow N0 to be const-constructed and expose it outside of `arithmetic` so that `ec` can start using it.
This commit is contained in:
parent
ad1204ec11
commit
af471c9351
@ -18,6 +18,7 @@ mod constant;
|
||||
pub mod bigint;
|
||||
|
||||
pub mod montgomery;
|
||||
|
||||
mod n0;
|
||||
|
||||
#[allow(dead_code)]
|
||||
|
@ -41,7 +41,6 @@ pub(crate) use self::{
|
||||
modulus::{Modulus, OwnedModulus, MODULUS_MAX_LIMBS},
|
||||
private_exponent::PrivateExponent,
|
||||
};
|
||||
use super::n0::N0;
|
||||
use crate::{
|
||||
arithmetic::montgomery::*,
|
||||
bits::BitLength,
|
||||
|
@ -12,7 +12,7 @@
|
||||
// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
||||
// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
use super::{super::n0::N0, BoxedLimbs, Elem, PublicModulus, Unencoded};
|
||||
use super::{BoxedLimbs, Elem, PublicModulus, Unencoded, N0};
|
||||
use crate::{
|
||||
bits::BitLength,
|
||||
cpu, error,
|
||||
@ -126,7 +126,7 @@ impl<M> OwnedModulus<M> {
|
||||
debug_assert_eq!(LIMB_BITS, 32);
|
||||
n_mod_r |= u64::from(n[1]) << 32;
|
||||
}
|
||||
N0::from(unsafe { bn_neg_inv_mod_r_u64(n_mod_r) })
|
||||
N0::precalculated(unsafe { bn_neg_inv_mod_r_u64(n_mod_r) })
|
||||
};
|
||||
|
||||
let len_bits = limb::limbs_minimal_bits(&n);
|
||||
|
@ -12,6 +12,8 @@
|
||||
// OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
||||
// CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
pub use super::n0::N0;
|
||||
|
||||
// Indicates that the element is not encoded; there is no *R* factor
|
||||
// that needs to be canceled out.
|
||||
#[derive(Copy, Clone)]
|
||||
@ -107,10 +109,7 @@ impl ProductEncoding for (RRR, RInverse) {
|
||||
}
|
||||
|
||||
#[allow(unused_imports)]
|
||||
use {
|
||||
super::n0::N0,
|
||||
crate::{bssl, c, limb::Limb},
|
||||
};
|
||||
use crate::{bssl, c, limb::Limb};
|
||||
|
||||
#[cfg(not(any(
|
||||
target_arch = "aarch64",
|
||||
|
@ -16,16 +16,14 @@ use crate::limb::Limb;
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
#[repr(transparent)]
|
||||
pub(in super::super) struct N0([Limb; 2]);
|
||||
pub struct N0([Limb; 2]);
|
||||
|
||||
impl N0 {
|
||||
#[cfg(feature = "alloc")]
|
||||
pub(super) const LIMBS_USED: usize = 64 / crate::limb::LIMB_BITS;
|
||||
}
|
||||
|
||||
impl From<u64> for N0 {
|
||||
#[inline]
|
||||
fn from(n0: u64) -> Self {
|
||||
pub const fn precalculated(n0: u64) -> Self {
|
||||
#[cfg(target_pointer_width = "64")]
|
||||
{
|
||||
Self([n0, 0])
|
||||
|
Loading…
x
Reference in New Issue
Block a user