Public keys and private keys: what they are and how they work

 

Public keys and private keys: what they are and how they work

www.binance.com
9 min
January 21, 2022
Without private and public keys, it will not be possible to transfer and receive cryptocurrency. They are also needed to ensure privacy and protect digital assets. They can be used from any device and any crypto wallet, without being tied to a location. 

What are public and private keys

To work with cryptocurrency, special wallet programs are used. To transfer and exchange digital money, you need to have two types of encryption keys:

  • private (closed);

  • public (open). 

Both keys are linked to the software wallet and can be imported into another wallet at the user's discretion. 

The coins themselves are in the form of unspent transaction data and are stored on a distributed ledger – the blockchain. It is to gain access to this registry that keys are needed. Without them, it will not be possible to transfer cryptocurrency to another user. That is, the main function of a public and private key is to ensure secure transactions.

The public key is the address (account) to which digital money is sent. It can be seen by other users, which is why it is called public. Using the public key, the encryption process is performed - creating a transaction. 

But the translation will not be approved by network administrators if it does not have a digital signature. To create such a signature, a private key is used. Without it, the user will not be able to send cryptocurrency to other wallets. For this reason, it is important to store it in a safe place. Preferably on a device that is not connected to the Internet.

If the private encryption key is lost, the wallet owner will not be able to access their funds. Even if someone sends him digital money, he will not be able to use it.

It is also important to protect the private key due to the high activity of scammers. If attackers recognize it, they will be able to transfer to themselves all the digital money stored in the wallet. But without the private key, the fraudster will not be able to gain access to the user’s cryptocurrency funds, even if he intercepts his traffic.

What private and public keys look like

Each of the keys takes the form of a unique set of characters, including letters and numbers. For example, you can take the encryption keys of the Bitcoin blockchain. It works based on the SHA-256 encryption algorithm, which generates a 256-bit number. To make it more convenient to work with such numbers, a combination consisting of 64 characters was created. This is the private key.

The Bitcoin network also uses other formats for creating private keys:

  • Bitcoin private key (in WIF format): 51 base58 characters, starting with “5”: 5JPeWYZx922hXi49Lg2RIPWLIqcmDGS9YegMNgANvx8cJa6kNK8

  • Short (compressed WIF): 52 base58 characters, starting with "K" or "L": KykxZQLSNPYVtYCsoqFGFnEqpRar997zihJgvfrPo8LapFrAtaea

  • B NINE format (64 characters [0-9A-F]): 4BBFF74CA25A2A00409DCB24EC0418E9A41F9B3B56216A183E0E9731F4589DC6

  • In Base64 format (44 characters): S7/3TKJaKgBAncsk7AQY6aQfmztWIWoY Pg6XMFRYncY=

Most cryptocurrency wallets that work with BTC use the WIF format. For normal transactions, a compressed key of 52 characters is sufficient. IN

wallets for storing Ethereum most often use a code of 64 characters. 

The public key for working with Bitcoin transactions can also have a different number of characters:

  • Bitcoin wallet address: 1DcEeFRGc4mfRLXWiVZySpmmXk7SsVLfMG

  • Short address: 1BSUkuwtdM7gkdy6W4Q954gNKWBgy4A19Q

  • Public key (130 characters [0-9A-F]): 04D7AS1212E4EEFE40C72B201E74AA3S57DEFD940ACESC3E1C76B75S77CD45FF9626065170497984F81C23BC8CBEEE64DBD84C9FE113F4A78930A0DA 7FA296B3F6D

  • Public key (short, 66 characters [0-9A-F]): 03D7A51212E4EEFE40C72B201E74AA3557DEFD940ACESC3E107687577CD45FF962 

The most common option is a short address. It can start with one or three.

Cryptocurrency encryption methods

Cryptography is the science of methods for maintaining data integrity and confidentiality; it appeared long before the creation of the first cryptocurrency. Achieving the goals of cryptography involves the use of different information security algorithms.

Symmetric encryption

It is the most popular and simplest way to encode transaction data. Messages are encrypted and decrypted using the same key. That is, symmetrical actions are performed. 

The recipient of the message is given a key with which he can decode the data.

Asymmetric encryption

With this method of data encoding, 2 keys are used:

  • open - needed to start the operation;

  • closed – for decrypting the message.

A private key allows you to put an electronic signature on a transaction, thereby confirming its authenticity. When validators see an electronically signed transaction arrive, they identify the transaction as the action of the rightful owner of the digital asset.

The logic here is simple: only the one who owns the funds in a separate wallet has the private key. This means that no one except this user can put an electronic signature, because this requires a key.

To avoid losing your private key, you need to write down a secret combination of characters in several notepads, which will be stored in a safe place, or save it on a special device. In this case, even if the system fails or electronic storage is damaged, the user will not lose access to his cryptocurrency reserves.

Hashing

This is another method of encoding user accounts that provides reliable encryption of transactions.

The essence of the method comes down to converting any information into a unique set of characters. It is used to encode large amounts of data. Information can be decrypted using a special hash value or digital fingerprint.

Principle of operation

The public key is used both to ensure confidentiality and to identify the user in the system. 

