<< Go back to Posts

DRAFT - 30 minutes to learn everything about Blockchain

At least all the important details



Introduction

In this article, we try to move one definition after another, so you can understand progressively more concepts.

Vocabulary

Hash Function

Function transforming any input into a has, which is a string that looks random, and of finite size.

Text input MD5 Hash
Dog c935d187f0b998ef720390f85014ed1e
dog 06d80eb0c50b49a509b49f2424e8c805
dogs d28d2d3560fa76f0dbb1a452f8c38169

Several properties:

  • The function is deterministic, the same input always leads to the same output (try it there)
  • The output size does not depend on the input size. A function as a predefined output length
  • Output format is often a hexadecimal string, so the binary word is representable using ascii characters ( 0123456789qbcdef)
  • One simple change in the input make a HIGH difference in the output hash
  • There are several “reference” hash function. MD5 is very well known to check if a downloaded software is correct, SHA-256 for Bitcoin, Ethereum use Keccak256

Decentralized network

A decentralized network is a network which is not owned by a single entity. In the philosophy, it is open to anyone who want to respect the rules.

Blockchain

Blockchain is the name of the most famous network. The idea is to store transaction into “blocks”. A block contain a thousand of transaction. The history is linear, there is a single last block, there is a common history for all. This helps checking the balance of the accounts.

Participants & Users

In the network, we have two kind of people:

  • Participants, also called the Miners: These are people maintaining the network, nodes, trying to fullfill the protocol. They are incentived by the protocol which reward them financially
  • End Users: These are people just making transactions on the network. They send their transactions they wish to do to participant. They are not rewarded in any ways.

Proof of Work

In a decentralized network, you have no control on the participants joining. Some will play nice, some not. You need to ensure that people will act as expected, to guarantee the stability. The first thing is avoiding a fork. We want a single block history, there should not be branching, there should not be a choice of the branch to select.

To do that, there is the “game” of the proof of work, which is the choice of Bitcoin. A participant of the network can only publish a block if it is able to find a solution to the following problem:

  • You are given a hash function (same for all the network)
  • You are given the previous hash of the last block

Your goal is to find a string such as hash_x = SHA256(last_hast + guess_string) has at least d leading zeros (the difficulty).

This task is difficult, so participant needs to invest a lot of effort to get a solution. This will prevent people from publishing blocks too frequently.

Hash Rate

The number of hash computed by seconds. This could be a spec for a device (GPU, ASIC), or the overall number of hash computed by all the Bitcoin participants.

How to compute the hash rate pf the network ? Bitcoin participants are not sending their electricity bill.

We can estimate it given the current difficulty of getting a valid proof.

At the date of writting, the hash rate was 620 Exa Hash/sec (10^18). The difficulty is made in such a way a solution is found every 10 minutes. So, if we want to find the number of leading zeros in the solution, this is easy:

difficulty = log2(hash rate x 60 x 10)

difficulty = log2(620 x 10^18 x 60 x 10) = 78 bits

78 bits corresponds to 19 zeros in hexadecimals. One recent solution was:

0000000000000000000256491fdd7cc579979b0b3f2397a73aac597ffebe8237

Proof of X

Bitcoin was the first “decentralized network”. Proof of work has its drawbacks: you need a lot of computing power to win a block, so there is an arm-race, leading to a high power demand.

Other networks have emerged after that, with alternative consensus mechanisms.

But in most, the more money you have, the better as some point, as you are able to control more of the fundamentals of the network.

Proof-of-stake: The more you own (and invest) in the network, the more power you have. This is equivalent to traditional exchanges where when you have shares in a company, you get coupons every X and you have a right to vote. This system is very similar to stocks and shares, where the more you own, the more you get as a reward, and the more power you have to vote changes in the network

Proof-of-authority:

Proof-of-space

Proof-of-location:

Proof-of-ownership:

MemPool

End-user, real people doing transaction, needs to advertize the full network.

The MemPool is a kind of “decentralized” database storing the transaction that need to be processed. This is a kind of waiting list.

When building a block, miners take a look at it. They are incentived to take the one with the highest transaction fees (as miner collect them in their block).

Normally, when a transaction arrive in a mempool, we cannot rollback. Nevertheless, the beneficiaries will only receive the funds after the transaction is officially processed.

Fiat Money

Traditional currencies like Euro, Dollar, Yen, etc.

They are issued by a government and not backed by a physical counterparty like gold or silver.

On Ramp / Off Ramp

Money conversion direction:

  • On-ramp: Conversion of Fiat money to crypto
  • Off-ramp: conversion of crypto into fiat

Wallet

Bitcoins are not stored in your pockets, as your saving are not stored under your bed.

A wallet is the place where the keys to your digital currency are stored. These keys help you to forge transactions. A wallet is just a secured software, and can handle multiple cryptocurrency at a time. Private keys for each network are recognizable, they often have an header.

https://strm.sh/posts/bitcoin-address-generation-in-pure-python/

TODO: illustration

Keys

There are several keys in a wallet

  • Private key: This is the main key you should not share.
  • Public key: The public key is automatically derived from the private key. This one needs to be shared with people with whom you want to do some transaction, for instance to receive some funds, you need to send them your public key.
  • Address: Addresses are like bank account. You can have several accounts under your name.

