diff --git a/Cargo.toml b/Cargo.toml index 8dbe6f1..0ccf0aa 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,7 @@ rlp = "0.4.5" zeroize = "1.1.0" libsecp256k1 = { version = "0.3.5", optional = true } sha3 = "0.9" -k256 = { version = "0.5", features = ["ecdsa", "zeroize"], optional = true } +k256 = { version = "0.7", features = ["ecdsa", "zeroize"], optional = true } serde = { version = "1.0.110", optional = true } ed25519-dalek = { version = "1.0.0-pre.4", optional = true } c-secp256k1 = { package = "secp256k1", version = "0.19", optional = true, features = ["global-context"] } diff --git a/src/keys/combined.rs b/src/keys/combined.rs index 2f1b376..3a70f70 100644 --- a/src/keys/combined.rs +++ b/src/keys/combined.rs @@ -96,7 +96,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::new(bytes) + let key = k256::ecdsa::SigningKey::from_bytes(bytes) .map_err(|_| DecoderError::Custom("Invalid secp256k1 secret key")) .map(Self::from)?; bytes.zeroize(); @@ -127,13 +127,13 @@ impl CombinedKey { #[derive(Clone, Debug, PartialEq)] pub enum CombinedPublicKey { /// An `Secp256k1` public key. - Secp256k1(k256::ecdsa::VerifyKey), + Secp256k1(k256::ecdsa::VerifyingKey), /// An `Ed25519` public key. Ed25519(ed25519::PublicKey), } -impl From for CombinedPublicKey { - fn from(public_key: k256::ecdsa::VerifyKey) -> Self { +impl From for CombinedPublicKey { + fn from(public_key: k256::ecdsa::VerifyingKey) -> Self { Self::Secp256k1(public_key) } } diff --git a/src/keys/k256_key.rs b/src/keys/k256_key.rs index a4a9eb5..f1f6800 100644 --- a/src/keys/k256_key.rs +++ b/src/keys/k256_key.rs @@ -5,7 +5,7 @@ use crate::Key; use k256::{ ecdsa::{ signature::{DigestVerifier, RandomizedDigestSigner, Signature as _}, - Signature, SigningKey, VerifyKey, + Signature, SigningKey, VerifyingKey, }, elliptic_curve::{generic_array::GenericArray, sec1::UntaggedPointSize}, CompressedPoint, EncodedPoint, Secp256k1, @@ -19,7 +19,7 @@ use std::{collections::BTreeMap, convert::TryFrom}; pub const ENR_KEY: &str = "secp256k1"; impl EnrKey for SigningKey { - type PublicKey = VerifyKey; + type PublicKey = VerifyingKey; fn sign_v4(&self, msg: &[u8]) -> Result, SigningError> { // take a keccak256 hash then sign. @@ -50,12 +50,12 @@ impl EnrKey for SigningKey { impl EnrKeyUnambiguous for SigningKey { fn decode_public(bytes: &[u8]) -> Result { // should be encoded in compressed form, i.e 33 byte raw secp256k1 public key - Ok(VerifyKey::new(bytes) + Ok(VerifyingKey::from_sec1_bytes(bytes) .map_err(|_| DecoderError::Custom("Invalid Secp256k1 Signature"))?) } } -impl EnrPublicKey for VerifyKey { +impl EnrPublicKey for VerifyingKey { type Raw = CompressedPoint; type RawUncompressed = GenericArray>;