Skip to main content

normalize_p256_s

Function normalize_p256_s 

Source
pub fn normalize_p256_s(s_bytes: &[u8]) -> FixedBytes<32>
Expand description

Normalize P256 signature s value to low-s form.

For any ECDSA signature (r, s), both (r, s) and (r, n-s) are valid. To prevent signature malleability, we require s <= n/2. If s > n/2, we replace it with n - s.

This function should be called by all P256 signing code before creating a signature, as the p256 crate does not guarantee low-s signatures.