Finding Mod-p Square Roots with the Tonelli-Shanks Algorithm

preview_player
Показать описание
In this video we review the theory of quadratic residues of an odd prime and then implement the Tonelli-Shanks algorithm in Python to find a square root. We end the video by showing how we can use this algorithm to find points with given x-values on real world elliptic curves.

Code:
Рекомендации по теме
Комментарии
Автор

I had never heard that odd primes are congruent to either 1 or 3 mod 4, thanks for teaching me something new today! I'll have to think about that.

MrCoreyTexas
Автор

Euler was an astounding mathematician, I didn't know about Euler's criterion until now

MrCoreyTexas
Автор

where is i can find code from video?please answer🙏🙏🙏

Ubertech-vt
Автор

nice! btw, on Python 3, one can use formatted strings in print statements.

schrodingerbracat
Автор

Maybe you could give some insight as to why it's called a quadratic residue? I guess that sounds better than "has an integer square root mod p"? Would a cube root be called a cubic residue and so on?

MrCoreyTexas
Автор

For the loop where you dividing by two can’t you just do bit search … as in it is odd only if least significant bit is 1… ie you just searching for first occurrence of 1 .. and shift that number of bits.

trollmole
Автор

Now I know one of the reasons Bitcoin picked SECP256K1, the prime it uses is congruent to 3 mod 4, so it's way easier to find your y's given an x, which is important when they compress public keys and only say whether y is even or odd

MrCoreyTexas