diff --git a/Cargo.lock b/Cargo.lock index e6dec566..28ea364b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -90,7 +90,7 @@ dependencies = [ [[package]] name = "elliptic-curve" version = "0.5.0" -source = "git+https://github.com/RustCrypto/traits#a866a23ab066bc89d000f0931dec9f915d6a8986" +source = "git+https://github.com/RustCrypto/traits#24ce4e1bda977a7f41af203eb3cbd3fa0e906b93" dependencies = [ "bitvec", "digest", diff --git a/ecdsa/src/dev/curve.rs b/ecdsa/src/dev/curve.rs index e8fc0406..7d35f62b 100644 --- a/ecdsa/src/dev/curve.rs +++ b/ecdsa/src/dev/curve.rs @@ -39,7 +39,7 @@ impl elliptic_curve::Arithmetic for ExampleCurve { } /// Field element bytes. -pub type ElementBytes = elliptic_curve::ElementBytes; +pub type FieldBytes = elliptic_curve::FieldBytes; /// Non-zero scalar value. pub type NonZeroScalar = elliptic_curve::scalar::NonZeroScalar; @@ -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 { + fn from_repr(_repr: FieldBytes) -> Option { unimplemented!(); } - fn to_repr(&self) -> ElementBytes { + fn to_repr(&self) -> FieldBytes { unimplemented!(); } @@ -256,7 +256,7 @@ impl From for Scalar { impl FromBytes for Scalar { type Size = U32; - fn from_bytes(bytes: &ElementBytes) -> CtOption { + fn from_bytes(bytes: &FieldBytes) -> CtOption { let mut w = [0u64; LIMBS]; // Interpret the bytes as a big-endian integer w. @@ -277,15 +277,15 @@ impl FromBytes for Scalar { } } -impl From for ElementBytes { +impl From 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()); diff --git a/ecdsa/src/lib.rs b/ecdsa/src/lib.rs index dd9b6b20..361c1119 100644 --- a/ecdsa/src/lib.rs +++ b/ecdsa/src/lib.rs @@ -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")] @@ -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>, - s: impl Into>, + r: impl Into>, + s: impl Into>, ) -> Result { Self::try_from(r.into().concat(s.into()).as_slice()) } @@ -150,13 +150,13 @@ where { /// Get the `r` component of this signature pub fn r(&self) -> NonZeroScalar { - let r_bytes = ElementBytes::::from_slice(&self.bytes[..C::FieldSize::to_usize()]); + let r_bytes = FieldBytes::::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 { - let s_bytes = ElementBytes::::from_slice(&self.bytes[C::FieldSize::to_usize()..]); + let s_bytes = FieldBytes::::from_slice(&self.bytes[C::FieldSize::to_usize()..]); NonZeroScalar::from_bytes(&s_bytes).unwrap() } diff --git a/ecdsa/src/rfc6979.rs b/ecdsa/src/rfc6979.rs index e39ad1a2..819cd3ed 100644 --- a/ecdsa/src/rfc6979.rs +++ b/ecdsa/src/rfc6979.rs @@ -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}; @@ -25,7 +25,7 @@ where D: FixedOutput + BlockInput + Clone + Default + Reset + Update, { let mut x = secret_scalar.to_bytes(); - let h1: ElementBytes = C::Scalar::from_digest(msg_digest).into(); + let h1: FieldBytes = C::Scalar::from_digest(msg_digest).into(); let mut hmac_drbg = HmacDrbg::::new(&x, &h1, additional_data); x.zeroize(); diff --git a/ecdsa/src/sign.rs b/ecdsa/src/sign.rs index f05e745a..9296c681 100644 --- a/ecdsa/src/sign.rs +++ b/ecdsa/src/sign.rs @@ -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}, @@ -73,7 +73,7 @@ where } /// Serialize this [`SigningKey`] as bytes - pub fn to_bytes(&self) -> ElementBytes { + pub fn to_bytes(&self) -> FieldBytes { self.secret_scalar.to_bytes() } } @@ -124,7 +124,7 @@ where mut rng: impl CryptoRng + RngCore, digest: D, ) -> Result, Error> { - let mut added_entropy = ElementBytes::::default(); + let mut added_entropy = FieldBytes::::default(); rng.fill_bytes(&mut added_entropy); let ephemeral_scalar =