Virtual Coin Development topic (how to generate a fake currency address)

Source: Internet
Author: User
Tags hash

Blockchain Enthusiast (qq:53016353)

First of all, let us briefly talk about how the address of the cottage is calculated. The Shanzhai coin is based on the mathematical cryptography, in which the great God uses the elliptic encryption Algorithm (ECDSA) to generate the private key and the public key of the cottage currency. A public key can be computed by a private key, and the value of the public key is obtained by a series of digital signature operations. It is necessary to note that because the public key can calculate the address of the cottage, so we often confuse the public key and the address of the cottage, but they all refer to a concept. A fake currency address is just another form of public key.
It takes nine steps to get the fake currency address we use from the private key of the cottage. SHA256 encryption, RIPEMD160 encryption, and BASE58 encoding are used in the middle. Our final use of the private key and the cottage currency address is usually the result of BASE58 encoding. The entire process is shown in the following figure.






The first step is to randomly select a 32-byte number, a size between 1 ~ 0xFFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFE baae DCE6 AF48 a03b BFD2 5e8c D036 4141, as the private key.
18e14a7b6a307f426a94f8114701e7c8e774e7f9a47e2c2035db29a206321725


In the second step, the non-compressed public key corresponding to the private key is computed using the Elliptic Curve encryption Algorithm (ECDSA-SECP256K1). (Total 65 bytes, 1 byte 0x04, 32 bytes x-coordinate, 32-byte y-coordinate) the issue of public key compression, non-compression is described in this article.


0450863ad64a87ae8a2fe83c1af1a8403cb53f53e486d8511dad8a04887e5b
23522cd470243453a299fa9e77237716103abc11a1df38855ed6f2ee187e9c582ba6


Step three, calculate the SHA-256 hash of the public key
600ffe422b4e00731a59557a5cca46cc183944191006324a447bdb2d98d4b408


Fourth step, take the previous result, calculate the RIPEMD-160 hash value
010966776006953d5567439e5e39f86a0d273bee


Fifth step, take the previous step result, add the address version number (the main net version number "0x00")
00010966776006953d5567439e5e39f86a0d273bee


Sixth step, take the previous result, calculate the SHA-256 hash value
445c7a8007a93d8733188288bb320a8fe2debd2ae1b47f0f50bc10bae845c094


Seventh step, take the previous result, and then calculate the SHA-256 hash (haha)
D61967f63c7dd183914a4ae452c9f6ad5d462ce3d277798075b107615c1a8a30


Eighth step, take the first 4 bytes of the previous result (8-bit hex)
D61967f6


The Nineth step, add the 4 bytes to the fifth step after the result, as a check (this is the 16 binary form of the address of the counterfeit currency).
00010966776006953d5567439e5e39f86a0d273beed61967f6


Tenth step, transform the address with base58 notation (this is the most common form of the cottage currency address).
16uwll9risc3qfpqbuvkofhmbq7wmtjvm


(Note: Some numbers start with "0x", meaning that this number is in hexadecimal notation.) "0x" itself does not have any meaning, it is the C language passed down, the conventional wording, such as 0xA is the decimal 10. In addition, 1 bytes = 8 bits binary = 2 bit hexadecimal).


We often say that the public key of the cottage currency is the result of the second step in the figure. And HASH160 refers to the fourth step RIPEMD160 signature produced results, because RIPEMD is also a hash algorithm, so collectively referred to as HASH160. And our usual cottage-currency address is the result of BASE58 encoding.


Shanzhai clients and wallets also accept a variety of cottage-currency address formats, commonly used in formats such as BASE58 format, WIF compression format, 130-bit and 66-bit public key. Go to Buck's Wallet tool click the Wallet Details query page, as shown below, the red box in the 130-bit string is the original public key of the ECDSA, the following is the public key compressed into 66-bit format, The above two are our commonly used cottage currency BASE58 address format and the cottage currency address wif (Wallet import format) compression format.




In fact, the address of various formats are basically universal, after learning the relevant knowledge, we will have a more in-depth understanding of the Shanzhai system.

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.