Skip to content

Commit

Permalink
elliptic-curve: non_zero => nonzero (#828)
Browse files Browse the repository at this point in the history
In #827, a `ReduceNonZero` trait was added whose method name uses an
underscored `*_non_zero`.

However, there's already one bit of precedent in the public API:

- `SecretKey::to_nonzero_scalar`

Since this is already a stable API and providing precedent, for
consistency this commit changes all of the unstable/unreleased APIs and
internal module naming to use `nonzero` instead of `non_zero`, as this
is a non-breaking change.
  • Loading branch information
tarcieri committed Dec 3, 2021
1 parent f6ac4b0 commit a01885d
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion elliptic-curve/src/lib.rs
Expand Up @@ -98,7 +98,7 @@ pub use {
AffineArithmetic, PrimeCurveArithmetic, ProjectiveArithmetic, ScalarArithmetic,
},
public_key::PublicKey,
scalar::{non_zero::NonZeroScalar, Scalar},
scalar::{nonzero::NonZeroScalar, Scalar},
},
ff::{self, Field, PrimeField},
group::{self, Group},
Expand Down
2 changes: 1 addition & 1 deletion elliptic-curve/src/ops.rs
Expand Up @@ -48,5 +48,5 @@ pub trait Reduce<UInt: Integer + ArrayEncoding>: Sized {
/// End users can use the `Reduce` impl on `NonZeroScalar` instead.
pub trait ReduceNonZero<UInt: Integer + ArrayEncoding>: Sized {
/// Perform a modular reduction, returning a field element.
fn from_uint_reduced_non_zero(n: UInt) -> Self;
fn from_uint_reduced_nonzero(n: UInt) -> Self;
}
2 changes: 1 addition & 1 deletion elliptic-curve/src/scalar.rs
Expand Up @@ -5,7 +5,7 @@ use subtle::Choice;
pub(crate) mod core;

#[cfg(feature = "arithmetic")]
pub(crate) mod non_zero;
pub(crate) mod nonzero;

#[cfg(feature = "arithmetic")]
use crate::ScalarArithmetic;
Expand Down
Expand Up @@ -207,7 +207,7 @@ where
Scalar<C>: ReduceNonZero<I>,
{
fn from_uint_reduced(n: I) -> Self {
Self::from_uint_reduced_non_zero(n)
Self::from_uint_reduced_nonzero(n)
}
}

Expand All @@ -217,8 +217,8 @@ where
I: Integer + ArrayEncoding,
Scalar<C>: ReduceNonZero<I>,
{
fn from_uint_reduced_non_zero(n: I) -> Self {
let scalar = Scalar::<C>::from_uint_reduced_non_zero(n);
fn from_uint_reduced_nonzero(n: I) -> Self {
let scalar = Scalar::<C>::from_uint_reduced_nonzero(n);
debug_assert!(!bool::from(scalar.is_zero()));
Self::new(scalar).unwrap()
}
Expand Down

0 comments on commit a01885d

Please sign in to comment.