Virtual Currency development topics (what is a virtual currency private key, public key, and address)

Source: Internet
Author: User

Blockchain Enthusiast (qq:53016353)


This is the three words that often appear in the virtual currency, so what do they mean? What kind of relationship do they have?

1

First, say a private key, such as a string:

5KYZDUEO39Z3FPRTUX2QBBWGNNP5ZTD7YYR2SC1J299SBCNWJSS, is a private key. Any application that correctly supports the virtual currency protocol can recognize the string as a private key, convert it to a public key, convert it to an address, and, if there is a virtual currency on the corresponding address, use the private key to spend the virtual currency. The public key and address generation all depend on the private key, so the private key is the most important in the virtual money world, with the private key can generate the public key and address, you can spend the corresponding address above the virtual currency. The way the private key spends virtual money is to sign (encrypt) the unused transactions owned by the private key.

The private key is essentially a 32 byte array, 1 byte equals 8 bit binary, one binary has only two possibilities 0 or 1, so the total number of private keys is 2^ (8*32) =2^256, this number has exceeded the total number of atoms in the universe, want to traverse all the private key, It is impossible to exhaust the energy of the whole sun. What we call the virtual currency private key is the cryptography above security, not impossible to duplicate the private key, but it is impossible to traverse all private keys, or other way to find the private key above the virtual currency, so the private key is cryptography safe.

The total number of private keys is large, but the private key generation is to rely on random, do not rely on random will greatly reduce the probability of generating a private key space, cryptography above the security of random refers to the random is not predictable, random results are not traversed. Cryptography safe randomly generated private keys can be used to store virtual currency, if random insecure, you can get the private key will be the same as others, then your virtual currency can be lost.

32 byte arrays are made up of 256 0 or 1, and if displayed, not only is the recognition rate too bad, but it is too long. So the private key will be converted to the look above, the above private key is a 32 byte array to do a Base58 conversion, Base58 is used in bitcoin for the use of a unique encoding method, mainly used to generate Bitcoin wallet address and private key. Compared to BASE64,BASE58 does not use the number "0", the letter Capital "O", the letter Capital "I", and the letter lowercase "l", as well as "+" and "/" symbol. Mainly for the naked eye easy to identify, in the input is not easy to hit the wrong, but I prefer to use two-dimensional code to scan the private key, after all, the above paragraph of the irregular string input is still very laborious.

We see the private key in addition to the beginning of 5, there are "L" and "K" the private key, why this situation occurs. What does 5,l,k represent? The content of this section is about the public key.

The public key is generated by the private key, generated by an elliptic curve (Ecpoint), and a private key is transformed into an array of 65 bytes after the Elliptic curve transformation. In general, we'll see a public key like this: 04A34B99F22C790C4E36B2B3C2C35A36DB06226E41C692FC82B8B56AC1C540C5BD5B8DEC5235A0FA8722476C7709C02559E3AA73AA 03918ba2d492eea75abea235, the public key is generally the byte array is after the hex (16 binary) processing after the display, different from the private key Base58, the public key is used to unlock the private key signature data, after using the private key signature transaction, will send their own public key together , the private key signature data can be decrypted with public key, after sending the public key to verify the correctness of the signature of the private key (can be solved), the private key and the public key is paired, a private key signature data, only the corresponding public key can be solved, and the address is generated from the public key, This allows you to verify that the transaction you are spending is not part of this address.

As for why there is a 5 start or l,k beginning of the private key, the problem is on the public key, the example of the private key contains not only 32 byte array of information, or the private key version of the information and public key is compressed information, the early virtual currency developers did not know that the generated public key can be compressed, The compressed public key has only 33 bytes, and the uncompressed public key has 65 bytes. The compressed public key is more meaningful to the virtual currency, because the virtual currency is a centralized, peer-to-coinbase crypto currency, each node will have a complete transaction record, each transaction will send a public key, in addition to the mining-resulting virtual currency, and the public key is supported in compressed format, and the transaction data will be reduced by 32 bytes. , which is very meaningful for the entire virtual money network, the entire virtual money network will be reduced by a lot of data.

When the private key is BASE58 encoded, the private key supporting the uncompressed public key is actually a 33-bit byte array, the first bit holds the version information, the current value is 128. The private key that supports compressing the public key is 34 bits, the same is the first bit is the version information, its value is also 128, and the extra one is the last byte is used to store whether the information is compressed, 1 is the public key to support the compression format, 5 of the private key is not supported in the compressed format of the private key, Both L and K begin with a private key that supports the compressed format.

Whether the public key is compressed in addition to the display of the private key, or the address has an impact. Address is generated by the public key, see the address is BASE58 encoding processing, address generation more complex, said address before have to say hash160, address is generated by the public key, but the public key generated address will be a hash160.

The generated process is to first SHA256 the public key, and then RIPEMD160 the resulting result, and then take 20 byte array from the result, the resulting array is the hash160, For example: 9A1C78A507689F6F54B847AD1CEF1E614EE23F1E, in front of this 20-bit byte array plus a byte, is the address of version information (currently 0) to get a 21-bit byte array, The Base58 conversion is the way we see the address, meaning that hash160 and the address can be converted to each other.

A private key can have a compressed public key, and an uncompressed public key, each public key will generate an address, the above private key will have two addresses: 1HZWKJKEAOZFTSAJXDW6AKKXP45AGDIEZN (the public key is not compressed), 1F3SAM6ZTWLAUNJ7D38PGFXTP3RVEVTSBV (compressed public key), these two addresses are the address of this private key, the money above each address can be spent with this private key. However, most applications today are private keys that support the compressed format.

This will give you a simple introduction of a private key, public key and address.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.