diff --git a/src/const_choice.rs b/src/const_choice.rs index e3203fd75..1428ba2c8 100644 --- a/src/const_choice.rs +++ b/src/const_choice.rs @@ -1,6 +1,6 @@ use subtle::{Choice, CtOption}; -use crate::{modular::BernsteinYangInverter, Limb, NonZero, Odd, Uint, WideWord, Word}; +use crate::{modular::SafeGcdInverter, Limb, NonZero, Odd, Uint, WideWord, Word}; /// A boolean value returned by constant-time `const fn`s. // TODO: should be replaced by `subtle::Choice` or `CtOption` @@ -428,7 +428,7 @@ impl ConstCtOption> { } impl - ConstCtOption> + ConstCtOption> { /// Returns the contained value, consuming the `self` value. /// @@ -437,7 +437,7 @@ impl /// Panics if the value is none with a custom panic message provided by /// `msg`. #[inline] - pub const fn expect(self, msg: &str) -> BernsteinYangInverter { + pub const fn expect(self, msg: &str) -> SafeGcdInverter { assert!(self.is_some.is_true_vartime(), "{}", msg); self.value } diff --git a/src/macros.rs b/src/macros.rs index 5fa7a2fbc..66d62de5c 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -15,10 +15,10 @@ macro_rules! nlimbs { /// We need to ensure that: /// /// ```text -/// $bits <= (bernstein_yang_nlimbs($bits) * 62) - 64 +/// $bits <= (safegcd_nlimbs($bits) * 62) - 64 /// ``` // TODO(tarcieri): replace with `generic_const_exprs` (rust-lang/rust#76560) when stable -macro_rules! bernstein_yang_nlimbs { +macro_rules! safegcd_nlimbs { ($bits:expr) => { ($bits + 64).div_ceil(62) }; diff --git a/src/modular.rs b/src/modular.rs index 6b22279a3..dbd5c804b 100644 --- a/src/modular.rs +++ b/src/modular.rs @@ -21,26 +21,26 @@ mod monty_form; mod reduction; mod add; -pub(crate) mod bernstein_yang; mod div_by_2; mod mul; mod pow; +pub(crate) mod safegcd; mod sub; #[cfg(feature = "alloc")] pub(crate) mod boxed_monty_form; pub use self::{ - bernstein_yang::BernsteinYangInverter, const_monty_form::{inv::ConstMontyFormInverter, ConstMontyForm, ConstMontyParams}, monty_form::{inv::MontyFormInverter, MontyForm, MontyParams}, reduction::montgomery_reduction, + safegcd::SafeGcdInverter, }; #[cfg(feature = "alloc")] pub use self::{ - bernstein_yang::boxed::BoxedBernsteinYangInverter, boxed_monty_form::{BoxedMontyForm, BoxedMontyParams}, + safegcd::boxed::BoxedSafeGcdInverter, }; /// A generalization for numbers kept in optimized representations (e.g. Montgomery) diff --git a/src/modular/boxed_monty_form/inv.rs b/src/modular/boxed_monty_form/inv.rs index 516cf899f..38bf308fd 100644 --- a/src/modular/boxed_monty_form/inv.rs +++ b/src/modular/boxed_monty_form/inv.rs @@ -2,7 +2,7 @@ use super::{BoxedMontyForm, BoxedMontyParams}; use crate::{ - modular::BoxedBernsteinYangInverter, Invert, Inverter, PrecomputeInverter, + modular::BoxedSafeGcdInverter, Invert, Inverter, PrecomputeInverter, PrecomputeInverterWithAdjuster, }; use alloc::sync::Arc; @@ -40,7 +40,7 @@ impl PrecomputeInverter for BoxedMontyParams { /// Bernstein-Yang inverter which inverts [`DynResidue`] types. pub struct BoxedMontyFormInverter { /// Precomputed Bernstein-Yang inverter. - inverter: BoxedBernsteinYangInverter, + inverter: BoxedSafeGcdInverter, /// Residue parameters. params: Arc, diff --git a/src/modular/const_monty_form.rs b/src/modular/const_monty_form.rs index 6c3c4c6cb..ae4d2a7a1 100644 --- a/src/modular/const_monty_form.rs +++ b/src/modular/const_monty_form.rs @@ -8,7 +8,7 @@ mod pow; mod sub; use self::inv::ConstMontyFormInverter; -use super::{div_by_2::div_by_2, reduction::montgomery_reduction, BernsteinYangInverter, Retrieve}; +use super::{div_by_2::div_by_2, reduction::montgomery_reduction, Retrieve, SafeGcdInverter}; use crate::{ConstZero, Limb, Odd, PrecomputeInverter, Uint}; use core::{fmt::Debug, marker::PhantomData}; use subtle::{Choice, ConditionallySelectable, ConstantTimeEq}; @@ -56,7 +56,7 @@ pub trait ConstMontyParams: fn precompute_inverter() -> ConstMontyFormInverter where Odd>: PrecomputeInverter< - Inverter = BernsteinYangInverter, + Inverter = SafeGcdInverter, Output = Uint, >, { diff --git a/src/modular/const_monty_form/inv.rs b/src/modular/const_monty_form/inv.rs index 108fd6d8d..2928673a1 100644 --- a/src/modular/const_monty_form/inv.rs +++ b/src/modular/const_monty_form/inv.rs @@ -2,7 +2,7 @@ use super::{ConstMontyForm, ConstMontyParams}; use crate::{ - modular::BernsteinYangInverter, ConstCtOption, Invert, Inverter, Odd, PrecomputeInverter, Uint, + modular::SafeGcdInverter, ConstCtOption, Invert, Inverter, Odd, PrecomputeInverter, Uint, }; use core::{fmt, marker::PhantomData}; use subtle::CtOption; @@ -11,7 +11,7 @@ impl, const SAT_LIMBS: usize, const UNSAT_LIMBS ConstMontyForm where Odd>: PrecomputeInverter< - Inverter = BernsteinYangInverter, + Inverter = SafeGcdInverter, Output = Uint, >, { @@ -39,7 +39,7 @@ impl, const SAT_LIMBS: usize, const UNSAT_LIMBS for ConstMontyForm where Odd>: PrecomputeInverter< - Inverter = BernsteinYangInverter, + Inverter = SafeGcdInverter, Output = Uint, >, { @@ -62,13 +62,13 @@ impl, const SAT_LIMBS: usize, const UNSAT_LIMBS ConstMontyFormInverter where Odd>: PrecomputeInverter< - Inverter = BernsteinYangInverter, + Inverter = SafeGcdInverter, Output = Uint, >, { /// Create a new [`ConstMontyFormInverter`] for the given [`ConstMontyParams`]. pub const fn new() -> Self { - let inverter = BernsteinYangInverter::new(&MOD::MODULUS, &MOD::R2); + let inverter = SafeGcdInverter::new(&MOD::MODULUS, &MOD::R2); Self { inverter, @@ -96,7 +96,7 @@ impl, const SAT_LIMBS: usize, const UNSAT_LIMBS for ConstMontyFormInverter where Odd>: PrecomputeInverter< - Inverter = BernsteinYangInverter, + Inverter = SafeGcdInverter, Output = Uint, >, { @@ -111,7 +111,7 @@ impl, const SAT_LIMBS: usize, const UNSAT_LIMBS for ConstMontyFormInverter where Odd>: PrecomputeInverter< - Inverter = BernsteinYangInverter, + Inverter = SafeGcdInverter, Output = Uint, >, { diff --git a/src/modular/monty_form/inv.rs b/src/modular/monty_form/inv.rs index 80c7ee4dd..0238131f2 100644 --- a/src/modular/monty_form/inv.rs +++ b/src/modular/monty_form/inv.rs @@ -2,8 +2,8 @@ use super::{MontyForm, MontyParams}; use crate::{ - modular::BernsteinYangInverter, traits::Invert, ConstCtOption, Inverter, Odd, - PrecomputeInverter, PrecomputeInverterWithAdjuster, Uint, + modular::SafeGcdInverter, traits::Invert, ConstCtOption, Inverter, Odd, PrecomputeInverter, + PrecomputeInverterWithAdjuster, Uint, }; use core::fmt; use subtle::CtOption; @@ -11,7 +11,7 @@ use subtle::CtOption; impl MontyForm where Odd>: PrecomputeInverter< - Inverter = BernsteinYangInverter, + Inverter = SafeGcdInverter, Output = Uint, >, { @@ -40,7 +40,7 @@ where impl Invert for MontyForm where Odd>: PrecomputeInverter< - Inverter = BernsteinYangInverter, + Inverter = SafeGcdInverter, Output = Uint, >, { @@ -97,7 +97,7 @@ where impl fmt::Debug for MontyFormInverter where Odd>: PrecomputeInverter< - Inverter = BernsteinYangInverter, + Inverter = SafeGcdInverter, Output = Uint, >, { diff --git a/src/modular/bernstein_yang.rs b/src/modular/safegcd.rs similarity index 97% rename from src/modular/bernstein_yang.rs rename to src/modular/safegcd.rs index 922a1564e..c280bdde5 100644 --- a/src/modular/bernstein_yang.rs +++ b/src/modular/safegcd.rs @@ -1,7 +1,8 @@ -//! Implementation of Bernstein-Yang modular inversion and GCD algorithm as described in: -//! . +//! Implementation of Bernstein-Yang modular inversion and GCD algorithm (a.k.a. safegcd) +//! as described in: . //! //! Adapted from the Apache 2.0+MIT licensed implementation originally from: +//! //! //! //! Copyright (c) 2023 Privacy Scaling Explorations Team @@ -44,7 +45,7 @@ use subtle::CtOption; /// - P. Wuille, "The safegcd implementation in libsecp256k1 explained", /// #[derive(Clone, Debug)] -pub struct BernsteinYangInverter { +pub struct SafeGcdInverter { /// Modulus pub(super) modulus: UnsatInt, @@ -58,9 +59,7 @@ pub struct BernsteinYangInverter - BernsteinYangInverter -{ +impl SafeGcdInverter { /// Creates the inverter for specified modulus and adjusting parameter. /// /// Modulus must be odd. Returns `None` if it is not. @@ -135,7 +134,7 @@ impl } impl Inverter - for BernsteinYangInverter + for SafeGcdInverter { type Output = Uint; @@ -386,7 +385,7 @@ impl UnsatInt { /// The ordering of the chunks in these arrays is little-endian. #[allow(trivial_numeric_casts)] pub const fn from_uint(input: &Uint) -> Self { - if LIMBS != bernstein_yang_nlimbs!(SAT_LIMBS * Limb::BITS as usize) { + if LIMBS != safegcd_nlimbs!(SAT_LIMBS * Limb::BITS as usize) { panic!("incorrect number of limbs"); } @@ -410,7 +409,7 @@ impl UnsatInt { "can't convert negative number to Uint" ); - if LIMBS != bernstein_yang_nlimbs!(SAT_LIMBS * Limb::BITS as usize) { + if LIMBS != safegcd_nlimbs!(SAT_LIMBS * Limb::BITS as usize) { panic!("incorrect number of limbs"); } @@ -564,7 +563,7 @@ mod tests { type UnsatInt = super::UnsatInt<4>; - impl PartialEq for crate::modular::bernstein_yang::UnsatInt { + impl PartialEq for crate::modular::safegcd::UnsatInt { fn eq(&self, other: &Self) -> bool { self.eq(other).to_bool_vartime() } diff --git a/src/modular/bernstein_yang/boxed.rs b/src/modular/safegcd/boxed.rs similarity index 95% rename from src/modular/bernstein_yang/boxed.rs rename to src/modular/safegcd/boxed.rs index 140deb0de..1ab12f600 100644 --- a/src/modular/bernstein_yang/boxed.rs +++ b/src/modular/safegcd/boxed.rs @@ -1,5 +1,5 @@ -//! Implementation of Bernstein-Yang modular inversion and GCD algorithm as described in: -//! . +//! Implementation of Bernstein-Yang modular inversion and GCD algorithm (a.k.a. safegcd) +//! as described in: . //! //! See parent module for more information. @@ -14,9 +14,9 @@ use subtle::{Choice, ConditionallySelectable, ConstantTimeEq, ConstantTimeGreate /// Modular multiplicative inverter based on the Bernstein-Yang method. /// -/// See [`super::BernsteinYangInverter`] for more information. +/// See [`super::SafeGcdInverter`] for more information. #[derive(Clone, Debug)] -pub struct BoxedBernsteinYangInverter { +pub struct BoxedSafeGcdInverter { /// Modulus pub(crate) modulus: BoxedUnsatInt, @@ -27,7 +27,7 @@ pub struct BoxedBernsteinYangInverter { inverse: i64, } -impl BoxedBernsteinYangInverter { +impl BoxedSafeGcdInverter { /// Creates the inverter for specified modulus and adjusting parameter. /// /// Modulus must be odd. Returns `None` if it is not. @@ -50,7 +50,7 @@ impl BoxedBernsteinYangInverter { } } -impl Inverter for BoxedBernsteinYangInverter { +impl Inverter for BoxedSafeGcdInverter { type Output = BoxedUint; fn invert(&self, value: &BoxedUint) -> CtOption { @@ -78,7 +78,7 @@ fn unsat_nlimbs_for_sat_nlimbs(saturated_nlimbs: usize) -> usize { saturated_nlimbs }; - bernstein_yang_nlimbs!(saturated_nlimbs * Limb::BITS as usize) + safegcd_nlimbs!(saturated_nlimbs * Limb::BITS as usize) } /// Returns the greatest common divisor (GCD) of the two given numbers. @@ -300,10 +300,7 @@ impl BoxedUnsatInt { bits_precision = 64; } - debug_assert_eq!( - self.nlimbs(), - bernstein_yang_nlimbs!(bits_precision as usize) - ); + debug_assert_eq!(self.nlimbs(), safegcd_nlimbs!(bits_precision as usize)); assert!( !bool::from(self.is_negative()), "can't convert negative number to BoxedUint" @@ -522,7 +519,7 @@ mod tests { use subtle::ConstantTimeEq; #[cfg(not(miri))] - use crate::modular::bernstein_yang::UnsatInt; + use crate::modular::safegcd::UnsatInt; impl PartialEq for BoxedUnsatInt { fn eq(&self, other: &Self) -> bool { @@ -669,8 +666,8 @@ mod tests { #[test] #[cfg(not(miri))] fn boxed_unsatint_add(x in u256(), y in u256()) { - let x_ref = UnsatInt::<{ bernstein_yang_nlimbs!(256usize) }>::from_uint(&x); - let y_ref = UnsatInt::<{ bernstein_yang_nlimbs!(256usize) }>::from_uint(&y); + let x_ref = UnsatInt::<{ safegcd_nlimbs!(256usize) }>::from_uint(&x); + let y_ref = UnsatInt::<{ safegcd_nlimbs!(256usize) }>::from_uint(&y); let mut x_boxed = BoxedUnsatInt::from(&x.into()); let y_boxed = BoxedUnsatInt::from(&y.into()); @@ -682,7 +679,7 @@ mod tests { #[test] #[cfg(not(miri))] fn boxed_unsatint_mul(x in u256(), y in any::()) { - let x_ref = UnsatInt::<{ bernstein_yang_nlimbs!(256usize) }>::from_uint(&x); + let x_ref = UnsatInt::<{ safegcd_nlimbs!(256usize) }>::from_uint(&x); let x_boxed = BoxedUnsatInt::from(&x.into()); let expected = x_ref.mul(y); @@ -693,7 +690,7 @@ mod tests { #[test] #[cfg(not(miri))] fn boxed_unsatint_neg(x in u256()) { - let x_ref = UnsatInt::<{ bernstein_yang_nlimbs!(256usize) }>::from_uint(&x); + let x_ref = UnsatInt::<{ safegcd_nlimbs!(256usize) }>::from_uint(&x); let x_boxed = BoxedUnsatInt::from(&x.into()); let expected = x_ref.neg(); @@ -704,7 +701,7 @@ mod tests { #[test] #[cfg(not(miri))] fn boxed_unsatint_shr(x in u256()) { - let x_ref = UnsatInt::<{ bernstein_yang_nlimbs!(256usize) }>::from_uint(&x); + let x_ref = UnsatInt::<{ safegcd_nlimbs!(256usize) }>::from_uint(&x); let mut x_boxed = BoxedUnsatInt::from(&x.into()); x_boxed.shr_assign(); @@ -716,7 +713,7 @@ mod tests { #[cfg(not(miri))] fn boxed_unsatint_is_negative(x in u256()) { - let x_ref = UnsatInt::<{ bernstein_yang_nlimbs!(256usize) }>::from_uint(&x); + let x_ref = UnsatInt::<{ safegcd_nlimbs!(256usize) }>::from_uint(&x); let x_boxed = BoxedUnsatInt::from(&x.into()); assert_eq!(x_ref.is_negative().to_bool_vartime(), bool::from(x_boxed.is_negative())); } @@ -725,7 +722,7 @@ mod tests { #[cfg(not(miri))] fn boxed_unsatint_is_minus_one(x in u256()) { - let x_ref = UnsatInt::<{ bernstein_yang_nlimbs!(256usize) }>::from_uint(&x); + let x_ref = UnsatInt::<{ safegcd_nlimbs!(256usize) }>::from_uint(&x); let x_boxed = BoxedUnsatInt::from(&x.into()); assert!(bool::from(x_boxed.is_minus_one().ct_eq(&x_ref.eq(&UnsatInt::MINUS_ONE).into()))); } diff --git a/src/modular/bernstein_yang/macros.rs b/src/modular/safegcd/macros.rs similarity index 100% rename from src/modular/bernstein_yang/macros.rs rename to src/modular/safegcd/macros.rs diff --git a/src/uint.rs b/src/uint.rs index c6cbcbdf3..44a1853d5 100644 --- a/src/uint.rs +++ b/src/uint.rs @@ -40,7 +40,7 @@ pub(crate) mod boxed; mod rand; use crate::{ - modular::{BernsteinYangInverter, MontyForm}, + modular::{MontyForm, SafeGcdInverter}, Bounded, ConstCtOption, ConstZero, Constants, Encoding, FixedInteger, Integer, Limb, NonZero, Odd, PrecomputeInverter, PrecomputeInverterWithAdjuster, Word, }; diff --git a/src/uint/boxed/gcd.rs b/src/uint/boxed/gcd.rs index d66c175bf..2cd6860fe 100644 --- a/src/uint/boxed/gcd.rs +++ b/src/uint/boxed/gcd.rs @@ -1,7 +1,7 @@ //! Support for computing greatest common divisor of two `BoxedUint`s. use super::BoxedUint; -use crate::{modular::bernstein_yang, ConstantTimeSelect, Gcd, Integer, Odd}; +use crate::{modular::safegcd, ConstantTimeSelect, Gcd, Integer, Odd}; use subtle::{ConditionallySelectable, ConstantTimeLess}; impl Gcd for BoxedUint { @@ -21,7 +21,7 @@ impl Gcd for BoxedUint { let f = Self::ct_select(&s1, &s2, !s2.is_odd()); let g = Self::ct_select(&s1, &s2, s2.is_odd()); - bernstein_yang::boxed::gcd(&f, &g).overflowing_shl(k).0 + safegcd::boxed::gcd(&f, &g).overflowing_shl(k).0 } fn gcd_vartime(&self, rhs: &Self) -> Self::Output { @@ -36,11 +36,11 @@ impl Gcd for Odd { type Output = BoxedUint; fn gcd(&self, rhs: &BoxedUint) -> BoxedUint { - bernstein_yang::boxed::gcd(self, rhs) + safegcd::boxed::gcd(self, rhs) } fn gcd_vartime(&self, rhs: &BoxedUint) -> Self::Output { - bernstein_yang::boxed::gcd_vartime(self, rhs) + safegcd::boxed::gcd_vartime(self, rhs) } } diff --git a/src/uint/boxed/inv_mod.rs b/src/uint/boxed/inv_mod.rs index 1dee99f67..670978f55 100644 --- a/src/uint/boxed/inv_mod.rs +++ b/src/uint/boxed/inv_mod.rs @@ -1,8 +1,8 @@ //! [`BoxedUint`] modular inverse (i.e. reciprocal) operations. use crate::{ - modular::BoxedBernsteinYangInverter, BoxedUint, ConstantTimeSelect, Integer, InvMod, Inverter, - Odd, PrecomputeInverter, PrecomputeInverterWithAdjuster, + modular::BoxedSafeGcdInverter, BoxedUint, ConstantTimeSelect, Integer, InvMod, Inverter, Odd, + PrecomputeInverter, PrecomputeInverterWithAdjuster, }; use subtle::{Choice, ConstantTimeEq, ConstantTimeLess, CtOption}; @@ -87,21 +87,18 @@ impl InvMod for BoxedUint { /// Precompute a Bernstein-Yang inverter using `self` as the modulus. impl PrecomputeInverter for Odd { - type Inverter = BoxedBernsteinYangInverter; + type Inverter = BoxedSafeGcdInverter; type Output = BoxedUint; - fn precompute_inverter(&self) -> BoxedBernsteinYangInverter { + fn precompute_inverter(&self) -> BoxedSafeGcdInverter { Self::precompute_inverter_with_adjuster(self, &BoxedUint::one()) } } /// Precompute a Bernstein-Yang inverter using `self` as the modulus. impl PrecomputeInverterWithAdjuster for Odd { - fn precompute_inverter_with_adjuster( - &self, - adjuster: &BoxedUint, - ) -> BoxedBernsteinYangInverter { - BoxedBernsteinYangInverter::new(self, adjuster) + fn precompute_inverter_with_adjuster(&self, adjuster: &BoxedUint) -> BoxedSafeGcdInverter { + BoxedSafeGcdInverter::new(self, adjuster) } } diff --git a/src/uint/gcd.rs b/src/uint/gcd.rs index d441176bc..6a6e5f812 100644 --- a/src/uint/gcd.rs +++ b/src/uint/gcd.rs @@ -1,10 +1,10 @@ //! Support for computing the greatest common divisor of two `Uint`s. -use crate::{modular::BernsteinYangInverter, ConstChoice, Gcd, Odd, PrecomputeInverter, Uint}; +use crate::{modular::SafeGcdInverter, ConstChoice, Gcd, Odd, PrecomputeInverter, Uint}; impl Uint where - Odd: PrecomputeInverter>, + Odd: PrecomputeInverter>, { /// Compute the greatest common divisor (GCD) of this number and another. /// @@ -32,7 +32,7 @@ where impl Odd> where - Self: PrecomputeInverter>, + Self: PrecomputeInverter>, { /// Compute the greatest common divisor (GCD) of this number and another. /// @@ -44,7 +44,7 @@ where impl Gcd for Uint where - Odd: PrecomputeInverter>, + Odd: PrecomputeInverter>, { type Output = Uint; @@ -62,7 +62,7 @@ where impl Gcd> for Odd> where - Odd: PrecomputeInverter>, + Odd: PrecomputeInverter>, { type Output = Uint; diff --git a/src/uint/inv_mod.rs b/src/uint/inv_mod.rs index 38a54cf2c..02485829c 100644 --- a/src/uint/inv_mod.rs +++ b/src/uint/inv_mod.rs @@ -1,6 +1,6 @@ use super::Uint; use crate::{ - modular::BernsteinYangInverter, ConstChoice, ConstCtOption, InvMod, Odd, PrecomputeInverter, + modular::SafeGcdInverter, ConstChoice, ConstCtOption, InvMod, Odd, PrecomputeInverter, }; use subtle::CtOption; @@ -85,11 +85,11 @@ impl Uint { impl Uint where - Odd: PrecomputeInverter>, + Odd: PrecomputeInverter>, { /// Computes the multiplicative inverse of `self` mod `modulus`, where `modulus` is odd. pub const fn inv_odd_mod(&self, modulus: &Odd) -> ConstCtOption { - BernsteinYangInverter::::new(modulus, &Uint::ONE).inv(self) + SafeGcdInverter::::new(modulus, &Uint::ONE).inv(self) } /// Computes the multiplicative inverse of `self` mod `modulus`. @@ -135,7 +135,7 @@ where impl InvMod for Uint where - Odd: PrecomputeInverter>, + Odd: PrecomputeInverter>, { fn inv_mod(&self, modulus: &Self) -> CtOption { self.inv_mod(modulus).into() diff --git a/src/uint/macros.rs b/src/uint/macros.rs index b52a89ce4..0089314cf 100644 --- a/src/uint/macros.rs +++ b/src/uint/macros.rs @@ -6,10 +6,8 @@ macro_rules! impl_precompute_inverter_trait { /// Precompute a Bernstein-Yang inverter using `self` as the modulus. impl PrecomputeInverter for Odd<$name> { #[allow(trivial_numeric_casts)] - type Inverter = BernsteinYangInverter< - { nlimbs!($bits) }, - { bernstein_yang_nlimbs!($bits as usize) }, - >; + type Inverter = + SafeGcdInverter<{ nlimbs!($bits) }, { safegcd_nlimbs!($bits as usize) }>; type Output = $name; @@ -29,7 +27,7 @@ macro_rules! impl_precompute_inverter_trait { /// value represented by a saturated `$bits`-sized integer. #[cfg(debug_assertions)] #[allow(trivial_numeric_casts)] - const _: () = assert!((bernstein_yang_nlimbs!($bits as usize) * 62) - 64 >= $bits); + const _: () = assert!((safegcd_nlimbs!($bits as usize) * 62) - 64 >= $bits); }; } diff --git a/tests/bernstein_yang.proptest-regressions b/tests/safegcd.proptest-regressions similarity index 100% rename from tests/bernstein_yang.proptest-regressions rename to tests/safegcd.proptest-regressions diff --git a/tests/bernstein_yang.rs b/tests/safegcd.rs similarity index 100% rename from tests/bernstein_yang.rs rename to tests/safegcd.rs