From b18ad2cf0926ba92a90f0124863cf804150e7e79 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Mon, 11 Mar 2024 06:58:06 +0100 Subject: [PATCH] chore(deps): bump secp256k1 0.28 (#61) --- Cargo.toml | 4 ++-- src/keys/rust_secp256k1.rs | 8 +++----- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 6fd34dd..ff3a92c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,12 +23,12 @@ sha3 = "0.10" k256 = { version = "0.13", features = ["ecdsa"], optional = true } serde = { version = "1.0.110", features = ["derive"], optional = true } ed25519-dalek = { version = "2.0.0", optional = true, features = ["rand_core"] } -secp256k1 = { version = "0.27", optional = true, default-features = false, features = [ +secp256k1 = { version = "0.28", optional = true, default-features = false, features = [ "global-context", ] } [dev-dependencies] -secp256k1 = { features = ["rand-std"], version = "0.27" } +secp256k1 = { features = ["rand-std"], version = "0.28" } serde_json = { version = "1.0.95" } [features] diff --git a/src/keys/rust_secp256k1.rs b/src/keys/rust_secp256k1.rs index 70a1265..010bcd0 100644 --- a/src/keys/rust_secp256k1.rs +++ b/src/keys/rust_secp256k1.rs @@ -20,8 +20,7 @@ impl EnrKey for secp256k1::SecretKey { fn sign_v4(&self, msg: &[u8]) -> Result, SigningError> { // take a keccak256 hash then sign. let hash = digest(msg); - let m = secp256k1::Message::from_slice(&hash) - .map_err(|_| SigningError::new("failed to parse secp256k1 digest"))?; + let m = secp256k1::Message::from_digest(hash); // serialize to an uncompressed 64 byte vector let signature = { let mut noncedata = [0; 32]; @@ -61,9 +60,8 @@ impl EnrPublicKey for secp256k1::PublicKey { fn verify_v4(&self, msg: &[u8], sig: &[u8]) -> bool { let msg = digest(msg); if let Ok(sig) = secp256k1::ecdsa::Signature::from_compact(sig) { - if let Ok(msg) = secp256k1::Message::from_slice(&msg) { - return SECP256K1.verify_ecdsa(&msg, &sig, self).is_ok(); - } + let msg = secp256k1::Message::from_digest(msg); + return SECP256K1.verify_ecdsa(&msg, &sig, self).is_ok(); } false }