-1
$\begingroup$

According to my understanding a public key is made up of x and y coordinate and a compress public key is made up of the y-coordinate since it's possible to directly calculate the uncompress public key using the compress public key.

Using the below secp256k1 elliptic curve coordinate what formula can I use to derive the x-coordinate using the y-coordinate?

X-coordinate

x = 115780575977492633039504758427830329241728645270042306223540962614150928364886

Y-coordinate

y = 78735063515800386211891312544505775871260717697865196436804966483607426560663
$\endgroup$
8
  • $\begingroup$ Use the curve equation over the finite field? that is $ y^2 = x^3 + 7$ $\endgroup$
    – kelalaka
    Sep 14, 2023 at 11:22
  • $\begingroup$ The equation you provided solve for y using x, but am trying to solve for x using y $\endgroup$ Sep 14, 2023 at 11:37
  • 2
    $\begingroup$ This might be the dupe How to expand elliptic curve public key from compressed form?. It doesn't matter. Just replace the $y$ value then solve for $x$ over the defining field. That is the math basics. Also, your question is two folds, one asking finding $x$ given $y$, that is simple math solving, the other one is decompression of public key that the linked answer cover that. $x = \sqrt[3]{y^2 - 7}$ $\endgroup$
    – kelalaka
    Sep 14, 2023 at 13:10
  • 1
    $\begingroup$ First of all, you asked 5 questions, only one upvote and none accepted. This is not good behavior if you really seek help here. I've told you before and @MaartenBodewes told you here, too. I've provided the equation that include basic arithmetic. Do not forget that ECC in cryptography we work on modulus, so you need the cuberoot to modulo $p$ of the curve. This is not a code site, yes I've provided many SageMath code to illustrate the theory in practice and enjoyed that, too. If you are failing in the coding you can ask at Stack Overflow and there you will learn mode about coding. $\endgroup$
    – kelalaka
    Sep 14, 2023 at 18:53
  • 1
    $\begingroup$ Does this answer your question? How to expand elliptic curve public key from compressed form? . There is a misunderstanding of the compression here so this makes the dupe. In secp256k1, the comression includes the full $x$ coordinate with a byte prefix to indicate either the compression or the which $y$ value. Read in the dupe for details. $\endgroup$
    – kelalaka
    Sep 15, 2023 at 15:09

2 Answers 2

2
$\begingroup$

You can do it on the site by Willem Hengeveld. It only works with hexadecimal numbers.

You can use this site to convert to hex. In your case:

y  =78735063515800386211891312544505775871260717697865196436804966483607426560663
   =0xAE12777AACFBB620F3BE96017F45C560DE80F0F6518FE4A03C870C36B075F297

Solutions:
x_1=0x19cab650e04db19581801eb9e6c50b54f6a51b9223f6040c894f936926e302c3
x_2=0xfff97bd5755eeea420453a14355235d382f6472f8568a18b2f057a1460297556
x_3=0xe63bcdd9aa535fc65e3aa731e3e8bed786649d3e56a15a6847aaf28078f38045

x_2=x
   =115780575977492633039504758427830329241728645270042306223540962614150928364886
$\endgroup$
1
  • 1
    $\begingroup$ The linked site's "You can decompress from $y$ as well" section indeed does that. This answer would be better if it told how: with $p=2^{256}-2^{32}-977$, compute $z=y^2-7\bmod p$, then $x_1=z^{(p+2)/9}\bmod p$. There's a solution and $x_1$ is one of them if and only if ${x_1}^3\bmod p=z$. If so, then the two other solutions in $[0,p)$ are $x_2=α\,x_1\bmod p$ and $x_3=α\,x_2\bmod p$, with $α=2^{(p-1)/3}\bmod p$. I also wish the question was clarified to tell if it's about standard point decompression or this non-standard variant. $\endgroup$
    – fgrieu
    Jan 24 at 15:20
1
$\begingroup$

You got it wrong, if you have a public key, it is in a compressed form, you can calculate the value of X-coordinate then you can decompressed the public key using the value of X-coordinate, however, deriving the formula to get the value of Y-coordinate gives you 2 values of Y-coordinate which is being used to decompress the public key and get the corrext value of the private key (if that is your goal), it is really imppssible because of the nature of elliptic curve you will need to look for a match and correct value of Y to decompress the public key.

$\endgroup$
0

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.