Skip to main content

verify_p256_signature_internal

Function verify_p256_signature_internal 

Source
fn verify_p256_signature_internal(
    r: &[u8],
    s: &[u8],
    pub_key_x: &[u8],
    pub_key_y: &[u8],
    message_hash: &B256,
) -> Result<(), &'static str>
Expand description

Verifies a P256 signature using the provided components

This performs actual cryptographic verification of the P256 signature according to the spec. Called during recover_signer() to ensure only valid signatures enter the mempool.

Includes a high-s value check to prevent signature malleability. For any ECDSA signature (r, s), a second valid signature (r, n-s) exists. By requiring s <= n/2 (the “low-s” requirement), we ensure only one canonical form is accepted, preventing transaction hash malleability attacks.

NOTE: this function conditionally compiles based on the cfg

  • !std → p256
  • std && !test → aws-lc-rs (best performance)
  • std && test → both (ensures verification backend alignment)