Tonelli-Shanks
In a congruence of the form r2 ā” a mod p
, Tonelli-Shanks calculates r
.
Tonelli-Shanks doesn't work for composite (non-prime) moduli. Finding square roots modulo composites is computationally equivalent to integer factorization - that is, it's a hard problem.
The main use-case for this algorithm is finding elliptic curve co-ordinates. Its operation is somewhat complex so we're not going to discuss the details. But there is a python implementation
Note the line 13 ? If s == 1
it's possible to quickly get the square root value with the following equation :
This occur cause a property of primes numbers : all primes that aren't 2 are of the form p ā” 1 mod 4
or p ā” 3 mod 4
, since all odd numbers obey these congruences.
It's possible cause p + 1
is divisible by 4 unlike the case p ā” 1 mod 4
and a
is a quadritic residue so it follows that :
Resources
Last updated