The application diagram is as follows:

  • The user who needs to transfer money gives his public key. 

  • The sender uses the resulting set of characters to encrypt the transaction - running it in secure mode.

  • The cryptocurrency is transferred to the specified cryptocurrency wallet address.

  • After receiving the transfer, the recipient uses the private key to decrypt the transaction. A secret set of characters provides access to a record in the blockchain, which contains information about the change of owner of a certain amount of crypto funds.

For a more clear example, imagine the following situation:

  • User A wants to send 5 bitcoins to user B.

  • User B provides the public key to User A.

  • User A creates a transaction using the public key and encrypts it using the private key.

  • User B sees that 5 BTC have been received in his wallet. To gain access to this money, he uses the private key of his wallet, that is, he decrypts the transaction, and can now use the coins. 

Without a private key, it is impossible to authorize a transfer, so only the owner of the secret character set has access to the received digital money.

Differences between private and public keys

Each key is a set of characters that is used to carry out a transaction. But their functions and characteristics differ.

Access level

The public key is not secret, it is available to everyone. If third-party users recognize the public character set of a cryptocurrency wallet, they will not be able to identify its owner. That is, the key, although public, contains a minimum of data.

The private key must be accessible only to the owner of the wallet. And it must not be disclosed to anyone. In other words, the one who owns the private key is the owner of the funds in the cryptocurrency account. 

Encryption process

If the public key encrypts the message, then the private key, on the contrary, decrypts it. 

These two character sets work in tandem with each other:

  • Without the public key, the sender will not be able to initiate the transaction. 

  • Without the private key, the recipient will not be able to authorize (decrypt) the transfer. 

Only the use of two keys when working with transactions allows you to ensure a high level of protection of funds. 

Changing private keys (sweeping)

When a user switches to a new wallet, they can transfer all funds from their old account. To carry out such a transaction, you will need a private key. Once the funds are transferred, the previous closed character set is no longer needed. The new wallet generates its own private key. 

This type of cleaning is called sweeping. This process is similar to moving jewelry from one safe to another. At the same time, the old safe is disposed of as unnecessary.

Performing a sweep can be useful in the following situations:

  • There is a risk of hacking. For example, a desktop wallet is installed on a PC, and a suspicious program was launched on the same computer. To avoid having your private key stolen, you should transfer all funds to another wallet.

  • There was a need to liquidate the old wallet. When a more convenient application is released, you can transfer funds to it, abandoning the outdated option.

  • The key was lost, but the user remembers the mnemonic phrase. We are talking about a special set of words, by entering which you can restore access to your accounts. These words are formed during the wallet registration process. All funds must be transferred because the lost private key may be found by someone. Theoretically, at the most unexpected moment, cryptocurrency can be stolen.

  • If you have to use a private key received from another person. When 2 users know the secret combination of symbols, there is always a risk of funds being stolen. It is better to immediately transfer the coins to another wallet, the private key of which will not be known to third parties.

When working with cryptocurrency, you should always monitor the current level of security of your wallet.

Importing keys

In addition to sweeping, you can import private keys. In this case, it is not the coins themselves that are transferred to the new wallet, but rather combinations of symbols - the private key.

Import is needed if the user registers in a new application and does not want to give up the old wallet. For transactions in each of them, one private key will be used. This will create 2 working wallets with one combination of symbols for decrypting transactions and creating a digital signature.

For example, a user may have a Bitcoin account that suits him. But it also needs a multi-currency wallet to work with different blockchains and cryptocurrencies. Then the user can install another wallet and copy the private key of his desktop wallet into it.

When importing, it is important to pay attention to protecting the private key on the new software.

How to properly store private keys

When choosing a storage method, you need to focus on the key task: to leave as few opportunities as possible for accessing the wallet via the network. Only after this condition is met does it make sense to pay attention to the functionality of the wallet.

Attackers can steal cryptocurrency by gaining access to the contents of the hard drive on a PC, as well as by hacking into an account on a cloud service or online platform. To prevent this from happening, you need to use the most reliable protection options. 

These include 3 ways to store private keys:

  • Hardware wallets. These devices are considered more secure than desktop wallets, mobile applications and online services. They look like a flash drive and contain data protection mechanisms. To make a transfer, the hardware wallet is connected to the PC. The transaction is sent from there and signed there. The encrypted message is then transmitted to the network. Modern hardware wallets are designed in such a way that even if a PC is hacked, fraudsters will not be able to gain access to the private key of a wallet connected to the computer.

  • Computer or smartphone. To store a significant amount of cryptocurrency, it makes sense to use a separate device. For security reasons, it must be permanently disconnected from the network and can only be turned on for transactions. 

  • Paper media. This could be a notepad or laminated piece of paper with the private key written down. You can make several copies so that if you lose one of them, you can maintain access to your digital money.

When using crypto wallets, you need to take care to create an extremely reliable private key storage. 

Some wallets themselves generate a private key, which you then just need to remember. There are special services that allow you to create your own secret set of random numbers and letters. They also make it possible to come up with a seed phrase, with the help of which access to the wallet is restored.

Коментарі

Популярні дописи з цього блогу

«Люди в блакитному» частина 2. Встановили агентів російських спецслужб у залі «Крокус».

«Вилаят Хорасан», подробности биографий подозреваемых и версии теракта

"Men in Blue" part 2 We have identified agents of the Russian secret services in the "Crocus" hall Our editorial staff continues to analyze photos and videos of the terrorist