pub fn field_sqrt_p3mod4<const LIMBS: usize>(
a: &FieldElement<LIMBS>,
p: &[u64; LIMBS],
) -> FieldElement<LIMBS>Expand description
Compute a square root of a in the prime field Fp, assuming
p ≡ 3 (mod 4). Uses the closed-form identity
y = a^((p+1)/4) mod pWhen a is a quadratic residue, y * y ≡ a (mod p) and p - y is
the other square root. When a is a non-residue, the returned
value is not a square root of anything useful – callers MUST verify
y*y == a mod p before trusting it.
All six curves currently shipped by this crate (P-256, P-384,
secp256k1, brainpoolP{256,384,512}r1) have p ≡ 3 (mod 4), so this
is the only sqrt helper we need. P-521 also satisfies p ≡ 3 (mod 4)
and will reuse this function.
Used by SEC1 compressed-point decompression (recovering y from x).