Mastering Bitcoin chapter 4 - 01 Public and Private keys as points in a curve
1 Private key
k is a random 256 bit integer.
2 Public key
We multiply the generator point
k, basically adding G to itself k number of times.
Get the secp256k1 curve's parameters from bouncy castle library:
Get the generator point G:
Multiply G with the private key to obtain the point P (the private key) and normalize (not sure what normalize means here). Points in the curve have a x and y coordinates.
The public key is the string concatenation of prefix + x + y
This exchange with chatGPT is also helpful:
Q: Bitcoin private keys are 256 bit integers. These are massive numbers. A public key, is achieved by multiplying the generator point of the secp256k1 curve, with the private key. how is this efficient?
A: Bitcoin private keys are 256-bit integers, which are large numbers. A public key is generated by multiplying a known generator point of the secp256k1 curve with the private key. This process is known as point multiplication and it is efficient because it takes advantage of the mathematical properties of elliptic curve cryptography.
The secp256k1 curve is defined by the equation y^2 = x^3 + 7, and the generator point is a specific point on this curve that has a large order. Point multiplication is performed by repeatedly adding a point to itself (doubling) and adding the generator point back in when the private key has a 1-bit. This process is called the "double-and-add" method.
The double-and-add method allows the multiplication to be performed in a very efficient way, because it requires very few additions and doublings. This is because the point multiplication is done by simple bit shifting and conditional bitwise operations that are much faster than traditional multiplication methods.
Additionally, the secp256k1 curve has been specifically chosen for its efficient point multiplication and the large order of the generator point. This makes it well-suited for use in public-key cryptography such as the one used in bitcoin.
In summary, the efficiency of point multiplication in generating public keys from private keys in bitcoin relies on the mathematical properties of the secp256k1 curve and the double-and-add method which is a very efficient way of doing point multiplication that takes advantage of the large order of the generator point and the specific characteristics of the secp256k1 curve.