The Bitcoin Introduction You've Been Missing

These slides are not intended to be an exhaustive intro to Bitcoin, but very simplify instead. They were written to give you an insight how Bitcoin works and which technologies power it.

As Wikipedia reports: "Bitcoin is a cryptocurrency and a payment system invented by an unidentified programmer, or group of programmers, under the name of Satoshi Nakamoto. The system is peer-to-peer and transactions take place between users directly, without an intermediary."

Let's look at the text from the previous slide more closely.

The word cryptocurrency refers to the fact Bitcoin utilizes cryptography to guarantee security and privacy.

The word peer-to-peer  tells us the system has a distributed nature, which means there is no organization has control over the system. There is no central server, storage, etc.  

The word intermediary refers back to the fact there is no company or organization who controls Bitcoin.

How does Bitcoin work?

The first thing you should know about Bitcoin is the ledger.

The ledger is a file that stores all the Bitcoin transactions ever made.

The ledger (or at least part of it) is stored on every peer.

Unlike a bank transaction database transaction in the ledger are anonymous, e.g. everything you know is the fact money were transferred from one address to another, but you don't know the persons behind these addresses.

As a consequence, bitcoins are a purely virtual currency. They don't exist as digital files or anything else.

If I say I have one bitcoin, it means someone has sent me one bitcoin and this fact is written in the ledger. The person who sent me this bitcoin received this bitcoin in the same way.

Let's say, Alice is the owner of a coffeeshop. She accepts bitcoins as a payment option.

A cup of coffee costs 1BTC (it's a very expensive coffeeshop!) and Bob is willing to buy one.

To make it possible for Bob to pay with bitcoins the ledger must contain the information about transactions that output to Bob's address and the sum of these outputs should be > 1BTC.

After Bob paid for the coffee, the information about the transaction for 1BTC that outputs to Alice's wallet will be added to the ledger.

Wallet? Transactions? I don't understand...

Let's start from the very beginning!

To start using Bitcoin you have to have a program called "wallet." There are a lot of implementations for different platforms.

The first time you run a wallet app, it will generate a pair of public and private keys.

The private key is what keeps your wallet and bitcoins safe. It's like a combination for a safe or your signature that authorizes transactions and indicates they are approved by you. Nobody should ever know your private key!

Now let's see how private and public keys are generated.

A private key is just a number between 

1\ and\ 2^{256}
1 and 22561\ and\ 2^{256}

Something like

cad19dffbfbacdfa54b3c6ca32f5c01f40fdf26d98b02dc17f40ded6cf7ed94a

In hexadecimal format.

A public key is generated from the private key using the elliptic curve defined in the secp256k1standard.

We won't explain how the elliptic curve cryptography works. The only thing you should know is that it is easy to obtain a public key from a private one using this cryptographic function, but almost impossible to do the opposite.

A public key should be available to all peers and is used for checking the fact that a message was signed by your public key. But it's not the only purpose of a public key...

A public key is used for generating a payment address, so the one that will be used in transactions.

A payment address is a hash of  your public key (actually, a hash of another hash, but it doesn't really matter right now.)

An address is what you typically see in your wallet app. If you want to send someone some bitcoins you must know this person's address.

You said transactions are anonymous, but it looks like after the first time I send/receive a payment at least one person knows which address is associated with me :(

No worries! Your wallet can (and typically does) generate a new address (as well as public and private keys) every time you send/receive money.

Let's look at the scheme one more time.

Private key

Public key = Elliptic curve blah-blah-blah(private key)

(One-time) address = Hash(Public key)

The scheme is irreversible:

Private key -> Public key -> Address

Now let's look closer at a transaction...

The transaction lifecycle:

  1. Creation.
  2. Broadcasting.
  3. Checking.
  4. Adding to a block of the blockchain (ledger).

Basically, a transaction consists of the following parts:

  1. Unspent transaction output (UTXO).
  2. Transaction input.
  3. Metainformation.

Once again, there are no accounts or balances in bitcoin, but UTXOs. If I have 5BTC, this means the sum of UTXOs associated with me is exactly 5BTC. I can then use these UTXOs for a transaction input.

Painting with a broad brush, metainformation consists of a receiver address, transaction hash, protocol version, signature, locking script, etc.

The last two are of interest to us.

Each transaction is signed by its owner's private key. Having the public key, one can check that the transaction was initiated by the owner.

A locking/unlocking script is a script in a Forth-like language embedded into the bitcoin platform. The script defines conditions that must be met in order to spend a transaction.

When a peer receives a transaction the following checking procedure is run:

  1. Using the public key of a sender, check the transaction signature.
  2. Check that the sum of sender's UTXOs >= the transaction input.

If and only if the conditions above are met, the transaction is propagated to the next node(s).

A consequence: a valid transaction is propagating with exponential speed, an invalid dies away on neighboring peers.

What happens after a transaction has been validated by the majority of peers?

As we've said before, a transaction is added to the ledger.

The ledger, in turn, can be treated as a distributed database, where information is stored as a tree.

In Bitcoin, ledger = blockchain.

Now let's answer the question – how did a transaction end up in the blockchain?

It's important to understand that transactions are not added to the ledger one-by-one. Instead, they are combined into blocks and blocks are added to the ledger (= blockchain.)

But who builds these blocks? Which rules does he follow? And who decides a block can be added to the blockchain?

There is a special group of users called "miners", who are busy with collecting valid transactions and building blocks from them.

Why do they do this? Because they are rewarded with bitcoins for their efforts.

Can I become a miner? Yes, but most likely you will not be able to mine a block without significant computational infrastructure.

The mining process consists of the following steps:

  1. Collecting valid transactions.
  2. Combining the transactions into a block with ~500 transactions inside.
  3. Solving hard a cryptographic problem against the block.
  4. Publishing the solution. 

Now let's discuss the problem miners are solving.

Let's say, a miner collected a bunch of valid transactions and combined them into a block.

After that, he solves the following problem: given a block and an integer number n. Find another integer number (called "nonce") such that: 

Y = sha256(block + nonce)
Y=sha256(block+nonce)Y = sha256(block + nonce)

and the first n bits of Y are equal to zero.

If n equals 1, this problem is very easy to solve. Every second number will do the trick.

At the moment n is ~20 in the bitcoin network and a new block is mined ~ every 10 minutes.

The system automatically defines n. The more miners, the larger the value of n.

Having the block and the nonce it's very easy to check that the nonce solves the problem.

After the majority of peers have validated a solution, a block is added to the blockchain and the miner receives a fee.

A lot of things were left uncovered in these slides but we hope they will be a good starting point.

Where to go next?

Mastering Bitcoin by Andreas M. Antonopoulos  – probably the best intro to Bitcoin at the time these slides were written.

Bitcoin for the Befuddled by Conrad Barski – another good intro.

Thank you!

Questions?

The Bitcoin Introduction You've Been Missing

By Andrey Lisin

The Bitcoin Introduction You've Been Missing

  • 2,143