The secp256k1 curve uses a prime number of \(2^{256}-2^{32}-977\) and \(y^2=x^3+7 \pmod p\). The base point is G= (5506626302227734366 ... 4175500187360389116729240L, 3267051002075881697 ... 904335757337482424L) and has an order of n = 1157920892373161954 ... 41518161494337L. In this case we enter the value of \(n\) and then use Sage to compute \(n.G\).
Sage: Elliptic Curve Point (P256) |
Outline
The secp256k1 curve uses a prime number of:
\(p=2^{256}-2^{32}-977\)
and:
\(y^2=x^3+7 \pmod p\)
The base point is:
G= (55066263022277343669578718895168534326250603453777594175500187360389116729240L, 32670510020758816978083085130507043184471273380659243275938904335757337482424L)
and has an order of:
n = 115792089237316195423570985008687907852837564279074904382605163141518161494337L
In this case we enter the value of \(n\) and then use Sage to compute \(n.G\).
Coding
import sys ## Alice's private key a = 1 str=sys.argv[1] a=int(str.split(";")[2]) ###### secp256k1 p256 = 2^256-2^32-977 a256 = 0 b256 = 7 ## Base point gx= 55066263022277343669578718895168534326250603453777594175500187360389116729240L gy= 32670510020758816978083085130507043184471273380659243275938904335757337482424L ## Curve order n = 115792089237316195423570985008687907852837564279074904382605163141518161494337L FF = GF(p256) EC = EllipticCurve([FF(a256), FF(b256)]) EC.set_order(n) ## Base point G = EC(FF(gx), FF(gy)) ## Alice's public key A = a*G print ("G=",G) print ("a=",a) print ("A=",A)
A sample run for \(1.G\) is:
G= (55066263022277343669578718895168534326250603453777594175500187360389116729240 : 32670510020758816978083085130507043184471273380659243275938904335757337482424 : 1) a= 1 A= (55066263022277343669578718895168534326250603453777594175500187360389116729240 : 32670510020758816978083085130507043184471273380659243275938904335757337482424 : 1)
and for \(10.G\):
G= (55066263022277343669578718895168534326250603453777594175500187360389116729240 : 32670510020758816978083085130507043184471273380659243275938904335757337482424 : 1) a= 10 A= (72488970228380509287422715226575535698893157273063074627791787432852706183111 : 62070622898698443831883535403436258712770888294397026493185421712108624767191 : 1)
and for \(100.G\):
G= (55066263022277343669578718895168534326250603453777594175500187360389116729240 : 32670510020758816978083085130507043184471273380659243275938904335757337482424 : 1) a= 100 A= (107303582290733097924842193972465022053148211775194373671539518313500194639752 : 103795966108782717446806684023742168462365449272639790795591544606836007446638 : 1)
To run within a Windows environment, we can use:
"c:\program files\SageMath 9.3\runtime\bin\bash.exe" -l "/opt/sagemath-9.3/sage" -c "os.chdir('C:\myfolder'); load('1.sage'); %1"