Skip to content
This repository was archived by the owner on Nov 20, 2023. It is now read-only.

Commit 074fe32

Browse files
authored
Update k256 to 0.7 (#24)
1 parent 200ca52 commit 074fe32

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ rlp = "0.4.5"
2424
zeroize = "1.1.0"
2525
libsecp256k1 = { version = "0.3.5", optional = true }
2626
sha3 = "0.9"
27-
k256 = { version = "0.5", features = ["ecdsa", "zeroize"], optional = true }
27+
k256 = { version = "0.7", features = ["ecdsa", "zeroize"], optional = true }
2828
serde = { version = "1.0.110", optional = true }
2929
ed25519-dalek = { version = "1.0.0-pre.4", optional = true }
3030
c-secp256k1 = { package = "secp256k1", version = "0.19", optional = true, features = ["global-context"] }

src/keys/combined.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ impl CombinedKey {
9696

9797
/// Imports a secp256k1 from raw bytes in any format.
9898
pub fn secp256k1_from_bytes(bytes: &mut [u8]) -> Result<Self, DecoderError> {
99-
let key = k256::ecdsa::SigningKey::new(bytes)
99+
let key = k256::ecdsa::SigningKey::from_bytes(bytes)
100100
.map_err(|_| DecoderError::Custom("Invalid secp256k1 secret key"))
101101
.map(Self::from)?;
102102
bytes.zeroize();
@@ -127,13 +127,13 @@ impl CombinedKey {
127127
#[derive(Clone, Debug, PartialEq)]
128128
pub enum CombinedPublicKey {
129129
/// An `Secp256k1` public key.
130-
Secp256k1(k256::ecdsa::VerifyKey),
130+
Secp256k1(k256::ecdsa::VerifyingKey),
131131
/// An `Ed25519` public key.
132132
Ed25519(ed25519::PublicKey),
133133
}
134134

135-
impl From<k256::ecdsa::VerifyKey> for CombinedPublicKey {
136-
fn from(public_key: k256::ecdsa::VerifyKey) -> Self {
135+
impl From<k256::ecdsa::VerifyingKey> for CombinedPublicKey {
136+
fn from(public_key: k256::ecdsa::VerifyingKey) -> Self {
137137
Self::Secp256k1(public_key)
138138
}
139139
}

src/keys/k256_key.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use crate::Key;
55
use k256::{
66
ecdsa::{
77
signature::{DigestVerifier, RandomizedDigestSigner, Signature as _},
8-
Signature, SigningKey, VerifyKey,
8+
Signature, SigningKey, VerifyingKey,
99
},
1010
elliptic_curve::{generic_array::GenericArray, sec1::UntaggedPointSize},
1111
CompressedPoint, EncodedPoint, Secp256k1,
@@ -19,7 +19,7 @@ use std::{collections::BTreeMap, convert::TryFrom};
1919
pub const ENR_KEY: &str = "secp256k1";
2020

2121
impl EnrKey for SigningKey {
22-
type PublicKey = VerifyKey;
22+
type PublicKey = VerifyingKey;
2323

2424
fn sign_v4(&self, msg: &[u8]) -> Result<Vec<u8>, SigningError> {
2525
// take a keccak256 hash then sign.
@@ -50,12 +50,12 @@ impl EnrKey for SigningKey {
5050
impl EnrKeyUnambiguous for SigningKey {
5151
fn decode_public(bytes: &[u8]) -> Result<Self::PublicKey, DecoderError> {
5252
// should be encoded in compressed form, i.e 33 byte raw secp256k1 public key
53-
Ok(VerifyKey::new(bytes)
53+
Ok(VerifyingKey::from_sec1_bytes(bytes)
5454
.map_err(|_| DecoderError::Custom("Invalid Secp256k1 Signature"))?)
5555
}
5656
}
5757

58-
impl EnrPublicKey for VerifyKey {
58+
impl EnrPublicKey for VerifyingKey {
5959
type Raw = CompressedPoint;
6060
type RawUncompressed = GenericArray<u8, UntaggedPointSize<Secp256k1>>;
6161

0 commit comments

Comments
 (0)