If you are already learning about blockchain or have already started creating wallets and transferring money, you must have heard of these concepts: public key, private key, wallet, address, mnemonic, keystore. If you want to be a qualified investor, then you must understand these concepts. What is the relationship between them? Here are a few concepts and an example to explain for everyone.
concept
First, the wallet
The wallet in the blockchain is different from the wallet we use in our daily life. Our usual wallet is for money; in the blockchain, our assets are various generations like btc and eth. The currency or token, the wallet in the blockchain is not used to install these assets, but as a key management tool. Speaking of this, some people may disagree. I obviously saw that there are various tokens in my wallet. How can I say that it is not used to load money? Then I have to tell you that your token is in the secret key. Even if your wallet can't be used, as long as you know your key, you can continue to manage your assets elsewhere. According to the private key, the public key can be calculated, and the address can be calculated indirectly. When you create a wallet, you will generate a pair of public and private keys. The public key gets your wallet address after a certain algorithm. This address is the address that someone else gives you when you trade. The private key is the digital signature of the transaction when you trade, thus proving that you have the output of the transaction. right. So the address can be made public and can be seen by anyone; the private key is never for others to see, and who owns the private key, who has control over the wallet assets.
Second, the address
In the process of digital currency trading, as long as you know the other party's wallet address, you can transfer money to the other party. Everyone knows that after creating a wallet, a wallet address will be generated. How does this address come from? When creating a wallet, the system uses the Ellipse Encryption Algorithm (ECDSA) to generate the private and public keys. Based on the principle of ellipse encryption, the public key can be calculated by the private key, and then the public key is digitally signed and hashed to obtain the wallet address. It is now clear that the address is not equal to the public key, or that the address is another form of public key. With this wallet address you can use it to receive someone else's currency.
Third, the public key
The public key is generated by the private key through the elliptic curve encryption algorithm. After the transformation, it is an array of 65 bytes, which is usually displayed by hexadecimal processing. Early Bitcoin developers didn't know that they could compress the public key, and the compressed public key had 33 byte arrays. With the private key, you can calculate the public key. The public key cannot calculate the private key, so the digital cryptocurrency has a high security.
Fourth, the private key
The private key is essentially a random number containing 64 bits:
For example: 6KYZdSDo39z3GDrtuX2QcowGnNP5zTd7yfr2SC1j239sBCnWjee.
The private key is randomly generated. The random number may be 256 times of 2. This number can be felt by everyone. It is almost impossible to traverse the possible private key one by one in a "brute force" manner. Even with the most advanced quantum computers available today.
The private key can only be generated by the wallet itself. When creating a wallet, enter the password and you can export the private key. Note: A wallet address has only one private key. Who owns the private key, who owns the control of these digital currencies, the private key cannot be forgotten, must be backed up, remember!
Five, mnemonic
In the process of creating a wallet, a mnemonic is generated and will be backed up. The mnemonic word is generally composed of 12 words, and the two words are separated by a space. These words are all from a fixed thesaurus. It is obtained by the private key according to a certain algorithm, so the conversion between the private key and the mnemonic is interoperable, and the mnemonic is actually another manifestation of the private key. The mnemonic is best written down on paper. Never use a networked thing to save it. The function of the mnemonic is equivalent to the private key. If someone gets your mnemonic, it can be used to import the wallet, then enter the wallet and have control of the wallet.
Six, KeyStore
KeyStore looks like a string in JSON format and is usually stored as a file. The essence of Keystore is the encrypted private key. Keystore must be used with your wallet password to be valid.
The following examples of bank card transfer explain the above concepts to help you better understand
For example, Bao Erye, who is now famous in the currency circle, is already wealth free because of investing in digital currency. One day, Bao Erye saw that I was his diehard powder. I wanted to transfer money to me with a bank card. Bao Erye had a VIP gold card, and I had a normal card. Both of us have our own card number and password. And the password is only known to me. Now I will provide my card number (address) to Bao Erye. Bao Erye uses his gold card, enters my address, gives me a sum of money, I enter my password. Just on the ATM, I saw a transfer from Bao Erye. In this process, the card number is the address; Bao Erye enters my card number to transfer to me is to use my public key to encrypt; Bao Erye enters his password and transfer amount, is to use his private key to carry out the transaction The digital signature indicates that he has control over the account, and in this way, it will leave a record on the blockchain, which can be checked later; I enter my password on the ATM and check the account, which is to use My private key decrypted the details of the transaction; I can see the address of Bao Erye, so I am equivalent to using Bao's public key to decrypt the money from Bao Erye.