Virtual Coin Development topic (the relationship between the private key, public key, wallet address)

Source: Internet
Author: User
Tags hash asymmetric encryption

Blockchain Enthusiast (qq:53016353)

Cottage currency trading involves a lot of cryptographic knowledge: public keys, private keys, hashes, symmetric encryption, asymmetric encryption, signatures, and so on. Then which is the need for users to seriously keep the external leakage, those are required to open the user. Start with the creation of the wallet address. Wallet Address generation


Img
1. First use the random number generator to generate a "private key". In general, this is a 256bits number, with this number can be in the corresponding "wallet address" of the cottage currency operation, so it must be safely saved up.
2. The "Private key" has been processed by the SECP256K1 algorithm to generate a "public key". SECP256K1 is an elliptic curve algorithm, which can be calculated as a "public key" when a known "private key" is known, but the "public key" cannot be computed in reverse. This is the basis of the algorithm to protect the security of counterfeit coins.
3. Like SHA256, RIPEMD160 is also a hash algorithm, which can be computed by "public key" to obtain a "public key hash", which in turn is not feasible.
4. Connect the address version number of a byte to the "public key Hash" header (the byte is "0" for the PubKey address of the Shanzhai network), and then two SHA256 the first 4 bytes of the result as a checksum of the "public key hash" at its tail.
5. Use BASE58 to encode the previous step (custom version of the cottage coin) and get the "wallet address".
For example, 1a1zp1ep5qgefi2dmptftl5slmv7divfna
Relationship between "private key" "Public key" "Wallet address"


In the above five steps, only the "BASE58 code" has the corresponding reversible algorithm ("BASE58 decoding"), the other algorithms are irreversible, so the relationship between the data can be expressed as:
Img
can see:
The "private key" can be used to get all the values in the above calculation process.
The "Public key hash" and "wallet address" can be converted by mutual inverse, so they are equivalent.
To sign a transaction using the private key


The transfer of the counterfeit coin wallet is achieved through trading (Transaction). The transaction data is generated by the owner of the "private key" that is transferred out of the wallet, that is, with a "private key" to spend the wallet's cottage currency balance. The process of generating the transaction is as follows:
Img
1. The original data of the transaction includes "transfer Amount" and "transferred to the wallet address", but only these are not enough because it is not possible to prove the right of the originator of the transaction to use the "Transfer out wallet address" balance. Therefore, the original data needs to be signed with a "private key".
2. Generate the "Turn out wallet public key", which is the same as the 2nd step of generating the "wallet address".
3. The "Transfer out signature" and "Transfer out public key" are added to the original transaction data, and formal transaction data is generated so that it can be broadcast to the Shanzhai Network for transfer.
Verifying a signature using the public key


Img
Once the transaction data is broadcast to the Shanzhai network, the node examines the transaction data, including the verification of the signature. If the check is correct, then the balance is successfully transferred from the "transfer wallet" to the "transfer wallet".
Summary


If a "wallet address" never sends a balance to another "wallet address", then its "public key" is not exposed to the Shanzhai network. The Public Key generation algorithm (SECP256K1) is irreversible, and even if the "public key" is exposed, it is difficult to influence the security of the "private key" (difficult to depend on the "private Key" generation algorithm).
The "private key" is used to generate "public key" and "wallet address", also used to sign the transaction. Having a "private key" means having all the power to operate on the balance of the purse. Therefore, the protection of the "private key" is the most basic and most important function of all the Shanzhai wallet applications.

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.