Consensus Mechanisms
Consensus mechanisms are a set of rules and procedures to ensure all participants in the blockchain come to an agreement. i.e. it determines how agreement is reached among all participants when it comes to validating data.
There are many different types: proof of work, proof of stake, delegated proof of stake, proof of authority, proof of space, and proof of burn.
Note: if the consensus mechanism is proof of work you will see participants being referred to as miners, but if the consensus mechanism is proof of stake, participants will be referred to as validators.
miners = proof of work
validators = proof of stake
Types of Consensus Mechanisms
Proof of work: miners solve complex mathematical problems to validate transactions and create new blocks. First miner to solve the complex mathematical problem earns the right to add the block to the blockchain and is rewarded in cryptocurrency.
What is the complex mathematical problem?
The problem is just figuring out which number on the nonce results in the first few digits of the hash being 0000.
A nonce is just a counter, it counts what transaction it is.
Proof of Stake: validators are selected in proportion to the quantity of cryptocurrency they staked in the blockchain. i.e. the amount of cryptocurrency they have contributed to the blockchain. You put cryptocurrency up (stake) to have a chance to be a validator. Validators who validate correctly are rewarded with cryptocurrency. Validators who validate incorrectly are slashed (their stake is reduced/taken away).
How do validators in Proof of Stake, validate transactions?
Validators verify the digital signature of each transaction, to ensure each transaction was sent and signed by the correct person. They do this by checking the signer’s private key matches the public key in which the funds are being sent through cryptographic techniques.
Example:
Alice wants to send 5 tokens to Bob on a blockchain that uses a PoS consensus mechanism. Here’s how a validator would check the transaction:
1) Digital signature verification: validator checks Alice’s digital signature using her public key, to ensure she authorized the transaction.
2) Sufficient balance check: validator looks to see if Alice has at least 5 tokens in her account, and enough to cover the transaction fees
3) Nonce verification: validator ensures transaction nonce matches the expected sequence for transactions from Alice. I.e. each transaction has a nonce attached to it, which acts as a counter. For example, if Alice has sent already 3 transactions, the next transaction should have a nonce of 3 (nonce starts from 0, not 1). So if Alice sends Bob $5, and this is her 4th transaction, the nonce attached to this transaction should be 3. The validator checks that this is the correct nonce, ensuring it’s the next transaction in the sequence, thus ensuring that the same transaction isn’t processed more than once i.e. double spending.
4) Compliance with blockchain rules: validator checks transactions match the blockchain standards/rules e.g. correct fields, sizes, etc.
Delegated proof of stake: instead of setting up a validator node yourself, you stake your coins, then use your voting power to delegate the validation process to someone else who has their validator node set up.
Proof of Authority: validation of blocks is handled by TRUSTED, validators based on their reputation (authority), rather than their stake.
Analogy: A teacher wants to keep track of which students complete their homework each day, so instead of checking every piece of homework herself, she appoints trusted students to check the homework.
Proof of Space: validators must prove that they have a certain amount of storage in order to have the chance to become a validator.
Analogy: A library wants to digitize all its books and make them accessible online, and instead of relying on one single company to store all its digital books, the library asks community members to contribute by allocating space on their personal computers to store the digital books. The more storage you provide, the more likely you are to be selected as a validator. Example: Chia.
Proof of Burn: in order to gain the right to be selected as a validator, participants must first demonstrate a long-term commitment to the network’s operations through burning/destroying cryptocurrency.