Skip to content

Commit

Permalink
Merge branch 'RustCrypto:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
makavity authored May 30, 2024
2 parents f50ac39 + 4a225a6 commit 1d0bc55
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 15 deletions.
2 changes: 1 addition & 1 deletion bp256/src/arithmetic/field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ impl FieldElement {

/// Returns the big-endian encoding of this [`FieldElement`].
pub fn to_bytes(self) -> FieldBytes {
self.0.to_be_byte_array()
self.to_canonical().to_be_byte_array()
}

/// Translate [`FieldElement`] out of the Montgomery domain, returning a
Expand Down
4 changes: 2 additions & 2 deletions k256/src/arithmetic/field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ impl Neg for &FieldElement {

impl Sum for FieldElement {
fn sum<I: Iterator<Item = Self>>(iter: I) -> Self {
iter.reduce(core::ops::Add::add).unwrap_or(Self::ZERO)
iter.reduce(Add::add).unwrap_or(Self::ZERO)
}
}

Expand All @@ -498,7 +498,7 @@ impl<'a> Sum<&'a FieldElement> for FieldElement {

impl Product for FieldElement {
fn product<I: Iterator<Item = Self>>(iter: I) -> Self {
iter.reduce(core::ops::Mul::mul).unwrap_or(Self::ONE)
iter.reduce(Mul::mul).unwrap_or(Self::ONE)
}
}

Expand Down
4 changes: 2 additions & 2 deletions k256/src/arithmetic/scalar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -713,7 +713,7 @@ impl ReduceNonZero<U512> for Scalar {

impl Sum for Scalar {
fn sum<I: Iterator<Item = Self>>(iter: I) -> Self {
iter.reduce(core::ops::Add::add).unwrap_or(Self::ZERO)
iter.reduce(Add::add).unwrap_or(Self::ZERO)
}
}

Expand All @@ -725,7 +725,7 @@ impl<'a> Sum<&'a Scalar> for Scalar {

impl Product for Scalar {
fn product<I: Iterator<Item = Self>>(iter: I) -> Self {
iter.reduce(core::ops::Mul::mul).unwrap_or(Self::ONE)
iter.reduce(Mul::mul).unwrap_or(Self::ONE)
}
}

Expand Down
4 changes: 2 additions & 2 deletions p256/src/arithmetic/field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ impl Neg for &FieldElement {

impl Sum for FieldElement {
fn sum<I: Iterator<Item = Self>>(iter: I) -> Self {
iter.reduce(core::ops::Add::add).unwrap_or(Self::ZERO)
iter.reduce(Add::add).unwrap_or(Self::ZERO)
}
}

Expand All @@ -490,7 +490,7 @@ impl<'a> Sum<&'a FieldElement> for FieldElement {

impl Product for FieldElement {
fn product<I: Iterator<Item = Self>>(iter: I) -> Self {
iter.reduce(core::ops::Mul::mul).unwrap_or(Self::ONE)
iter.reduce(Mul::mul).unwrap_or(Self::ONE)
}
}

Expand Down
4 changes: 2 additions & 2 deletions p256/src/arithmetic/scalar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -676,7 +676,7 @@ impl ReduceNonZero<U256> for Scalar {

impl Sum for Scalar {
fn sum<I: Iterator<Item = Self>>(iter: I) -> Self {
iter.reduce(core::ops::Add::add).unwrap_or(Self::ZERO)
iter.reduce(Add::add).unwrap_or(Self::ZERO)
}
}

Expand All @@ -688,7 +688,7 @@ impl<'a> Sum<&'a Scalar> for Scalar {

impl Product for Scalar {
fn product<I: Iterator<Item = Self>>(iter: I) -> Self {
iter.reduce(core::ops::Mul::mul).unwrap_or(Self::ONE)
iter.reduce(Mul::mul).unwrap_or(Self::ONE)
}
}

Expand Down
4 changes: 2 additions & 2 deletions p521/src/arithmetic/field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,7 @@ impl Neg for FieldElement {

impl Sum for FieldElement {
fn sum<I: Iterator<Item = Self>>(iter: I) -> Self {
iter.reduce(core::ops::Add::add).unwrap_or(Self::ZERO)
iter.reduce(Add::add).unwrap_or(Self::ZERO)
}
}

Expand All @@ -626,7 +626,7 @@ impl<'a> Sum<&'a FieldElement> for FieldElement {

impl Product for FieldElement {
fn product<I: Iterator<Item = Self>>(iter: I) -> Self {
iter.reduce(core::ops::Mul::mul).unwrap_or(Self::ONE)
iter.reduce(Mul::mul).unwrap_or(Self::ONE)
}
}

Expand Down
8 changes: 4 additions & 4 deletions p521/src/arithmetic/scalar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use self::scalar_impl::*;
use crate::{FieldBytes, NistP521, SecretKey, U576};
use core::{
iter::{Product, Sum},
ops::{AddAssign, MulAssign, Neg, Shr, ShrAssign, SubAssign},
ops::{Add, AddAssign, Mul, MulAssign, Neg, Shr, ShrAssign, SubAssign},
};
use elliptic_curve::{
array::Array,
Expand All @@ -43,7 +43,7 @@ use {crate::ScalarBits, elliptic_curve::group::ff::PrimeFieldBits};
use serdect::serde::{de, ser, Deserialize, Serialize};

#[cfg(doc)]
use core::ops::{Add, Mul, Sub};
use core::ops::Sub;

#[cfg(target_pointer_width = "32")]
use super::util::{u32x18_to_u64x9, u64x9_to_u32x18};
Expand Down Expand Up @@ -474,7 +474,7 @@ impl Neg for Scalar {

impl Sum for Scalar {
fn sum<I: Iterator<Item = Self>>(iter: I) -> Self {
iter.reduce(core::ops::Add::add).unwrap_or(Self::ZERO)
iter.reduce(Add::add).unwrap_or(Self::ZERO)
}
}

Expand All @@ -486,7 +486,7 @@ impl<'a> Sum<&'a Scalar> for Scalar {

impl Product for Scalar {
fn product<I: Iterator<Item = Self>>(iter: I) -> Self {
iter.reduce(core::ops::Mul::mul).unwrap_or(Self::ONE)
iter.reduce(Mul::mul).unwrap_or(Self::ONE)
}
}

Expand Down
2 changes: 2 additions & 0 deletions primefield/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,7 @@ macro_rules! impl_mont_field_element_arithmetic {
}

impl Sum for $fe {
#[allow(unused_qualifications)]
fn sum<I: Iterator<Item = Self>>(iter: I) -> Self {
iter.reduce(core::ops::Add::add).unwrap_or(Self::ZERO)
}
Expand All @@ -464,6 +465,7 @@ macro_rules! impl_mont_field_element_arithmetic {
}

impl Product for $fe {
#[allow(unused_qualifications)]
fn product<I: Iterator<Item = Self>>(iter: I) -> Self {
iter.reduce(core::ops::Mul::mul).unwrap_or(Self::ONE)
}
Expand Down
2 changes: 2 additions & 0 deletions primeorder/src/field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,7 @@ macro_rules! impl_mont_field_element_arithmetic {
}

impl Sum for $fe {
#[allow(unused_qualifications)]
fn sum<I: Iterator<Item = Self>>(iter: I) -> Self {
iter.reduce(core::ops::Add::add).unwrap_or(Self::ZERO)
}
Expand All @@ -454,6 +455,7 @@ macro_rules! impl_mont_field_element_arithmetic {
}

impl Product for $fe {
#[allow(unused_qualifications)]
fn product<I: Iterator<Item = Self>>(iter: I) -> Self {
iter.reduce(core::ops::Mul::mul).unwrap_or(Self::ONE)
}
Expand Down

0 comments on commit 1d0bc55

Please sign in to comment.