Bitcoin uses asymmetric cryptography (or public key cryptography) to create a pair of keys (one public and the other private) that will allow access to Bitcoins.
Concretely a public key allows to encode a message and the private key to decode it. Anyone can therefore encode a message with the public key but only the owner can decode it (and thus prove his “identity”) thanks to the private key. You can get more information on Bitcoin Cash ABC core.
Public key cryptography is very useful for checking that someone is who they say they are. Take an example, John has created his key pair. He finds himself in a group of ten people who all know the public key and who all claim to be John. To know who John is, just use the public key to encode any message like “hello, how are you?” And send the message so coded to ten people. Only John, who will use his private key to decode your message, will be able to tell you what was the original message that sent to everyone and you will know that it is John.
During a transaction, the recipient’s public key is represented by his fingerprint: the Bitcoin address. It is at this address that Bitcoins are sent (the private key is used to generate the public key that can generate Bitcoin addresses). If the public key can receive money, the private key allows you to prove to the Bitcoin network that you are the owner of bitcoins and therefore you have the right to make a transaction on them. Specifically, if you want to send bitcoins to a person, you must create a transaction (ie a transfer of Bitcoins from one address to another) in which you indicate how many bitcoins you send and at which address. Then, you must “sign” this transaction with your private key. It’s a bit the same principle as a check: you put the recipient, the amount and you sign.
This may seem a bit heavy but most solutions on the market have a “wallet” ( wallet ) that stores your keys and mask this complexity.
Note: in the first part of the article, I talked about creating an “account” but in reality, when you generate your public key and your private key, you do not exist for the Bitcoin network. You only have a valid Bitcoin address that could be used to access existing transactions. Once you have made a deal with this address, you will “exist” but in the meantime, your address is just a valid key like billions of others. There is no notion of “account” in Bitcoin as you have with an account in a bank. You can get more information on Bitcoin Cash ABC core.
The private key.
As we have already seen, the private key is a number, chosen at random. It allows you to have control over all Bitcoins associated with the addresses corresponding to the private key.
The public key is computed from the private key using the Elliptic Curve Digital Signature Algorithm (ECDSA )
Note that it is not possible to calculate the private key from the public key. It only works in one way. To understand how this is possible, imagine that you throw a puck into a room. You launch it from a particular point, with a certain force and in a precise direction. By throwing it, from the same place, with the same force and in the same direction, you can find this point as many times as you want. However, a person entering the room and seeing the position of the puck, can not determine where you launched it.