Post
Topic
Board Development & Technical Discussion
Re: y coordinate calculation (PUBLIC KEY BITCOIN)
by
ETFbitcoin
on 03/12/2021, 11:28:54 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


I managed to solve the problem by replacing Integer() with int() and run it with Python 2.