Coding & Journals, Bitcoin Programming.

one day or day one: you decide
-- unknown

I decide this is day one of my coding & journals journey.
Recently i pickup this book from O'Reilly titled 
"Programming Bitcoin" from Jimmy Song

Things i learned:
a. the bitcoin uses secp256k1 Elliptic Curve Cryptography
b. the keys which the 2 points X & Y could be stored in
    2 ways, compressed and uncompressed

Secp256k1
========

Simply an elliptic curved of this equation 

And the secp256k1 chooses a = 0, therefore it become

Also that the y and x will be in modulus where |P is a prime number.

The order to calculate the secp256k1 would be in the following order:
a. validate if the given coordinate x & y by plug in the numbers
    into the formula, if it is equal meaning coordinate on-curve
b. |P is 
c. n is selected constant value of 0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141
d. then G is a point of the elliptic curve

e.g:

>>> from ecc import FieldElement, Point
>>> gx = 0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798
>>> gy = 0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8 
>>>p=2**256-2**32-977
>>> n = 0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141
>>> x = FieldElement(gx, p)
>>> y = FieldElement(gy, p)
>>> seven = FieldElement(7, p)
>>> zero = FieldElement(0, p)
>>> G = Point(x, y, zero, seven)
>>> print(n*G)

Point(infinity

*/ Note: that these snippets are from Chapter-03, the source code itself hosted at github of JimmySong.

Comments