Categories
Crypto Guides

What Is SegWit & Why Is It Required?

Introduction

There are over two thousand cryptocurrencies and tokens in the market, and all of them have a set of rules to ensure they work properly. These rules are also referred to as protocols, and they are continuously in progress. Similarly to any computer code, mobile phones, and apps, the cryptocurrency protocols must be updated and improved, which means teams of programmers work every day to detect code errors, improve their performance and add new functionality. And SegWit is one of the updates that has been implemented in the Bitcoin protocol.

What is SegWit? 

Pieter Wuille was the man who came up with the idea of SegWit at a Bitcoin conference in 2015. Wuille claimed that SegWit was a possible solution to the flaw in the Bitcoin protocol. SegWit was a proposed solution to the problem of transaction malleability. Transaction malleability is a way of saying that coins can be stolen from the user just by changing tiny pieces of transaction information.

How does transaction malleability work?

Let’s say Bob sends 10BTC to Billy. But, with transaction malleability, Billy can trick Bob into sending him 20BTC instead of 10. The transaction malleability flaw in Bitcoin’s code enables Billy to tamper Bob’s witness before the transaction is confirmed on the blockchain network.

In this case, the transaction ID changes, but the transaction does not (10BTC were still sent from Bob to Billy). Now, Billy contacts Bob, saying that he hasn’t received 10BTC, though he actually has. Since the transaction id was altered, Bob checks and sees that the original transaction hasn’t been confirmed. So, seeing this, Bob sends 10BTC again to Billy. And Billy now receives 10 BTC more and 20 BTC in total.

The patch to transaction malleability

As mentioned earlier, a patch is a solution to this glitch in the Bitcoin protocol. SegWit is a patch designed by Pieter Wuille to bring a stop to transaction malleability. To prevent witness data from being used to alter the transaction ID, Peiter suggested removing it from the transaction. Hence, it is given the SegWit, which is the abbreviation for segregated witnesses, means to remove or separate the witness data.

A segregated witness creates something called as sidechain where witness data is stored aside from the main blockchain. This method efficiently prevents transaction IDs from being changed by dishonest users. Also, a smart thing about SigWit is that it’s backward compatible. So the nodes that are updated with the SegWit protocol can still work with nodes that are not updated yet. Such an update is called a soft fork, as opposed to updates that are not backward compatible, which are called hard forks.

Wuille wanted SegWit to be backward compatible so that the witness data was still recorded on the main blockchain. To solve this problem, he encrypted all the witness data of a block on the SegWit sidechain and then stored this root code on the main blockchain. Hence, transaction malleability was successfully patched without a hard-fork update.

The Pros on SegWit

💡 Patch to the transaction malleability – The problem of the malleability of transactions was solved by SegWit.

💡 Faster Blockchain transactions – SegWit makes the network much lighter. More transactions can be performed without increasing the overall block size.

💡 Room for more development – Things don’t end just at transaction malleability. If the use of blockchain increases drastically, the issue of scalability must be figured. And SegWit helped lightning network technology come to reality.

Conclusion

The problem of transaction malleability was a real concern to Bitcoin. A patch to it was really in need. Hence, Pieter Wuille came up with a successful patch to it. And this brought talks about the bright future of the Bitcoin platform. We hope you understood the concept of segregated witness (SegWit). If you have any questions, let us know in the comments below. Cheers!

Categories
Crypto Guides

Consensus & Its Importance In Any Existing Cryptocurrency

Introduction

In most of our previous articles, we have discussed a lot of topics regarding cryptocurrencies. We now know the properties of cryptos, advantages, and their fundamental purpose. In this article, let’s discuss the concept of consensus and why it is essential for the existence of any cryptocurrency.

The consensus algorithm plays a vital role in validating the transactions of any crypto network. One of the crucial reasons for the success of cryptos is its ability to handle the problem of double-spending adequately. And this also an important reason for the failure of digital currencies before Bitcoin; they weren’t able to solve the problem of double-spending. So let’s see what this problem is about.

Double Spending

