1
$\begingroup$

Here is the fixed script

# Generator point coordinates
x=55066263022277343669578718895168534326250603453777594175500187360389116729240
y=32670510020758816978083085130507043184471273380659243275938904335757337482424
# Order
n=115792089237316195423570985008687907853269984665640564039457584007908834671663
# from the curve equation y^2=x^3+7
should_be_zero= (y**2)-(x**3+7)
print("by applying the equation, this should be equal to 0 :",should_be_zero)
# The remainder from the division by n should be 0
print("should_be_zero divided by n leaves:",should_be_zero%n)

the output

by applying the equation, this should be equal to 0 : -166977061698153803977729810299616665720111080589888563362701662779994291659332409807309461070447932090244771419528434792678509158779752908144538176572381887934774683088169260414743338484604182122883788458741320363571878334796108231
should_be_zero divided by n leaves: 0
$\endgroup$
5
  • 1
    $\begingroup$ You do realize for any valid $x$ coordinate, there are two possible $y$ coordinates (and both $y$ coordinates correspond to valid points). Perhaps your 'curve' function returns the other one... $\endgroup$
    – poncho
    Commented Dec 15, 2022 at 19:51
  • $\begingroup$ thank you for pointing that out but i've tried the other point with no success, i will try to rephrase my question to eliminate that posibility. $\endgroup$ Commented Dec 15, 2022 at 21:17
  • $\begingroup$ Hint: the curve's equation $y^2=x^3+7$ is in the BASE FIELD. $n$ is the order of the ELLIPTIC CURVE GROUP. These are like car and pizza. Parameters for secp25k1. $\endgroup$
    – fgrieu
    Commented Dec 15, 2022 at 21:34
  • $\begingroup$ could you be more explicit please ? [moderator note: as stated there, this group's practice is to only give hint on homework questions; see e.g. this meta]. $\endgroup$ Commented Dec 15, 2022 at 22:18
  • 2
    $\begingroup$ Enough with analogies. The curve's equation $y^2=x^3+7$ is with $x$, $y$, the addition and multiplication operators for a field noted $\mathbb F_p$ in this reference. Your code is trying to verify it in another field $\mathbb F_n$, where $n$ is the order (number of elements) of the Elliptic Curve group secp256k1. That's reason enough for the verification to fail. $\endgroup$
    – fgrieu
    Commented Dec 16, 2022 at 5:53

1 Answer 1

2
$\begingroup$

The generator point belongs to the curve when using the right parameters.

$\endgroup$
1
  • $\begingroup$ That is, the modulus for the coordinates is $p$, which is different from the order (number of elements) of the curve $n$. (This detail better be included in the answer. $\endgroup$
    – DannyNiu
    Commented Dec 16, 2022 at 10:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.