Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions keetanetwork-crypto/src/algorithms/secp256k1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,13 @@ impl CryptoVerifierWithOptions<Signature> for Secp256k1PublicKey {
let message = message.as_ref();
let verifying_key = VerifyingKey::from(&self.inner);

// Always enforce low-S signatures (BIP-62 compliance)
// Use normalize_low_s() to convert high-S signatures before verification
let sig_bytes: [u8; 64] = signature.to_bytes().into();
if !crate::utils::is_low_s(&sig_bytes, Algorithm::Secp256k1) {
return Err(::signature::Error::new());
}

if options.raw {
// For raw verification, treat the message as a pre-computed hash
// and use prehash verification to avoid double hashing
Expand Down
7 changes: 7 additions & 0 deletions keetanetwork-crypto/src/algorithms/secp256r1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,13 @@ impl CryptoVerifierWithOptions<Signature> for Secp256r1PublicKey {
let message = message.as_ref();
let verifying_key = VerifyingKey::from(&self.inner);

// Always enforce low-S signatures (BIP-62 compliance)
// Use normalize_low_s() to convert high-S signatures before verification
let sig_bytes: [u8; 64] = signature.to_bytes().into();
if !crate::utils::is_low_s(&sig_bytes, Algorithm::Secp256r1) {
return Err(::signature::Error::new());
}

if options.raw {
// For raw verification, treat the message as a pre-computed hash
// and use prehash verification to avoid double hashing
Expand Down
Loading
Loading