Fundamentals of Blokchain, Bitcoin Cryptography in a nutshell

in #sct5 years ago

The American economy is collapsing in a huge wave that sweeps the rest of the world with it. It all starts with thousands of mortgage-backed mortgages, and continues with the fall of the stock exchange, the dollar and everything related to them.
A man named Satoshi Nakamoto (or group of people) decides that they have reached water to the heart - he no longer wants to rely on banks and governments to oversee the passage of money from hand to hand. so what are we doing? Invent the Bitcoin.
Of course, this is a shortened version of the rudeness of history as it happened, but the point is clear. However, this article is intended to present the world of virtual currencies as it is - and not as the hype and misinformation created over the years. With the fall of the Bitcoin we see speculation from here to Japan (ostensibly the origin of Satoshi), and most of them are based on nothing. So, I wanted to give as much information as possible about how virtual currencies work. This is an important point - I will not talk about the value of Bitcoin, ether and other vegetables, and I will also try to keep my personal opinion as little as possible. I will present in detail the technology (rather glowing, it should be noted) that stands behind the storm.

So what is Blockcain?
The Million Dollar Question.
Blockchain, in direct translation, is a chain of bricks (or, as noted, blocks). Simply put, the blockchine is one block, connected to the next block, which in turn is connected to the next and so on - theoretically, to infinity. In practice, the "connection" is the total retention of the HASH (which I will explain below) of the previous block in the current block - and so each block "knows" only who is behind it.

How does this relate to the currency?
Here we are already going into the depth of the matter, and in order to understand we have to present a few basic concepts:

Transaction - transfer of information (or, for that matter, money) from place to place.
Public key - An encryption key that everyone knows, and belongs to one person.
A private key - an encryption key that only its owner knows, and with which it signs a transaction (encodes it). You can decode an encrypted transaction with a private key only with the appropriate public.
HASH - A mathematical function that converts a block of information into a sequence of characters (whose number is constant) and is deterministic - from each information block, the same fire will always be exported (this is also the name of the sequence and the function). The charge can not be converted back to the message unless the public key associated with the information that encrypts the charge is known.
Distributed Consensus - Consensus of many entities, all of which have the same information, and the information is reliable (not maliciously altered).

If so, let's start.

Satoshi Nakamoto aspired to create a system by which we can transfer money without using a reliable third party. This is the crucial point - until that moment, all funds have been transferred under the supervision of a central third party on which both parties are relying. It was almost always bank. What Blocchine suggests is a way to do this by achieving a decentralized consensus, that is - everyone agrees that:
A. A transfer was made from A to B,
B. Next to A was enough "money" in order not to remain in the balance sheet
third. The transfer was made at the initiative of the first party and he signed it

In this way, not only is there no need to rely on a third party (which may have an interest / malicious intent), but it is possible to lower the fees significantly, since one does not have to finance a bank with all its senior officials and expenses, but one entity that carried out work on a specific transaction An entire block filled with transactionalism, more on this later).
The overall agreement will solve two main problems:
A. Sending money that does not belong to the sender
B. The problem of "double waste" - if I have 10 coins and I simultaneously send two entities 10 coins, how do you decide which one will receive them?

how does it happen?
Ready? Rub your eyes and sit in the chair, because I'm going to complicate matters.

Suppose Side A wants to transfer 10 coins to the second side. He sends a message to the entire network "Side A 10 coins next to B", and encrypts it with his private key. The network receives the message, and each participant begins to try to check it. He makes sure that there is indeed the amount requested by the first party, and also that the message was signed by him - otherwise, it will not be deciphered properly with the public key.
In addition, in order not to be able to easily process the block to which we are trying to pin the transaction, there is a random number that must be guessed - and you have to try a lot until you reach it. 0,1,2 .. So until you reach a very large number.
Why?
So if we did not do the hard work, any computer could easily change all the blocks to fit the information he wants to transmit to the network - say, that he has a thousand Bitcoin. Since it is difficult to guess the number, it takes about 10 minutes for the computer to do so.
Now - remember that the blocks are connected? So if we try to change a value in Block 1, its HASH will no longer match what is listed in Block 2. Then we will need to change Block 2. Then 3. What happens is that while we try to change the chain, others extend it further. Bitcoin's protocol says that you must always choose the longer chain, so unless we have more processing power than all other computers on the network, we will never get them and work for nothing in an attempt to change the chain maliciously.

So after we did work on, say, 100 transactions, and confirmed that they were really reliable. two questions:
A. Why would I even invest processing resources (electricity) for the network? What will I get from this?
B. How do the others know that we have not cheated? Should everyone approve everything?

Here are the answers:
A. Because I accept a reward for this - and this is the commission from every transaction, which is much lower than bank fees. In addition, I was given the mandate to produce for myself a specific amount of coins as a reward for hard work.
B. Once we have finished processing, the computer generates something called Merkle Tree. This idea was conceived by Ralph Merkel in the late 1970s. I will not go into detail, but in general: The Merkel tree is a combination of all transactions, and by making sure that no changes are made to the transactions that make up it. It is also created in the fire function, and if there is an identification of a change, it is possible to find in which branch it happened and thus to see where the change is. Sending the Markal allows us to distribute to the network a minimal amount of information that proves that we did the right job, instead of everyone doing all the work and downloading all the information always (which would make the network slow and ridiculously cumbersome).

So great, we did a job, and in case someone else did the same job on the same block at the same time - how do you know which of us is putting a block on the grid?
As you may recall, all network participants choose the longest chain. It's a matter of luck - someone who will spread the chain to more people faster, will "conquer" the network's trust and receive the reward. In any case, there will be no contradiction, but rather a total "orphan" block - the chain continues, but no one uses it any longer, it is actually a short branch cut off from the chain (if we draw a graph, it goes away from the chain).

Sort:  

This post has received a 8.89% upvote from @swiftcash, thanks to @msg768 🤑