diff --git a/Cargo.toml b/Cargo.toml index fb10f6a..e2cee35 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,7 +20,7 @@ rand = "0.8" rlp = "0.5" zeroize = "1.1.0" sha3 = "0.10" -k256 = { version = "0.11", features = ["ecdsa"], optional = true } +k256 = { version = "0.13", features = ["ecdsa"], optional = true } serde = { version = "1.0.110", optional = true } ed25519-dalek = { version = "1.0.0-pre.4", optional = true } secp256k1 = { version = "0.26", optional = true, default-features = false, features = [ diff --git a/src/keys/combined.rs b/src/keys/combined.rs index 2103451..3d8d6e1 100644 --- a/src/keys/combined.rs +++ b/src/keys/combined.rs @@ -78,7 +78,7 @@ impl CombinedKey { /// Generates a new secp256k1 key. #[must_use] pub fn generate_secp256k1() -> Self { - let key = k256::ecdsa::SigningKey::random(rand::thread_rng()); + let key = k256::ecdsa::SigningKey::random(&mut rand::thread_rng()); Self::Secp256k1(key) } @@ -97,7 +97,7 @@ impl CombinedKey { /// Imports a secp256k1 from raw bytes in any format. pub fn secp256k1_from_bytes(bytes: &mut [u8]) -> Result { - let key = k256::ecdsa::SigningKey::from_bytes(bytes) + let key = k256::ecdsa::SigningKey::from_slice(bytes) .map_err(|_| DecoderError::Custom("Invalid secp256k1 secret key")) .map(Self::from)?; bytes.zeroize(); diff --git a/src/keys/k256_key.rs b/src/keys/k256_key.rs index 53b38da..dbfa3e4 100644 --- a/src/keys/k256_key.rs +++ b/src/keys/k256_key.rs @@ -5,13 +5,13 @@ use crate::Key; use bytes::Bytes; use k256::{ ecdsa::{ - signature::{DigestVerifier, RandomizedDigestSigner, Signature as _}, + signature::{DigestVerifier, RandomizedDigestSigner}, Signature, SigningKey, VerifyingKey, }, elliptic_curve::{ + point::DecompressPoint, sec1::{Coordinates, ToEncodedPoint}, subtle::Choice, - DecompressPoint, }, AffinePoint, CompressedPoint, EncodedPoint, }; @@ -33,11 +33,11 @@ impl EnrKey for SigningKey { .try_sign_digest_with_rng(&mut OsRng, digest) .map_err(|_| SigningError::new("failed to sign"))?; - Ok(signature.as_bytes().to_vec()) + Ok(signature.to_vec()) } fn public(&self) -> Self::PublicKey { - self.verifying_key() + *self.verifying_key() } fn enr_to_public(content: &BTreeMap) -> Result { @@ -75,7 +75,7 @@ impl EnrPublicKey for VerifyingKey { fn encode(&self) -> Self::Raw { // serialize in compressed form: 33 bytes - self.to_bytes() + self.into() } fn encode_uncompressed(&self) -> Self::RawUncompressed {