diff --git a/Cargo.lock b/Cargo.lock index 362701079..aee48a0e5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -417,7 +417,7 @@ checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719" [[package]] name = "elliptic-curve" version = "0.14.0-rc.10" -source = "git+https://github.com/RustCrypto/traits.git#a10ef181945a480bba5d2fb36ad6f3f78a3474db" +source = "git+https://github.com/RustCrypto/traits.git#d5355ef8a85577d9842505cf3241f6e1d011d0da" dependencies = [ "base16ct", "base64ct", diff --git a/p521/src/arithmetic/scalar.rs b/p521/src/arithmetic/scalar.rs index 7f99e9112..4fe040e01 100644 --- a/p521/src/arithmetic/scalar.rs +++ b/p521/src/arithmetic/scalar.rs @@ -18,7 +18,7 @@ use self::scalar_impl::*; use crate::{FieldBytes, NistP521, U576}; use core::{ iter::{Product, Sum}, - ops::{Add, AddAssign, Mul, MulAssign, Neg, Shr, ShrAssign, SubAssign}, + ops::{Add, AddAssign, Mul, MulAssign, Neg, SubAssign}, }; use elliptic_curve::{ Curve as _, Error, FieldBytesEncoding, Result, @@ -305,32 +305,6 @@ impl Scalar { res } - /// Right shifts the scalar. - /// - /// Note: not constant-time with respect to the `shift` parameter. - #[cfg(target_pointer_width = "32")] - pub const fn shr_vartime(&self, shift: u32) -> Scalar { - Self(fiat_p521_scalar_montgomery_domain_field_element( - u32x18_to_u64x9( - &U576::from_words(u64x9_to_u32x18(self.as_limbs())) - .wrapping_shr_vartime(shift) - .to_words(), - ), - )) - } - - /// Right shifts the scalar. - /// - /// Note: not constant-time with respect to the `shift` parameter. - #[cfg(target_pointer_width = "64")] - pub const fn shr_vartime(&self, shift: u32) -> Scalar { - Self(fiat_p521_scalar_montgomery_domain_field_element( - U576::from_words(self.into_limbs()) - .wrapping_shr_vartime(shift) - .to_words(), - )) - } - /// Borrow the inner limbs of this scalar. pub(crate) const fn as_limbs(&self) -> &[u64; 9] { &self.0.0 @@ -551,28 +525,6 @@ impl IsHigh for Scalar { } } -impl Shr for Scalar { - type Output = Self; - - fn shr(self, rhs: usize) -> Self::Output { - self.shr_vartime(rhs as u32) - } -} - -impl Shr for &Scalar { - type Output = Scalar; - - fn shr(self, rhs: usize) -> Self::Output { - self.shr_vartime(rhs as u32) - } -} - -impl ShrAssign for Scalar { - fn shr_assign(&mut self, rhs: usize) { - *self = *self >> rhs; - } -} - impl PrimeField for Scalar { type Repr = FieldBytes; diff --git a/primefield/src/lib.rs b/primefield/src/lib.rs index 6f8dac77d..6d7e54fd5 100644 --- a/primefield/src/lib.rs +++ b/primefield/src/lib.rs @@ -197,22 +197,6 @@ macro_rules! field_element_type { res } - - /// Right shifts the [` - #[doc = stringify!($fe)] - /// `]. - pub const fn shr(&self, shift: u32) -> Self { - Self(self.0.wrapping_shr(shift)) - } - - /// Right shifts the [` - #[doc = stringify!($fe)] - /// `]. - /// - /// Note: not constant-time with respect to the `shift` parameter. - pub const fn shr_vartime(&self, shift: u32) -> Self { - Self(self.0.wrapping_shr_vartime(shift)) - } } impl $crate::ff::Field for $fe { @@ -323,56 +307,6 @@ macro_rules! field_element_type { } } - impl ::core::ops::Shr for $fe { - type Output = Self; - - #[inline] - fn shr(self, rhs: u32) -> Self { - Self::shr(&self, rhs) - } - } - - impl ::core::ops::Shr for &$fe { - type Output = Self; - - #[inline] - fn shr(self, rhs: u32) -> Self { - Self::shr(self, rhs) - } - } - - impl ::core::ops::ShrAssign for $fe { - #[inline] - fn shr_assign(&mut self, rhs: u32) { - *self = Self::shr(self, rhs) - } - } - - impl ::core::ops::Shr for $fe { - type Output = Self; - - #[inline] - fn shr(self, rhs: usize) -> Self { - Self::shr(&self, rhs as u32) - } - } - - impl ::core::ops::Shr for &$fe { - type Output = Self; - - #[inline] - fn shr(self, rhs: usize) -> Self { - Self::shr(self, rhs as u32) - } - } - - impl ::core::ops::ShrAssign for $fe { - #[inline] - fn shr_assign(&mut self, rhs: usize) { - *self = Self::shr(self, rhs as u32) - } - } - impl ::core::fmt::Debug for $fe { fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { write!(f, "{}(0x{:X})", stringify!($fe), &self.0)