
This is the first article of a bitcoin learn serius.
Imagine a pigeons flock discover a pigeonhole but the number of pigeons is very high rather than the whole number of possible holes and all of them want to stay in one of the holes… the image below pictures the scenario.
Now, please bare the image up above in mind and before the end of the article it will be perfectly clear the similarities between pigeons and blockchain.
Blockchain as the word suggest can be imaged as a list of blocks chained togheter. Each block can be represented as a sequence of characters and numbers, in bitcoin scenario the below sequence represents the block number 123456 in the bitcoin blockchain:
0000000000002917ed80650c6174aac8dfc46f5fe36480aaef682ff6cd83c3ca |
We’ll explain later on the exact structure of the string representing a block. Each block stores informations, the numbers of coins(bitcoins or any cryptocurrencies) generated by the block, the list of transactions, the difficulty, the nonce, the height of the block, the string representing the previous block, the sting representing the block itself and some others, but let’s focus on the last one:
the sting representing the block
That string, in mathematical jargon is the result of a function, the hash function.
What is a hash function?
A hash function as all other mathematical functions, is a process that associates elements belonging to a set named domain to elements of a set named codomain. In particular, a hash function, has some properties:
- Calculate a codomain’s element it is very quick.
- It mustn’t be possible to programmatically finds the domain’s element that generated the codomain’s element, unless by guessing! Because of the previous statement hash functions are also known as one-way-function.
- Domian’s element should have a good distribution over the codomain set, such that it has to be very very very higly difficult that hash(m1) =hash(m2).
- Elements belonging to domain are infinite, elements belonging to codomain, instead, are finite.
Consequence of the statement above, given the informations in each block, they are used as the domain element to calculate the hash of the block, and if all the properties of the hash function that we have decided to use, in case of bitcoin the hash function is known as SHA256, are respected, “””only””” the given input, and some others infinite elements of the domain, will generate the same hash.
Yet you haven’t realized?
That’s what a blockchain shares with pigeons… and this principle is known as the “pigeon principle”.
And, this is what gives strenght and weakness to blockchain and all software based on cryptography. Weakness because for sure there exists many different elements(pigeons) that generate(stay) the same hash(in the same hole), so, in a blockchain example, the block can be altered, and it means altering some of the transactions of the block, but altough it is true that different elements can generate the same hash, at the same time, it practical impossible with the actual calculation power to find a collision for a particular hash in an acceptable amount of time.
We have just scratched the surface of the bitcoins and cryptocurrencies in general, I hope you enjoyed the reading, and keep following the serius as many articles will explain deeply some concepts mentioned in this article.