1.9

## EIT InnoEnergy

Skip to 0 minutes and 12 secondsIn the previous lesson, we saw how Alice, Bob and Chuck gave solution to all the vulnerabilities they found in their ledger. They found a way to be aware of all the transactions taking place and they came up with methods to identify fake transactions and tracing back fraudulent modifications. Manipulating the history of ownership is impossible now, but Chuck still figures out a way to cheat. He owes some money to both Bob and Alice. So he creates two new transactions and transfers ABC-coins to Alice and Bob at the same time, having only enough funds for one of the transactions. When Alice receives the transaction she thinks the transaction is valid. So does Bob.

Skip to 1 minute and 0 secondsThere is no way for them to know whether the coins they received have been spent somewhere else. This problem is known as "Double Spending". Again, they find a solution. They make sure that all the transactions are in a certain order, so the same transaction cannot take place twice at the same moment. To achieve this, one or more transactions are collected and put in a so called block. In the case of Bitcoin, one block contains about 2000 transactions. Each block will contain an identifier in the form of a hash of the previous one. This results in a chain of blocks. A Blockchain.

Skip to 1 minute and 44 secondsThey have built a pretty resilient system! But what if Alice, Bob and Chuck disagree about the information displayed in the Blockchain? Let’s imagine they disagree about the particular order in which the blocks are stored. They need a consensus mechanism that decides who is right. How is consensus in the network achieved? The users periodically compare their version of the ledger. When they observe a difference, every user votes for the version of the ledger that they think is honest. One vote per account, the version of the ledger that will prevail is the one voted by the majority of users. In our scenario, the blockchain will discard the ledger where Chuck registered two transactions.

Skip to 2 minutes and 32 secondsBy adding this mechanism, they have achieved a perfectly secure private network. In other words, a private blockchain. However, after validating their system, they don’t want to stop here! Now they want to open their ABC-coin network to the public, so everyone can have an account and start trading ABC-coins. As soon as they do this, Chuck tries to cheat again. Chuck registers 10 accounts pretending they belong to new users. Later on, he uses these accounts to vote for some altered version of the ledger where he has more coins than he really has. We just reached the main issue with virtual identities. It is not possible to control how many different accounts belong to the same person.

Skip to 3 minutes and 21 secondsTo be sure that there is one account per user, the system should rely on formal identity checks outside the system via passport or ID cards. However, this goes in the opposite direction of what they are trying to achieve, and even then, for many cases it is desirable to allow more than one account per person. In order to stop Chuck from cheating, they need a voting mechanism based on something which is not easy to replicate. It needs to be based on a scarce resource that the user must have. This scarce resource could be computational power. This type of voting mechanism is called Proof of Work. The voting could also be based on the amount of money there is in one account.

Skip to 4 minutes and 7 secondsThe more money you have, the more voting rights you have. This is called Proof of Stake. Both of them will be explained thoroughly in later weeks of the course, but let’s see how our team manages the situation. In these scenarios, to succeed, the attacker must have enough computational power or money to impose his version of the ledger in voting. Doing that would require an incredible amount of energy, in the first case, or funds, in the second, and it could be punished by the system. The gain obtained from faking the transaction would be minor compared to the resources invested in doing so. This is the reason why we say that is economically disincentivizing.

Skip to 4 minutes and 54 secondsLet's say Alice, Bob and Chuck decide to use Proof of Work. That's also the mechanism used by Bitcoin. They come up with a primitive version, where you are allowed to vote after solving a computational challenge created by the system. The challenge could be, for example, to guess a secret random number in a certain interval of time. Guessing a random number can be very difficult, and they have to put a lot of work and computational resources in doing so. This process is called mining. The miner that successfully guesses the number is rewarded with newly created ABC-coins. After succeeding, the miner will attach the mined block to the previous correct block.

Skip to 5 minutes and 42 secondsAlice, Bob, and Chuck have created a trustless, immutable and decentralized network. A blockchain. Now we learnt that a blockchain can be used to transact electronic cash, but that’s only one of the many functions blockchain can accomplish. Stay with us to discover what comes next!

# How does a blockchain work?

Blockchain technology offers a storage system that is more resilient to database attacks than any other technology. Watch this video to fully understand the way a blockchain works, the actors involved and the rewards at stake. You will also learn where all the data is stored and who keeps it safe.

A lesson from Alexander Kaiser, Blockchain Developer at BlockInfinity