ECDSA Signature Verification
Noir supports ECDSA signatures verification over the secp256k1 and secp256r1 curves.
ecdsa_secp256k1::verify_signature
Verifier for ECDSA Secp256k1 signatures. See ecdsa_secp256k1::verify_signature_slice for a version that accepts slices directly.
pub fn verify_signature<N>(
public_key_x: [u8; 32],
public_key_y: [u8; 32],
signature: [u8; 64],
message_hash: [u8; N]
) -> bool
Source code: noir_stdlib/src/ecdsa_secp256k1.nr#L2-L9
example:
fn main(hashed_message : [u8;32], pub_key_x : [u8;32], pub_key_y : [u8;32], signature : [u8;64]) {
let valid_signature = std::ecdsa_secp256k1::verify_signature(pub_key_x, pub_key_y, signature, hashed_message);
assert(valid_signature);
}
This is a black box function. Read this section to learn more about black box functions in Noir.
ecdsa_secp256k1::verify_signature_slice
Verifier for ECDSA Secp256k1 signatures where the message is a slice.
pub fn verify_signature_slice(
public_key_x: [u8; 32],
public_key_y: [u8; 32],
signature: [u8; 64],
message_hash: [u8]
) -> bool
Source code: noir_stdlib/src/ecdsa_secp256k1.nr#L13-L20
This is a black box function. Read this section to learn more about black box functions in Noir.
ecdsa_secp256r1::verify_signature
Verifier for ECDSA Secp256r1 signatures. See ecdsa_secp256r1::verify_signature_slice for a version that accepts slices directly.
pub fn verify_signature<N>(
public_key_x: [u8; 32],
public_key_y: [u8; 32],
signature: [u8; 64],
message_hash: [u8; N]
) -> bool
Source code: noir_stdlib/src/ecdsa_secp256r1.nr#L2-L9
example:
fn main(hashed_message : [u8;32], pub_key_x : [u8;32], pub_key_y : [u8;32], signature : [u8;64]) {
let valid_signature = std::ecdsa_secp256r1::verify_signature(pub_key_x, pub_key_y, signature, hashed_message);
assert(valid_signature);
}
This is a black box function. Read this section to learn more about black box functions in Noir.
ecdsa_secp256r1::verify_signature
Verifier for ECDSA Secp256r1 signatures where the message is a slice.
pub fn verify_signature_slice(
public_key_x: [u8; 32],
public_key_y: [u8; 32],
signature: [u8; 64],
message_hash: [u8]
) -> bool
Source code: noir_stdlib/src/ecdsa_secp256r1.nr#L13-L20
This is a black box function. Read this section to learn more about black box functions in Noir.