Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 8 additions & 8 deletions ecdsa/src/dev/curve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ impl elliptic_curve::Arithmetic for ExampleCurve {
}

/// Field element bytes.
pub type ElementBytes = elliptic_curve::ElementBytes<ExampleCurve>;
pub type FieldBytes = elliptic_curve::FieldBytes<ExampleCurve>;

/// Non-zero scalar value.
pub type NonZeroScalar = elliptic_curve::scalar::NonZeroScalar<ExampleCurve>;
Expand Down Expand Up @@ -99,18 +99,18 @@ impl Field for Scalar {
}

impl PrimeField for Scalar {
type Repr = ElementBytes;
type Repr = FieldBytes;
type ReprBits = [u64; 4];

const NUM_BITS: u32 = 256;
const CAPACITY: u32 = 255;
const S: u32 = 4;

fn from_repr(_repr: ElementBytes) -> Option<Self> {
fn from_repr(_repr: FieldBytes) -> Option<Self> {
unimplemented!();
}

fn to_repr(&self) -> ElementBytes {
fn to_repr(&self) -> FieldBytes {
unimplemented!();
}

Expand Down Expand Up @@ -256,7 +256,7 @@ impl From<u64> for Scalar {
impl FromBytes for Scalar {
type Size = U32;

fn from_bytes(bytes: &ElementBytes) -> CtOption<Self> {
fn from_bytes(bytes: &FieldBytes) -> CtOption<Self> {
let mut w = [0u64; LIMBS];

// Interpret the bytes as a big-endian integer w.
Expand All @@ -277,15 +277,15 @@ impl FromBytes for Scalar {
}
}

impl From<Scalar> for ElementBytes {
impl From<Scalar> for FieldBytes {
fn from(scalar: Scalar) -> Self {
Self::from(&scalar)
}
}

impl From<&Scalar> for ElementBytes {
impl From<&Scalar> for FieldBytes {
fn from(scalar: &Scalar) -> Self {
let mut ret = ElementBytes::default();
let mut ret = FieldBytes::default();
ret[0..8].copy_from_slice(&scalar.0[3].to_be_bytes());
ret[8..16].copy_from_slice(&scalar.0[2].to_be_bytes());
ret[16..24].copy_from_slice(&scalar.0[1].to_be_bytes());
Expand Down
10 changes: 5 additions & 5 deletions ecdsa/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ use core::{
fmt::{self, Debug},
ops::Add,
};
use elliptic_curve::ElementBytes;
use elliptic_curve::FieldBytes;
use generic_array::{sequence::Concat, typenum::Unsigned, ArrayLength, GenericArray};

#[cfg(feature = "arithmetic")]
Expand Down Expand Up @@ -113,8 +113,8 @@ where
/// Create a [`Signature`] from the serialized `r` and `s` scalar values
/// which comprise the signature.
pub fn from_scalars(
r: impl Into<ElementBytes<C>>,
s: impl Into<ElementBytes<C>>,
r: impl Into<FieldBytes<C>>,
s: impl Into<FieldBytes<C>>,
) -> Result<Self, Error> {
Self::try_from(r.into().concat(s.into()).as_slice())
}
Expand Down Expand Up @@ -150,13 +150,13 @@ where
{
/// Get the `r` component of this signature
pub fn r(&self) -> NonZeroScalar<C> {
let r_bytes = ElementBytes::<C>::from_slice(&self.bytes[..C::FieldSize::to_usize()]);
let r_bytes = FieldBytes::<C>::from_slice(&self.bytes[..C::FieldSize::to_usize()]);
NonZeroScalar::from_bytes(&r_bytes).unwrap()
}

/// Get the `s` component of this signature
pub fn s(&self) -> NonZeroScalar<C> {
let s_bytes = ElementBytes::<C>::from_slice(&self.bytes[C::FieldSize::to_usize()..]);
let s_bytes = FieldBytes::<C>::from_slice(&self.bytes[C::FieldSize::to_usize()..]);
NonZeroScalar::from_bytes(&s_bytes).unwrap()
}

Expand Down
4 changes: 2 additions & 2 deletions ecdsa/src/rfc6979.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use elliptic_curve::{
ops::Invert,
scalar::NonZeroScalar,
zeroize::{Zeroize, Zeroizing},
Arithmetic, ElementBytes, FromBytes, FromDigest,
Arithmetic, FieldBytes, FromBytes, FromDigest,
};
use hmac::{Hmac, Mac, NewMac};

Expand All @@ -25,7 +25,7 @@ where
D: FixedOutput<OutputSize = C::FieldSize> + BlockInput + Clone + Default + Reset + Update,
{
let mut x = secret_scalar.to_bytes();
let h1: ElementBytes<C> = C::Scalar::from_digest(msg_digest).into();
let h1: FieldBytes<C> = C::Scalar::from_digest(msg_digest).into();
let mut hmac_drbg = HmacDrbg::<D>::new(&x, &h1, additional_data);
x.zeroize();

Expand Down
6 changes: 3 additions & 3 deletions ecdsa/src/sign.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use crate::{
use core::convert::TryInto;
use elliptic_curve::{
generic_array::ArrayLength, ops::Invert, scalar::NonZeroScalar, weierstrass::Curve,
zeroize::Zeroize, Arithmetic, ElementBytes, FromBytes, FromDigest, SecretKey,
zeroize::Zeroize, Arithmetic, FieldBytes, FromBytes, FromDigest, SecretKey,
};
use signature::{
digest::{BlockInput, Digest, FixedOutput, Reset, Update},
Expand Down Expand Up @@ -73,7 +73,7 @@ where
}

/// Serialize this [`SigningKey`] as bytes
pub fn to_bytes(&self) -> ElementBytes<C> {
pub fn to_bytes(&self) -> FieldBytes<C> {
self.secret_scalar.to_bytes()
}
}
Expand Down Expand Up @@ -124,7 +124,7 @@ where
mut rng: impl CryptoRng + RngCore,
digest: D,
) -> Result<Signature<C>, Error> {
let mut added_entropy = ElementBytes::<C>::default();
let mut added_entropy = FieldBytes::<C>::default();
rng.fill_bytes(&mut added_entropy);

let ephemeral_scalar =
Expand Down