Double spending is a fraud where the same money is promised for two different transactions but is spent on making only one transaction in real. This is a significant problem for digital currencies because the entire system is decentralized, and there is no entity confirming the authenticity of the transactions. The cryptos after Bitcoin alleviate this problem by waiting for the confirmation of the payments. During this wait time (which is very minimal in general), the transactions are validated by the users present in the blockchain network using the ‘consensus’ algorithms.

The consensus here is nothing but a mutual agreement within all the partiers that are present in a cryptocurrency network. The majority of the validators must approve the transactions, and this is made possible by the consensus algorithm. Also, because of this protocol, a crypto network cannot be controlled by a single person or a group of people. Now, let’s look at two of the most important and equally reliable consensus mechanisms – Proof of Work & Proof of Stake.

Proof of Work (POW)

Proof of Work is used by Bitcoin blockchain. This consensus algorithm proposes a mathematical problem for the miners in the network. To solve this challenge, high power computing devices are used, and thereby a lot of electricity is consumed. The first one to solve the problem gets to validate the transactions and communicate the same to all the other miners in the network through gossip protocol. Then all the other miners verify the transactions and seal them in a block.

The crux here is this. To solve this challenge, the miner uses a considerable amount of power and hardware, which is a costly process. Hence, one would be honest enough to not validate faulty transactions as a lot of stake from the user side is already expended. This is how POW makes the miners be reliable and run the blockchain efficiently. They are rewarded with the in-house cryptos for doing this work. Though the POW consensus algorithm is the most efficient one out there, it is the costliest of all the consensus algorithms and not eco-friendly, which is the need of the hour.

Proof of Stake (POS)

In this consensus protocol, the participants who want to be the validators must stake some of the native cryptocurrency in a virtual safe for a specified period. The network randomly picks the validators based on certain methods. The two most used methods are ‘Randomized Block Selection’ and ‘Coin Age Selection.’ In Randomized block selection, the validator is chosen based on the highest stake and lowest hash value. While in the Coin Age Selection, the validators are picked based on the duration of the native currency staked in the virtual safe. Dash and Peer coin are examples of cryptos that use POS.

Why is POS more reliable than POW? 

POS algorithm uses considerably less energy compared to POW. Hence, the process is less expensive, and most importantly, it is eco-friendly. Also, the POS protocol fulfills the fundamental property of blockchain as it serves the purpose of complete decentralization. This is not the case in POW because currently, there are large mining pools who mine cryptos (Bitcoins, for example) and get the maximum reward. But that’s not possible in POS, making them truly decentralized.

Conclusion

Apart from these two, there are other major consensuses like Delegated Proof of Stake (DPOS), Proof of Burn (PoB), Proof of Elapsed Time (PoET), and Proof of Activity (PoA). These protocols are gaining momentum because of their efficiency and eco-friendly nature. However, a lot of research is still happening to develop more efficient and cost-effective consensuses. We hope you find this article worthful. Let us know if you have any questions in the comments below.

Categories
Cryptocurrencies

Consensus and Consensus Mechanisms

Cryptocurrencies operate on a blockchain – a decentralized peer-to-peer system with no centralized authority that makes decisions on behalf of the other participants. While this system eliminates arbitrary decision making and corruption, it still presents a problem. How will decisions be made? How will things get done?

For blockchain networks to make decisions, there is a need to come to a consensus. Blockchains use “consensus mechanisms” to secure the network and verify transactions. Consensus mechanisms are protocols that ensure all nodes (devices that support blockchains by validating and relaying transactions) on the chain are harmonized and can collectively approve and add transactions on the blockchain.

Characteristics of a Good Consensus Mechanism

In order to ensure a consensus mechanism is fair and reliable and achieves the function of a “consensus,” it must possess certain qualities, like being:

☑️Agreement Oriented: A consensus mechanism should elicit the highest level of agreement possible from the group

☑️Collaborative: Participants in the group should put the best interests of the group above everything else

☑️Cooperative: Decisions should be made to benefit the group as a whole rather than individuals

☑️Egalitarian: This means the system is fair – every single vote must carry equal weight. No one vote can be more important than the rest

☑️Inclusive: As many people as possible should feel like their vote counts and want to participate in the process, unlike a regular voting process where people are unmotivated to vote because they feel as if their vote won’t count in the long run

