Skip to content

Commit

Permalink
chore(deps): bump secp256k1 0.28 (#61)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattsse authored Mar 11, 2024
1 parent 123f3d3 commit b18ad2c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
8 changes: 3 additions & 5 deletions src/keys/rust_secp256k1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ impl EnrKey for secp256k1::SecretKey {
fn sign_v4(&self, msg: &[u8]) -> Result<Vec<u8>, 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];
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit b18ad2c

Please sign in to comment.