SqrtDem
Square Root Modulo P Algorithm
Calculate using Shanks' RESSOL algorithm
Understanding Square Roots Modulo Prime
The square root modulo prime problem asks: given integers and prime , find such that . Shanks' RESSOL algorithm efficiently solves this when a solution exists:
- 1First, we check if is a quadratic residue modulo using Euler's criterion:
- 2For the special case where , we can use the simple observation:
- 3For , we factor where is odd
- 4We find a quadratic non-residue modulo (an element where )
- 5Using the Tonelli-Shanks algorithm, we iteratively reduce the problem until we find the square root
- 6The algorithm maintains the invariant that we're solving where has decreasing order of 2