Hot Wallet

A hot wallet is like your bank: You log in with a password, they offer recovery methods. They (the entity managing the wallet) ensure the security of your private keys

Cold Wallet

A cold wallet is a private key stored by your own means, either on a file in a USB stick, either on a paper, or in a physical devide like Ledger.

YOU are responsible of the storage and the security.

Custodial

A wallet is custodial if you do not manage the keys of your wallet. Most of the time, when you use an exchange, you do not have access to the private key, and everything is accessible thanks to your email and main password.

A non-custodial wallet is a wallet that you manage yourself.

This is similar to hot and cold at some point, but not completely. You can have your wallet online, but completely encrypted. You will need to manage the access key yourself.


Layers

With Bitcoin, we quickly discover that security has a price, which is network capacity. Because of the proof of work, we are limited in the number of transactions. This is why some other blockchains appeared, with other consensus mecanisms. Yet, there is still some limitation or other drawbacks. And Bitcoin has not been left, so people search for a way to improve network capacity. Here comes the layers.

Layer 1 is the “real” / low level blockchain with its “small” capacity but all the garantees.

Layer 2 is a set of protocols / other mecanisms working on top of layer 1, where transactions are done “off-chain”, i.e., they are not recorded in the blockchain’s blocks.

Layer 3 tries to increase the capacity of level 2 using other mechanisms.

Today (2024), we are talking about this 3 layers architecture. Nevertheless, layers 3 do not exists at all, and layer 2 are experimental / in progress but not democratized. The most known layer 2 is the Lightning network 1, which allows doing bitcoin transactions thanks to bitcoin smartcontract and peer-to-peer network.

Numbers

It is good to have big numbers in mind

  • 31th of october 2008: Bitcoin paper
  • 3rd of january 2009: First bitcoin block
  • 864,877 bitcoin blocks (9th of October 2024)
  • Size of a block 1.5 MByte (on average)
  • Blockchain size: 600GB
  • Number of transaction in a block: 6400 (when 1.4MB)

  • 0000000000000000000256491fdd7cc579979b0b3f2397a73aac597ffebe8237
  • Current difficulty: 92 049 594 548 485,47
  • Evaluation of difficulty: every 2016 blocks
  • Hash Rate: 620 EH (Giga: 10^9, Tera: 10^12, Peta: 10^15, Exa: 10^18)

Exchange

Exchanges are marketplaces where you can exchange cryptocurrency against something. In the regulated ones, you can buy crypto using fiat money or to sell them. You can also exchange one crypto currency (say ethereum) against another (for instance dodge coin). In some specialized exchanges, you can buy NFT

In decentralized exchanges, you cannot use fiat money, but

Decentralized exchange

Unless you are able to mine cryptocurrency, you ca

Memotechnic

Private keys or wallet keys are a list of bits. They can be read thanks to hexadecimal formal (you look at 4 bits at a time and convert it as a alphanum charecter in 0123456789abcdef). Nevertheless, this is quite difficult to remember, or to copy (in a paper notebook for instance).

In BIP39 has been introduced a way to convert the private keys into a list of human readable words. BIP39 wordlist Each word represent 11 bits of the key. This words are common, so their writing cannot be mistaken, and they have been choosen such as all four first letters are different.

In Bitcoin, a private key is 256 bits, so you would need 24 words to represent it.

TODO

## Hierarchical Deterministic Wallet

Rather than having many private keys to remember, another option is to have a master key and to derive all private key from it. TODO

Memotechnic converter

KYC

For Know Your Customer.

The idea of bitcoin was to do transaction without sharing your identity. Anyone can create a cold wallet at no cost. However, it is empty. To get some coins, you need to exchange fiat money (€, $, £, …) against tokens/coins. To do that, you need to provide your identity (ID card).


BIP

Bitcoin Improvement Proposal

List of proposal (some are draft, other accepted or rejected) to improve the Bitcoin protocol.

As it exist for “normals” protocols with “RFC: Request for Comment”.

  • BIP39: List of 2048 words (one word represent 11 bits) which can represent your private key passphrase to get your private key / wallet unlocked. Words should be short and common. The four first letters are different for all words. From the wallet private key, you can issue several public key for different cryptocurrency. For a wallet: 12 words. Therefore, the key is 11 x 12 = 132 bits long

ERC

Ethereum Request for Comment

Same as BIP, but for Ethereum.

The most known are:

  • ERC20 for alternative currency (identical coin that can be exchanged in a quantity).
  • ERC721 for NFT (unique object)

# Smart Contract

This is a piece of code which can be executed during a blockchain transaction.

Within a blockchain, it is useless to run for instance a code doing image segmentation as there is no value. As a blockchain is a set of addresses and currency with verifiable properties, the codes are “contract” which gives credentials / prove the ownership of something to someone.

NFT

Non-Fongible Tokens.2

This is a particular type of “digital object” created thanks to smartcontract.

Interaction are done with the smartcontract.

To a digital document (image, text, or anything else) is given a signature and the possiblity to be owned.

The Smartcontract defines:

  • What is the digital object
  • Who is the owner
  • How it can be exchanged

Minting

Lyfecycle of a token.

Triangle

  • Sécurity
  • Scalability
  • Decentralization


>> You can subscribe to my mailing list here for a monthly update. <<