Bitcoin technology II

"Human civilization flourished in times and places where sound money was widely adopted, while unsound money all too frequently coincided with civilizational decline and societal collapse".  — Saifedean Ammous

Each Bitcoin balance is associated with a Bitcoin address. The creation of addresses is a simple and free process that a program called a wallet may assist to.


Addresses are obtained from Public Keys which in turn are derived from Private Keys.

edcc6224fee390a57c76c13a9becc9502a6f3b1bf6f72b6ed11b83a0f0e3e9fc --------->

04f3df70315e569bbf9fb427da65e60ce2e3660ea83ec8a8523da4de6901f7988e9e460cd594f27c9f6 --------->



One-way functions are used on those processes, which means it is not possible to obtain a Public Key from an Address, neither to derive a Private Key from a Public Key.


A Private Key consists of a random number between 0 and 2^256 (roughly the number of atoms in the known universe), so its entropy (disorder) is 256 bits.

It can be used to encrypt data that only its Public Key is able to decrypt.


That feature is employed to demonstrate compliance with a message, which is the equivalent of signing a message: by keeping a Private Key in secret, its owner could publish a text that includes:

-the message

-the Public Key

-and the digital signature, which simply is that same message encrypted by its Private Key


The mathematical proof that the owner of the Private Key has authorized the Message (digital signature) can be verified by decrypting the message with the Public Key and checking that the resulting message and the original message coincide.


A transaction is simply a digitally signed message that orders the change of bitcoin units between Addresses. The message also specifies the number of units to be paid as commission to the block creators (miners) to incentivize the priority of its execution. 

The first transaction in a block (coinbase transaction) is included by the miner himself to receive the reward at his own Address.


Hashing makes easy verifiable the integrity of historic data.

Cryptographic hash functions transform any digital data (input) into a fixed size of data (hash). 


Cryptographic hashes are for data what fingerprints are for people:

-A fingerprint does not disclose any information about the person. (One-way function).

-Similar people may have very different fingerprints. (Slightly different digital data result in completely different hashes).

-The same person will always produce the same fingerprint. (The same data will always result in the same hash).

-Let's assume fingerprints are always of the same size independently of the size of the person, for the sake of the analogy. (No matter the size of initial data, the hash will always have the same size).

Try it here!

There are different kinds of hash functions, the most commonly used in Bitcoin is SHA256, which produces a 256 bits hash. Examples:

-An Address is the encoded hash of a Public Key

-The transaction ID is the double SHA256 hash of the data that it contains.

-The block ID is the double SHA256 hash of the block header data.


Data that constitute a block: 

 -Transactions and their respective hashes (Merkle tree):

 ••••   #

 •••     #

 ••••• #

 -Header:  # # Ν # Τ

The block header contains:

1. #   Hash of Previous block ID

2. #   Combined hash of all transactions' hashes (Root of a Merkle Tree)

3. Ν #   Nonce + target hash

4. Τ   Timestamp 

block header.png

1. Hash of Previous block ID: 

This is what chains the blocks. If blocks are imagined like the pages of a ledger, each new page would contain a small photo of the previous page in which a photo of its previous page would appear and so on, so all pages would appear in the last photo of the book. 

Each new block creates a hash of the entire payment history, so altering the info contained in a block would make that block and all subsequent blocks invalid.


Like a mosquito in amber, the deeper a block is in the chain the more irremovable (final) it will be.


2. Root of a Merkle Tree:

It provides an easy way to verify the integrity of transactions data.


3. Nonce and hash target:


The nonce is a number used only to change the Block ID. 

In order to mine a block, it is necessary to be the first in finding a number (nonce) that combined with the rest of block header data, results in a hash (Block ID) lower than a certain threshold (hash target). 


Imagine you are on the task of hashing data that contains the word bitcoin until obtaining a hash starting by 000. You could try with bitcoin-1, bitcoin-2, .... until you find a “nonce" that gives that result:

Try it here!

The nonce would be 1918 in this example ;)


The block ID Proofs Work that can be quickly validated by nodes. 

Based on energy spent miners obtain probabilistically the power to propose the execution of transactions, but transactions are ultimately executed by nodes, in a decentralized way.

Analogously to the difference in work required to find a needle in a yard, and that necessary to verify that it is indeed a needle, there is a great asymmetry between the cost incurred when mining a block and that incurred in its verification. That makes costly for miners to misbehave. 


Hash target:

It is previously established by the network with the goal of getting blocks produced at an average rate of 10', which reduces the incentives for miner centralization by making the data propagation time comparatively

short, and ensures that orphan blocks are extremely rare.

The small stream of data also helps information to be easily replicated, and eases the cost of running a node.


The miners' total calculation power changes with time, so hash target needs to adapt or blocks would be produced much faster/slower.

In order to achieve the adjustment:

-Each successful miner will include (stamp) the approximated block’s creation time (timestamp) in the header of the block.

-In order to deduce the average hash rate, every 2016 blocks (approximately two weeks), the network will calculate the difference in time between the first and the last stamps.  

-The hash target will be automatically adjusted accordingly (retarget), by rising the mining difficulty if blocks are produced too fast or by lowering it, if blocks are being created slowly.


The target can’t change by more than a factor of 4 or by less than a factor of 1/4 to limit the effect of certain double-spend attacks.


The mechanism effectively work as a decentralized clock.


4. Timestamp:  

It is not exact. As an anecdote: not always increases from block to block.

In order to be accepted by each node: 

-It must be later than the median of the previous 11 timestamps. 

-It must be at most two hours in the future, according to each node own official time.


Hashing provides integrity.  

Encryption provides confidentiality. 

Encoding is converting data into a particular form that can be reversed.