Decentralized Systems

In this article, we learn how a decentralized system such as a blockchain addresses trust issues.

Table of Contents.

  1. Introduction.
  2. Elements of Trust in a Blockchain.
  3. The Trust Trail.
  4. PoW(Proof of Work).
  5. Summary.
  6. References.

Introduction

Bitcoin is described as a database modeled by a linear sequence of blocks, each block has cryptographic hashes that correspond to the previous and current block. These links between blocks form chains. The bitcoin blockchain is used for the exchange of value and all transactions that were ever made are stored in this decentralized database.

The following image demonstrates chaining in bitcoin.

bit142

The above ensures the immutability of the database by each block using the hash of the previous header block hash in the current block. A block header stores the root hash of the merkle tree for all block transactions. This way if anyone decides to change a transaction, it will affect the local chain and render it invalid. As discussed in a previous article, once this happens, the block can no longer participate in blockchain activities.

In this article, we learn how a decentralized system such as a blockchain addresses trust issues.

Elements of Trust in a Blockchain.

In a traditional system such as a bank, all participants trust that a central authority will verify and validate and maintain immutability in transactions.

On the other hand, blockchains work in a similar way except there are no central authorities just mathematical algorithms executing on many different computers distributed across the globe with the same copy of a database.

Transactions between participants require that all participants trust the system and trust that it will perform as expected.

Elements of trust in a blockchain include;

  • Validation of transactions and blocks on the blockchain to make sure they are immutable.
  • Verifying the availability of resources such as wallet or account with sufficient balances before transaction execution.
  • Security(Public Keys cryptography and hashing) and other protocols
  • Reaching a consensus.
  • Executing and confirming transactions.

The Trust Trail.

In a blockchain such as Bitcoin or Ethereum, the elements of trust include securing the blockchain using mathematical algorithms, cryptographic hashing among others, validation of transactions and participants, verification of transactions and participants, and consensus mechanisms.

bit143-1

  1. The trial starts with the validation of transactions. We have mentioned the criteria that are checked during this phase. These include gas limit, syntax, transaction digital signature, nonce, account balance, gas points, hash, and transaction signatures, among others.
  2. The network makes sure that gas fees are available and the amount being transferred is available in the sender's account. Remember that bitcoin does not check if the sender's address is valid, meaning that once funds are sent to a wrong wallet address they cannot be recovered.
  3. Gather validated transactions to form a block. Transactions are hashed and stored as a tree of transaction hashes. They are combined in twos up the tree to form a cumulative hash which is the Merkle root hash.
  4. Execute transactions to get a new state. In Ethereum, the Merkel tree hash is computed. It is the transaction root in the block header. In any transaction, all miners execute the transaction or smart contract code on their own nodes. The Merkel tree hash(state root of the block header) of the states is computed using the state that results from the execution of transactions. The receipt root of the block header is also computed.
  5. Create a new block. A block consists of transactions and smart contract code.
  6. All miners reach a consensus(proof of work). The proof of work consensus mechanism involves finding a number used only once(nonce) that when combined and then hashed with the block header hash results in a value that is less than the target set by the protocol.
  7. Addition of the new block with confirmed transactions to the blockchain by all participants. Once the nonce is found by the winning miner, it is shared with all miners to confirm that it is indeed the correct one. This is what proves that the miner indeed put in work to find the block and therefore all miners add the mined block to their local copy of the blockchain.

A secure chain is consistent and as the chain grows, the trust level of the chain increases. Miners are always competing for the right of block-creation. On blockchains such as Bitcoin and Etherium, protocols have been implemented that are used to select miners who get the right to add their block to the chain. A common algorithm is referred to as PoW(Proof of Work). Just like all other blockchain operations, proof of work also uses cryptography.

This goes to show how cryptography is used in blockchain.

PoW (Proof of Work).

A secure chain in Ethereum is a single main chain with a consistent state, therefore, every valid block that is added to the main chain adds to the security and trust level of the blockchain.
This main chain will have the highest cumulative proof of work which is the sum of all PoW for all blocks in the chain.
Every miner hash a candidate block that he/she wants to add to the chain. A consensus mechanism is used to determine who gets to add his/her block to the chain.
PoW uses a hashing algorithm referred to as SHA-256.

The following image summarizes the process;

bit144

The first step is to compute the hash value of the block header elements which results in a fixed value and a nonce that is a variable, it can change.
If the hash value is less than the specified function difficulty, the puzzle has been solved. And the puzzle solver earns the right to broadcast his/her block. Other miners will add the winner block to the blockchain reaching a consensus.
If the puzzle fails to be solved, in this case, if the function difficulty is greater than the hash value, the process is repeated, this time the nonce is changed.

We can test this practically here. As you can see, once the nonce changes, the block itself and all other subsequent blocks become invalid.
In our case, the puzzle is similar except here it is invalid, now we have to find a nonce that makes it valid. The first to find the nonce wins and earns the right to create a new block and is also rewarded with coins.

Other protocols for consensus have also been developed and are still being developed. Some include proof of stake(PoS) and, proof of elapse time(PoET).

Summary

Trust in a decentralized system involves securing the blockchain using specified protocols, validation of transactions, and blocks that make it tamper-proof, and execution and confirmation of transactions.
Miners are responsible for the execution of transactions and smart contracts on Ethereum.
Proof of Work and Proof of Stake are consensus protocols used in Bitcoin and Ethereum Blockchain.

References

Blockchain-based trust & authentication for decentralized sensor networks