☑️Participatory: The consensus mechanism should be designed in a manner that everyone can participate in the process

Consensus Mechanisms Used In Cryptocurrencies

Ever since Bitcoin pioneered the proof of work mechanism, multiple other consensus models have been experimented with and adopted. Some of these mechanisms have been created to sidestep the energy-intensive aspect of proof of work. Others aim to achieve faster and more convenient transactions. With that, here are some of the most common consensus mechanisms used in cryptocurrencies today.  

1. Proof of Work

Proof of work (PoW) is the consensus mechanism used by Bitcoin, the pioneer cryptocurrency. It involves a process known as mining, which confirms transactions and adds new blocks to the chain. To do this, miners usually solve challenging computational puzzles. The first miner to solve the puzzle is the one to add a block and to receive a reward in the form of crypto coins. The computational puzzles have certain unique features. Let’s take a look:

  1. They are asymmetric, meaning they can take a long time to figure out the answer, but it’s very easy to verify if the answer is correct
  2. They are solved with a trial and error method, meaning the only way to solve is to guess and keep guessing 
  3. Their difficulty changes in response to the rate at which blocks are being mined. The quicker the blocks are added, the harder the puzzles become, and the reverse is true

PoW is very effective against fraud, as it makes it almost impossible to alter anything in the blockchain – and that is improbable as it would mean re-mining all successive blocks. Also, no one user can monopolize the process, since both the mining machines and the power required to run them are quite expensive. 

2. Proof of Stake

Proof of Stake (PoS) allows people to validate transactions according to their ‘stake’ – the coins they hold. This means that the more cryptocurrency one has, the more computational or mining power they have. 

PoS was designed as a cheaper alternative to Proof of Work, as the latter uses up excessive power and is therefore very costly. PoS addresses this issue by assigning mining power per the ownership of coins. Instead of using energy to solve difficult puzzles, a PoS miner mines percentage that corresponds with his/her ownership stake. For instance, if a miner owns 2% of the Ether available, they can only mine, theoretically, 2% of the blocks. 

3. Delegated Proof of Stake

This is a special type of PoS. This consensus mechanism is very fast and able to complete more transactions per second (TPS) than PoW and PoS. In a Delegated Proof of Stake (DPoS), crypto coin holders stake their coins to elect a certain number of delegates. The weight of a vote depends on the voter’s stake – e.g., if person A stakes 5 coins for a delegate and person B stakes 2 coins, A’s vote carries more weight than B’s vote. 

Now, these delegates have the power to produce more blocks on the network. Delegates who receive the most votes can create blocks, and be rewarded with coins or a percentage of transaction fees (as is the case with PoW and PoS). The vote is dynamic, so the top delegates can change anytime. Also, the number of delegates depends on the design of blockchain: either a fixed number or all delegates above a certain paygrade. 

 4. Proof of Capacity (PoC)

This is a consensus mechanism that allows miners to utilize empty space on their hard drive to mine crypto coins. It uses a process called plotting, in which solutions to puzzles are pre-stored on digital storages. Once a storage has been filled with solutions, it can participate in creating new blocks. 

The plotting process uses a very slow hash function called Shabal and can take days or weeks. The takeaway is, PoC is a game of space: the more hard drive capacity you have, the more solutions you can store, and the better your chances of mining the next block. Burst coin is the first and only cryptocurrency to use PoC.

5. Proof of Elapsed Time (POET)

Proof of elapsed time is a mechanism that uses a sort of lottery system to choose block producers. Every single node has a fair chance at winning. The idea is to randomly determine who gets to create a new block, based on the time they have waited. 

A POET algorithm works as follows. Each participating node is supposed to wait for a randomly assigned period of time. The node whose designated waiting time ends first gets to create the next block. After this node “wakes up,” they commit to add a new block and then broadcasts the information to the whole network. The process then repeats itself. 

The POET consensus mechanism can only work under three conditions. First, there must be a system in place that ensures no one single person can run multiple nodes and second, that the waiting time is indeed random and third, that the winner actually finishes their waiting time. 

6. Proof of Burn

