Skip to content

Commit

Permalink
Bump k256 dependency to v0.13 (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
tarcieri authored Mar 9, 2023
1 parent 79d2df3 commit 7e12e4e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down
4 changes: 2 additions & 2 deletions src/keys/combined.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand All @@ -97,7 +97,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::from_bytes(bytes)
let key = k256::ecdsa::SigningKey::from_slice(bytes)
.map_err(|_| DecoderError::Custom("Invalid secp256k1 secret key"))
.map(Self::from)?;
bytes.zeroize();
Expand Down
10 changes: 5 additions & 5 deletions src/keys/k256_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand All @@ -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<Key, Bytes>) -> Result<Self::PublicKey, DecoderError> {
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 7e12e4e

Please sign in to comment.