Bitcoin, along with other cryptocurrencies, is based on open-source cryptography - a system that uses key pairs: public (publicly known and necessary for identification) and private (kept secret and used for authentication and encryption).
Each time when transferring coins, the user actually sends the encrypted version to the blockchain of the so-called “public key”. The public key is public, and therefore open to visibility to any member of the network. Users exchange it with each other if it is necessary to make a payment (transfer information). This key is mathematically associated with a private key, which acts as a decoder of information of the transmitted message.
Public and private keys consist of randomly selected sets of alphanumeric characters that form cryptographically generated data strings for the secure exchange of coins between two parties.
But since this set is very large, it is usually presented in a separate wallet import format (WIF):
The private key is the longer of the two and is used to generate the signature of the user-submitted transaction. This signature is used to confirm transaction processing, eliminating the possibility of making changes after it is submitted.
Basically, all wallets generate and store private keys by default. When a user sends coins from a wallet, the software signs the transaction with his private key (without actual disclosure), thus “informing” the network that this user has the authority to transfer funds.
It is worth remembering that a private key is access to your funds, therefore, for the purpose of security, it must remain secret from third parties!
The private key is used to mathematically derive the public key, which (together with information about the network and the checksum) is then converted using a hash function to an address accessible to other users. The user receives coins from the sender, which is the result of hashing the public key.
You probably have a question: if the public key is obtained from the private key, can anyone create a reverse key generator in order to calculate the private key and steal the funds?
Cryptocurrencies solve this problem by applying a complex mathematical algorithm. Despite the fact that the system makes it easy to generate public keys from private keys, it is almost impossible to “cancel” the algorithm to achieve the opposite result.
The reverse process execution mechanism is so complex that even the most powerful computer in the world will need more than 4,000,000,000,000,000,000,000,000,000,000 years to realize this calculation.
Nowadays, popular cryptocurrency wallets used on exchanges (Coinbase), hardware wallets (Trezor) and browser extensions (MetaMask) abstract users from the process of creating public and private keys, which makes it easy to send and receive cryptocurrencies.
— How Bitcoin Halving Can Change Crypto Market
— Find Out About Demo Crypto Trading
— What You Should Know About 2FA
As we see the security of this system is much higher than it might seem at first glance. Such protection is achieved due to the fact that:
Many cryptocurrency owners do not pay much attention to protecting their private keys, and mainly rely on a password that encrypts them. But do not forget that a large proportion of malware is created specifically for the theft of private keys, so it is not recommended to store them digitally.
For the safe storage of cryptographic keys, the most appropriate option is to write a QR code on paper, because in this case the user does not interact with the Internet, and therefore excludes the option of a hacker attack.
Do not forget, only you are responsible for your funds, so be careful and vigilant!