The proof of burn mechanism works by allowing miners to “burn” or “destroy” the cryptocurrency tokens, which allows them to create blocks in proportion to the coins burnt. 

The idea is that miners should show proof they have burned some coins – that is, sent them to an address where they can’t be spent. The process, unlike proof of work, for example, does not consume too many resources, and it also enables the network to remain quick and agile. Miners can either burn the native currency or coins of an alternative chain, upon which they are rewarded with the currency of the native chain. 

7. Proof of Authority (PoA)

In a PoA consensus algorithm, people stake their identity to become block producers. The blockchain is secured, and transactions are verified by approved accounts known as validators. To become a validator, users disclose their identity, which is then cross-referenced with existing public data. There are three requirements which qualify one to be a validator on a PoA blockchain: 

1. Their identities must be formally identifiable on-chain with the ability to crosscheck it from data available on the public domain

2. Eligibility to become one should be above par – so that the position is filled by people with an honest incentive

3. The process must be uniform and fair across the whole choosing process  

The idea behind the PoA principle is that validators will act in good faith; trust is indeed the foundation of the protocol. 

8. Proof of Importance (PoI)

First introduced by NEM for its cryptocoin -XEM, the PoI consensus mechanism takes into account other qualities more than just the amount of coins one has. It is based on a user’s contribution to the network in all areas, including reputation, frequency of transactions, and overall balance. 

With PoI, the more active a user is, the more they qualify to “harvest” new blocks on the blockchain. This was designed to encourage network participants to actively conduct transactions rather than hoarding coins. 

The technology underlying PoI ensures the mechanism is manipulation-proof – so users can trust that miners’ selection is reliable and fair. 

9. Practical Byzantine Fault Tolerant Mechanism (PBFT)

PBFT is derived from the Byzantine Generals’ Problem, an analogy used in computer science. The Byzantine Generals’ problem is as follows. A group of Byzantine generals is preparing to launch an attack against an enemy. To win, they must attack at the same time. But the problem is, some of the generals might go rogue or act maliciously. So how will they launch a successful attack despite this probability? 

In other words, in any distributed computing system, there is always the possibility that some actors will not be honest or reliable. This is where PBFT comes in. The “fault tolerance” is the ability for a distributed computing network to reach a consensus despite the presence of malicious nodes that might fail to send information or relay the wrong information altogether. The majority of participants (at least 2/3) have to agree and execute transactions at the same time to avoid complete failure.

10. Proof of Activity 

Proof of activity is a hybrid of proof of work and proof of stake that attempts to combine the best qualities of both. The mining process starts with a standard PoW procedure – miners rushing to solve a computational puzzle. When a miner finds a new block, the system switches to PoS, with the block being only a template bearing header information and the miner’s reward address.

Then, a random group of validators is chosen from the network to validate the new block – according to the header information. Being chosen as the signer for a new block depends on the amount of cryptocoins a validator owns. When all validators sign a new block, it becomes a complete block and is then added on to the public blockchain network. 

In cases when some selected validators are not available to approve block, the process proceeds to the next new block, with other validators being chosen to sign on. The system runs in that manner until sufficient validators are available to sign off all produced blocks. In the proof of activity mechanism, mining rewards plus/or transaction fees are split evenly among the signers and the miners.

11. Leased Proof of Stake (LPoS) 

LPoS is an attempt to improve the proof of stake mechanism. PoS only allows users to create a block if they meet a certain minimum balance of coins. Also, not everyone can participate in securing and maintaining the chain or even get rewards. 

LPoS solves this by granting users the ability to “lease” their tokens to different contractors and receive a percentage of the payout as a reward. The more tokens are leased, the bigger the chance for a user to be selected to produce the next block.

In an LPoS environment, users can decide to run a full node or lease their stake to a full node. If the full node is selected to add a new block, the user gets a piece of the total transaction fees. In this way, the system allows everyone to participate in maintaining the network.

Conclusion

The takeaway is that all these mechanisms have the same goal: to reach fair and transparent decisions for all network participants. It’s intriguing to see how various mechanisms have evolved over time, and it certainly will be fascinating to watch as more enter the space, with each being (hopefully) better and more effective than its predecessor.