The finale piece of the puzzle to fully understand the mechanics’ underlying Bitcoin, is digital signatures, which are based on public-key cryptography. The digital signatures provide an easy way for nodes to identify accounts and authorize transactions.
Public Keys and Private Keys
When you create a bitcoin wallet to store your virtual coins, you are assigned two keys – a public key and a private key that are mathematically connected. Technically, the wallet address is created by double-hashing the public key, and the public key is generated from the private key via a complex multiplication known as elliptic curve digital signature algorithm. The algorithm goes one-way, which means there is no way of reverse-engineering the private key based on the public key or the wallet.
In the Bitcoin blockchain, your key pairs are your identity. You can think of the public key as your username in the network, while your private key is your password. You are free to create as many key pairs as you want, just like you can create multiple e-mail addresses. Bitcoin uses 256-bit public keys, where an unimaginably large pool of numbers can be generated. The likelihood of two public keys colliding with each other are almost zero. For that to happen, you would need to register 2128 keys, which would be one key for every carbon atom in every human that has ever existed .
The private key creates the digital signature. It should be kept secret at all times, backed up and protected from accidental loss. If the private key is misused by a third party or lost, the funds cannot be recovered and will be lost forever.
A private key is a randomly generated number in hexadecimal format (256 binary digits shown as 64 hexadecimal digits) and could look like this:
The corresponding public key can be used by anyone in the network to verify that a transaction was in fact signed with the sender’s private key. The two keys are related in such a way that the private key can encrypt a transaction message that can only be decrypted by the public key. A public key contains a string of letters and numbers, from 26 to 34 characters and could look like this :
Sending and Verifying a Digital Signature Bitcoin Blockchain
A digital signature is the equivalent to a handwritten signature on a document, as it is used to authorize the sender and prove his or hers intent to make a transaction. A digital signature is virtually impossible to forge. In the following diagram, I have tried to outline to the best of my knowledge how digital signatures are used in the Bitcoin blockchain to carry out transactions .
Let’s say I want to send 1 bitcoin to a friend. Practically, the transaction consists of inputs and outputs. The inputs are data from one or more previous transactions, while the outputs are the amount of bitcoin I want to send, and possibly the return of any change to the sender. By sending my friend 1 bitcoin, I am actually sending him the transaction history of the bitcoin, as the output is made from previous inputs.
The transaction data is hashed through SHA-256 to create a unique hash value. The hash value is then combined with my private key to create a unique digital signature of the transaction. My friend can now be ensured that the data he receives has not been tampered with and that it must have come from me. I send him the digital signature of the transaction, the relevant transaction data, and my public key, so the nodes on the network can authenticate that I am the sender and that the data has not been altered.
As already mentioned, my private key is mathematically linked to my public key, which means that anyone can verify that the digital signature was made with my private key by utilizing my public key. The first step of the verification process is to hash the transaction data through SHA-256. The second step is to decrypt the digital signature with my public key and then compare the two hash values to see if they match. If they are identical, the nodes can confirm that the transaction was in fact signed with my private key. If someone were able to alter the transaction in the network, the nodes would be able to see that the hash value of the transaction data is inconsistent with my digital signature when decrypted with my public key.
 https://en.wikipedia.org/wiki/Elliptic_Curve_Digital_Signature_Algorithm (opened 01-09-2020).
 https://nakamoto.com/public-key-cryptography/ (opened 01-09-2020)
 Andreas M. Antonopoulos (2010), Mastering Bitcoin – Unlocking Cryptocurrencies Potential, pg. 63
 https://spectrocoin.com/en/faqs/bitcoins/what-is-a-public-key.html (09-09-2020).
 Christopher Mann and Daniel Loebenberger (2014), Two-Factor Authentication for the Bitcoin Protocol, pg. 3.
  Satoshi Nakamoti (2008), Bitcoin: A Peer-to-Peer Electronic Cash System, pg. 5.