Post
Topic
Board Development & Technical Discussion
Re: y coordinate calculation (PUBLIC KEY BITCOIN)
by
mausuv
on 02/12/2021, 13:21:34 UTC


script: y from x

Code:
p = 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f
x = 0x33709eb11e0d4439a729f21c2c443dedb727528229713f0065721ba8fa46f00e
ysquared = ((x*x*x+7) % p)   
print ("ysquared= %s ",  hex(ysquared) )   
y = pow(ysquared, (p+1)/4, p)
print ("y1 =  ",hex(y))
print ("y2 =  ", hex(y * -1 % p))
y1 = y
y2 = (y * -1) % p
print(" ")
print("value x = ",hex(x))
print("value x = ",x)
print("         ")

if Integer(y1) % 2 == 0:
   
    print("value 02 to y = ",hex(y1))
    print("value 02 to y =",y1)
    print(" ")
    print("value 03 to y = ",hex(y2))
    print("value 03 to y =",y2)
   

if Integer(y2) % 2 == 0:
    print("value 02 to y = ",hex(y2))
    print("value 02 to y =",y2)
    print(" ")
    print("value 03 to y = ",hex(y1))
    print("value 03 to y =",y1)
   

#test
print (hex((x**3 + 7 - y1**2) % p) ) 

print (hex((x**3 + 7 - y2**2) % p)) 



i am run your code python and python2 both erro why?Huh?....
NameError: name 'Integer' is not defined


Code:
user@me133:~/Downloads$ python 3.py
ysquared= %s  0x8ff5190f5e682d223717cd48318a53d918a5c48335924148963d7fc92c852e00
Traceback (most recent call last):
  File "3.py", line 5, in <module>
    y = pow(ysquared, (p+1)/4, p)
TypeError: pow() 3rd argument not allowed unless all arguments are integers

user@me133:~/Downloads$ python2 3.py[
('ysquared= %s ', '0x8ff5190f5e682d223717cd48318a53d918a5c48335924148963d7fc92c852e00L')
('y1 =  ', '0x4bb74cfb14940bce37a2468d7873ea0d0ac01a946607fd774ffb8cdbfb022eacL')
('y2 =  ', '0xb448b304eb6bf431c85db972878c15f2f53fe56b99f80288b004732304fdcd83L')
 
('value x = ', '0xc0c686408d517dfd67c2367651380d00d126e4229631fd03f8ff35eef1a61e3cL')
('value x = ', 87194829221142880348582938487511785107150118762739500766654458540580527283772L)
         
Traceback (most recent call last):
  File "3.py", line 15, in <module>
    if Integer(y1) % 2 == 0:
NameError: name 'Integer' is not defined

user@me133:~/Downloads$ python3 3.py
ysquared= %s  0x8ff5190f5e682d223717cd48318a53d918a5c48335924148963d7fc92c852e00
Traceback (most recent call last):
  File "3.py", line 5, in <module>
    y = pow(ysquared, (p+1)/4, p)
TypeError: pow() 3rd argument not allowed unless all arguments are integers