Here is the fixed script

# Generator point coordinates
# Order
# 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
  • 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
    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$ 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
    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$ 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
    Dec 16, 2022 at 5:53

1 Answer 1


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

  • $\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
    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.