Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: Harald1970 on December 09, 2021, 08:12:50 PM



Title: Verifying G on y² = x³ + 7 mod p
Post by: Harald1970 on December 09, 2021, 08:12:50 PM
Hi guys,

About the elliptic curve y² = x³ + 7 mod p Bitcoin uses:

As i understood base point G should be on that curve where point G should have the following coordinates:

x = 79BE667EF9DCBBAC55A06295CE870B07029BFCDB2DCE28D959F2815B16F81798
y = 483ADA7726A3C4655DA4FBFC0E1108A8FD17B448A68554199C47D08FFB10D4B8

In decimal format:

x = 55066263022277343669578718895168534326250603453777594175500187360389116729240
y = 32670510020758816978083085130507043184471273380659243275938904335757337482424

and p should be:

2^256 – 2^32 – 977 = 115792089237316195423570985008687907853269984665640564039457584007908834671663

However, when I enter these values in the equation (y² = x³ + 7 mod p)

(32670510020758816978083085130507043184471273380659243275938904335757337482424)² mod 115792089237316195423570985008687907853269984665640564039457584007908834671663 = (55066263022277343669578718895168534326250603453777594175500187360389116729240)³ + 7 mod 115792089237316195423570985008687907853269984665640564039457584007908834671663

I come to a totally different conclusion.

Namely:

32748224938747404814623910738487752935528512903530129802856995983256684603122 =
1669770616981538039777298102996166657201110805898885633627016627799942916593334 7716953447757272370428515427513339781177865265195629184436663606848320359309455 8427352525126936769086968791554813695916119291254705683450242657305024007

So what did i do wrong?


Title: Re: Verifying G on y² = x³ + 7 mod p
Post by: BlackHatCoiner on December 09, 2021, 08:21:10 PM
So what did i do wrong?
In here, you're mod-ing 7 with p instead of (x3 + 7) with p:

Quote
(55066263022277343669578718895168534326250603453777594175500187360389116729240)³ + 7 mod 115792089237316195423570985008687907853269984665640564039457584007908834671663

If you mod (x3 + 7) with p, you will, indeed, get:
Code:
32748224938747404814623910738487752935528512903530129802856995983256684603122


Title: Re: Verifying G on y² = x³ + 7 mod p
Post by: garlonicon on December 09, 2021, 08:24:29 PM
Quote
1669770616981538039777298102996166657201110805898885633627016627799942916593334
7716953447757272370428515427513339781177865265195629184436663606848320359309455
8427352525126936769086968791554813695916119291254705683450242657305024007
Just use modulo on that number and it will be correct. You used modulo on x-value, but not on y-value, so they are obviously not equal.

Edit:
Quote
you're mod-ing 7 with p
You are right, using 7 modulo something bigger than 7 does not change anything.


Title: Re: Verifying G on y² = x³ + 7 mod p
Post by: Harald1970 on December 09, 2021, 09:18:42 PM
Thank you guys! What harm a simple bracket at the wrong place can do!  8)