They generate numbers based on a seed, and by default, the seed is the current time. You see, normal RNG libraries are not intended for cryptography, as they are not very secure. Python even provides a cute way of generating just enough bits: import random So, how do we generate a 32-byte integer? The first thing that comes to mind is to just use an RNG library in your language of choice. The order of secp256k1 is FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141, which is pretty big: almost any 32-byte number will be smaller than it. Because we use ECDSA, the key should be positive and should be less than the order of the curve. There is an additional requirement for the private key. So, to put it another way, we need 32 bytes of data to feed to this curve algorithm. Now, this curve has an order of 256 bits, takes 256 bits as input, and outputs 256-bit integers. More specifically, it uses one particular curve called secp256k1. Why exactly 32 bytes? Great question! You see, to create a public key from a private one, Bitcoin uses the ECDSA, or Elliptic Curve Digital Signature Algorithm. The same private key, written in different formats. For our purposes, we will use a 64 character long hex string. It can be a binary string, Base64 string, a WIF key, mnemonic phrase, or finally, a hex string. It can be a string of 256 ones and zeros (32 * 8 = 256) or 100 dice rolls. Now, there are many ways to record these bytes.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |