Skip to content

Commit

Permalink
chore: replace deprecated function
Browse files Browse the repository at this point in the history
  • Loading branch information
mattsse committed Mar 8, 2024
1 parent 50ed042 commit 558f561
Showing 1 changed file with 3 additions and 5 deletions.
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 558f561

Please sign in to comment.