Skip to main content

sqrt_tonelli_shanks

Function sqrt_tonelli_shanks 

pub fn sqrt_tonelli_shanks<F, S>(f: &F, tm1d2: S) -> CtOption<F>
where F: PrimeField, S: AsRef<[u64]>,
Expand description

Constant-time implementation of Tonelli–Shanks’ square-root algorithm for p mod 16 = 1.

tm1d2 should be set to (t - 1) // 2, where t = (modulus - 1) >> F::S.

§Implementing Field::sqrt

This function can be used to implement Field::sqrt for fields that both implement PrimeField and satisfy p mod 16 = 1.