DEV Community

Cover image for Blockchain and Bitcoin Explained in 6 Episodes — Bonus Episode
Christian Ahrweiler
Christian Ahrweiler

Posted on Originally published at Medium

Blockchain and Bitcoin Explained in 6 Episodes — Bonus Episode

Why Is Bitcoin Called a Cryptocurrency?Why Is Bitcoin Called a Cryptocurrency?Cryptography is usually associated with encryption. Data is transformed so that it can only be read again with the appropriate key.

Bitcoin, however, is not encrypted.

The Bitcoin blockchain is public. Anyone can read its blocks and transactions. The amounts transferred are generally visible as well.

Bitcoin Is Public but Pseudonymous

The Bitcoin blockchain makes it possible to trace which amounts a Bitcoin address has received and later spent.

However, the address does not contain a name. At first, the blockchain only shows the flow of payments between different addresses.

Publicly visible:
Bitcoin addresses
Amounts
Transactions
Timestamps

Not directly visible:
Names
People
Purpose of the paymentIf an address is linked to a person or company, its previous transactions can also be traced.

Bitcoin is therefore not anonymous but pseudonymous.

Although this data is public, Bitcoin uses several cryptographic methods. However, they are not used to encrypt transactions.

Why, then, is Bitcoin called a cryptocurrency?

Because cryptography is not only used to keep information secret. It can also make data verifiable, assign control, and confirm digital authorizations.

Bitcoin uses cryptographic methods in three essential places:

Cryptographic hash functions
Make data and computational work verifiable

Cryptographic key pairs
Control who can spend Bitcoin

Digital signatures
Provide verifiable authorization for transactionsLet us take a closer look at these three methods.

1. Cryptographic Hash Functions

In Episode 1, we calculated simplified hashes from short texts:

Text Hello Anna!
Hash 3dcdffText Hello Anne!
Hash 2dededThese short hashes were only used to make the principle easier to understand.

Bitcoin uses a real cryptographic hash function called SHA-256.

SHA stands for Secure Hash Algorithm. The number 256 describes the length of the result.

Internally, a SHA-256 hash always consists of 256 bits.

A bit can have one of two values:

0 or 1Written this way, a SHA-256 hash would be a sequence of 256 zeros and ones:

101101001011011010101100…This representation would be very long and difficult for people to read. Therefore, every four bits are combined into one character.

Four bits have 16 possible combinations:

0000
0001
0010
0011

1111The following characters are used to represent these 16 possibilities:

0 1 2 3 4 5 6 7 8 9 a b c d e fThis is called hexadecimal notation.

One character therefore replaces four bits:

4 bits = 1 characterIt follows that:

256 bits ÷ 4

64 charactersA complete SHA-256 hash is therefore normally displayed using 64 characters.

A real hash might look like this:

00000000000000000001a7f4c8b2…The dots are not part of the hash. They only indicate that we have shortened the value for this example.### What Makes SHA-256 Cryptographic?

SHA-256 has several important properties:

  • The same content always produces the same hash.
  • Even a small change produces a completely different hash.
  • The original content cannot be calculated from the hash. A hash function is therefore a one-way function.

Can Two Different Contents Have the Same Hash?

SHA-256 can map content of any size to a hash containing only 256 bits.

Because there are more possible contents than possible hashes, different contents producing the same hash must theoretically exist.

This is called a collision.

However, SHA-256 has such an unimaginably large number of possible hashes that an accidental collision is not expected in practice.

For verification purposes, we can therefore say:

Hashes are different:
The contents are different

Hashes are identical:
The contents are identical with extremely high probability### How Does Bitcoin Use SHA-256?

Bitcoin uses SHA-256 for purposes including its block hashes and Proof of Work.

Block data

  • previous hash
  • nonce ↓ SHA-256 ↓ Block hashDuring mining, the nonce is repeatedly changed and the hash recalculated until the result meets the current target.

Our 00 condition from Episode 1 was a simplified representation of this process.

Change nonce

Calculate SHA-256

Target met?Bitcoin actually applies SHA-256 twice when calculating a block hash. However, the basic principle remains the same.

SHA-256 does not make the data secret. The hash function makes the connection between blocks and the computational work performed verifiable.

2. Cryptographic Key Pairs

When a Bitcoin wallet is created, private and public keys are generated.

The private key begins as a very large random number.

Very large random number

Private keyThe wallet calculates the corresponding public key from the private key.

Private key

Cryptographic calculation

Public keyIn practice, this calculation only works in one direction.

The private key cannot be calculated from the public key.

The private key remains secret inside the wallet. The public key may be disclosed together with a transaction.

Does Bitcoin Use RSA?

RSA is one of the best-known methods of asymmetric cryptography. However, Bitcoin does not use RSA.

Bitcoin uses a method based on elliptic curves. The curve it uses is called secp256k1.

The mathematical details are not necessary for our explanation.

What matters is how the responsibilities are divided:

Private key: Remains secret
Public key: May be publicThe key pair does not encrypt Anna’s Bitcoin.

It ensures that only the wallet with the matching private key can create valid authorization to spend her Bitcoin.

3. Digital Signatures

Anna wants to authorize a Bitcoin transaction.

Her wallet uses the transaction and her private key to do this.

Transaction

  • private key ↓ Digital signatureThe transaction and the digital signature are sent to the Bitcoin network.

The private key never leaves Anna’s wallet.

A node uses the public key to verify the signature.

Transaction

  • digital signature
  • public key ↓ Signature valid or Signature invalidThe digital signature proves that the transaction was authorized using the matching private key.

It does not hide the contents of the transaction.

Why Can’t the Signature Be Copied?

The signature is calculated from the complete transaction.

If the recipient or amount is changed afterward, the signature no longer matches the transaction data.

A signature therefore cannot simply be copied and attached to another transaction.

Bitcoin originally used ECDSA for these signatures. Newer Taproot transactions can use Schnorr signatures.

Both methods perform the same basic task here: the private key creates a signature, which can then be verified using the public key.

Summary

Bitcoin is not encrypted. Its blockchain and the transactions it contains are publicly visible.

The term cryptocurrency refers to the cryptographic methods that make the system verifiable and control who can spend Bitcoin.

Bitcoin is called a cryptocurrency because these cryptographic methods make the system possible and secure it — not because its transactions are encrypted.

Top comments (0)