# Bitcoin Forum

## Bitcoin => Development & Technical Discussion => Topic started by: Yves Cuicui on September 03, 2013, 05:16:16 PM

 Title: x^3+7=0 ? Post by: Yves Cuicui on September 03, 2013, 05:16:16 PM Given the x coordinate of a point on the EC curve, it's easy to compute one of the y coordinate.But, given y, how can we get x? In particular does someone know a solution to x^3+7 = 0 on the secp256k1 curve?Thanks Title: Re: x^3+7=0 ? Post by: mustyoshi on September 04, 2013, 01:24:49 AM It only becomes trivial to crack the equation when the same "random" number is used in subsequent transactions. Basically the same way they got into Sony's servers, it can, and has been executed on the Blockchain, a few months back some application was using the same random numbers in transactions and people were able to calculate the private key. Title: Re: x^3+7=0 ? Post by: Yves Cuicui on September 04, 2013, 10:49:05 AM Thanks for your comment mustyoshiMy question is simply, what are the points that lies on the x axis.Alternatively, how many are there, 1 or 3? Title: Re: x^3+7=0 ? Post by: johoe on September 04, 2013, 11:05:29 AM It shouldn't be too difficult to compute the cubic-root modulo p. There are at most three solution, but I'm not sure if there are always three solutions.The idea for square root is the following.  For every number x^p = x (mod p), hence x^(p+1) = x^2 (mod p), hence x^((p+1)/2) = x (mod p) and x^((p+1)/4) = sqrt(x) (mod p) is one of the two square roots.  The other is obtained by negation.For cubic roots a similar approach should work.  If (p+1) is divisible by three then x^(p+1)/6 is a cubic root (I'm too lazy to check if this is the case).  There should be a general way to find a cubic root for any prime p. Title: Re: x^3+7=0 ? Post by: jackjack on September 04, 2013, 11:06:44 AM Quote from: johoe on September 04, 2013, 11:05:29 AMIt shouldn't be too difficult to compute the cubic-root modulo p. There are at most three solution, but I'm not sure if there are always three solutions.The idea for square root is the following.  For every number x^p = x (mod p), hence x^(p+1) = x^2 (mod p), hence x^((p+1)/2) = x (mod p) and x^((p+1)/4) = sqrt(x) (mod p) is one of the two square roots.  The other is obtained by negation.For cubic roots a similar approach should work.  If (p+1) is divisible by three then x^(p+1)/6 is a cubic root (I'm too lazy to check if this is the case).  There should be a general way to find a cubic root for any prime p.I tried yesterday but no, p is not divisible by threeIt's divisible by 2, 4, 8, 16 then big numbers (>1M) Title: Re: x^3+7=0 ? Post by: fpgaminer on September 04, 2013, 11:12:53 AM QuoteBut, given y, how can we get x? In particular does someone know a solution to x^3+7 = 0 on the secp256k1 curve?Well, it's just a finite field, so this should work:Code:x = modular_cube_root ((y^2 - 7) % p, p)I used the code listed here (http://stackoverflow.com/questions/6752374/cube-root-modulo-p-how-do-i-do-this) to solve your particular example.  It returns None, so probably there isn't an x that solves the equation when y is 0. Title: Re: x^3+7=0 ? Post by: Yves Cuicui on September 04, 2013, 11:37:24 AM Thanks for these ideas. I will dig in.Quote from: fpgaminer on September 04, 2013, 11:12:53 AMQuoteI used the code listed here (http://stackoverflow.com/questions/6752374/cube-root-modulo-p-how-do-i-do-this) to solve your particular example.  It returns None, so probably there isn't an x that solves the equation when y is 0.As N is odd and all points are duals (x,y) and (x,-y), there is at least one point (x,0), so you must get one. Title: Re: x^3+7=0 ? Post by: johoe on September 04, 2013, 01:30:39 PM There is always the point at infinity (the neutral element of the elliptic curve group).  This explains why the total number of points is odd if there is no solution for y=0. Title: Re: x^3+7=0 ? Post by: Yves Cuicui on September 04, 2013, 02:20:51 PM  Shame on me   :-[ Title: Re: x^3+7=0 ? Post by: Yves Cuicui on February 23, 2014, 10:07:16 PM This just to finalize this topic.Because P=9xu+7, if a cubic root exists it can be computed by r1=a^((P+2)/9).The other two solutions are: r2=0x3fffffffffffffffffffffffffffffffffffffffffffffffffffffffbfffff0c . r1r3=0x1c71c71c71c71c71c71c71c71c71c71c71c71c71c71c71c71c71c71c555554e9 . r1Then it is easy to see that -7 has no cubic root because ((-7)^((P+2)/9))^3 <> -7Then there is no points with y=0my 2 centsThanks to you all