Skip to content
This repository was archived by the owner on Nov 20, 2023. It is now read-only.
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.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }
Expand Down
8 changes: 4 additions & 4 deletions src/keys/combined.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ impl CombinedKey {

/// Imports a secp256k1 from raw bytes in any format.
pub fn secp256k1_from_bytes(bytes: &mut [u8]) -> Result<Self, DecoderError> {
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();
Expand Down Expand Up @@ -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<k256::ecdsa::VerifyKey> for CombinedPublicKey {
fn from(public_key: k256::ecdsa::VerifyKey) -> Self {
impl From<k256::ecdsa::VerifyingKey> for CombinedPublicKey {
fn from(public_key: k256::ecdsa::VerifyingKey) -> Self {
Self::Secp256k1(public_key)
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/keys/k256_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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<Vec<u8>, SigningError> {
// take a keccak256 hash then sign.
Expand Down Expand Up @@ -50,12 +50,12 @@ impl EnrKey for SigningKey {
impl EnrKeyUnambiguous for SigningKey {
fn decode_public(bytes: &[u8]) -> Result<Self::PublicKey, DecoderError> {
// 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<u8, UntaggedPointSize<Secp256k1>>;

Expand Down