Skip to main content

decompress_pubkey

Function decompress_pubkey 

Source
pub fn decompress_pubkey<const LIMBS: usize>(
    params: &CurveParams<LIMBS>,
    compressed: &[u8],
) -> Option<PublicKey>
Expand description

SEC1 decompress: take a 0x02/0x03 || X encoding and return the 0x04 || X || Y uncompressed form, recovering Y via field_sqrt_p3mod4.

Returns None if the input is malformed, if X is not a valid x-coordinate on the curve (i.e. RHS(X) is a non-residue), or if the decompressed point fails the on-curve safety check.

Also accepts an already uncompressed input as a no-op, so callers can use decompress_pubkey(bytes) as a “normalise to uncompressed” entry point regardless of which form they start from.