Some ECC Types and Operations

We have a number of possible types of elliptic curve methods. These have a field (the prime number used), the order (the number of elliptic curve points), an a value, a b value, and a generator point (G). For a Weierstrass curve the standard form is y²=x³+ax+b (such as secp256k1). With a twisted Edwards curve (such as Ed25519) we have the form of ax²+y²=1+dx²y². A Montgomery curve has the form of by²=x³+ax²+x.

With ECC, we typically take a base point (G) and multiply it with our private key (sk), and then generate our public key point (sk.G). A sample run for secp256k1 and for 1,000G is []:

Curve: secp256k1
G: (0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 , 0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8)
Bit size: 256
Order: 115792089237316195423570985008687907852837564279074904382605163141518161494337
Field: 115792089237316195423570985008687907853269984665640564039457584007908834671663
a: 0
b: 7
1000G: (0x4a5169f673aa632f538aaa128b6348536db2b637fd89073d49b6a23879cdb3ad , 0xbaf1e702eb2a8badae14ba09a26a8ca7cb1127b64b2c39a1c7ba61f4a3c62601)Point add (add 1G on)1001G: (0x9d1abaec9f5715a15c7628244170951e0f85e87f68ca5393d3f9fc3fa23a69c8 , 0xf21ee70050dbb61c238c89e62942353871b010e798867bdd149ad28b3f28cadf)Point subtraction (take 1G off)1000G: (0x4a5169f673aa632f538aaa128b6348536db2b637fd89073d49b6a23879cdb3ad , 0xbaf1e702eb2a8badae14ba09a26a8ca7cb1127b64b2c39a1c7ba61f4a3c62601)The first 10 points ...

The field is the prime number used, and the order is the number of points on the curve. We can see we have the form of y²=x³+7. The outline code is []:

from ecpy.curves     import Curveimport syso=3
if (len(sys.argv)>1):
if (len(sys.argv)>2):
cv = Curve.get_curve('Curve25519')if (o==1): cv = Curve.get_curve('Curve25519')
if (o==2): cv = Curve.get_curve('Curve448')
if (o==3): cv = Curve.get_curve('Ed25519')
if (o==4): cv = Curve.get_curve('Ed448')
if (o==5): cv = Curve.get_curve('secp160r2')
if (o==6): cv = Curve.get_curve('secp256k1')
if (o==7): cv = Curve.get_curve('secp521r1')
if (o==8): cv = Curve.get_curve('NIST-P192')
if (o==9): cv = Curve.get_curve('NIST-P224')
if (o==10): cv = Curve.get_curve('NIST-P256')
print (f"Curve: {}")
print ("====================")
print (f"G: {cv.generator}")
print (f"Bit size: {cv.size}")
print (f"Order: {cv.order}")
print (f"Field: {cv.field}")
print (f"a: {cv.a}")
if (o==3 or o==4): print (f"b: {cv.d}")
else: print (f"b: {cv.b}")
print ("====================")
G=cv.generatorQ = k*Gprint (f"\n{k}G: {Q}")print ("\nPoint add (add 1G on)")
P = G
print (f"\n{k+1}G: {R}")print ("\nPoint subtraction (take 1G off)")
print (f"\n{k}G: {R}")print ("\nThe first 10 points ...")
for i in range(1,11):
if (o==3 or o==4):
print (f"({x},{i})")
print (f"(NO POINT,{i})")
print (f"({i},{y})")

You can run this here:

Professor of Cryptography. Serial innovator. Believer in fairness, justice & freedom. EU Citizen. Auld Reekie native. Old World Breaker. New World Creator.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store