If you’ve seen the phrases ‘SegWit friendly‘, or ‘SegWit approved‘, and wondered ‘what is Segwit?‘, you have come to the right place! In this article we answer some common questions regarding this segregated witness protocol such as, ‘what is SegWit?’, how does SegWit work?‘, and ‘what are the benefits of SegWit?‘. We shall explain how the transition happened, why it does not apply to all blocks, and what happens to these legacy or non-Segwit transactions.

In case you find the following piece a tad too technical, it can be a great idea to enroll in Ivan on Tech Academy to get a firmer grasp on blockchain technology and crypto. Ivan on Tech Academy is one of the most popular blockchain education platforms and offers countless relevant courses. Enroll today and supercharge your blockchain and crypto education!

What is SegWit: Overview

Segregated Witness – commonly known just as SegWit – is a Bitcoin protocol update that fixed issues of transaction malleability and served as a way to help scale the Bitcoin network without the need for a hard fork (explained below). Bitcoin is a global and decentralized network meaning that should any issues arise, it is down to the Bitcoin community of developers and contributors to collaboratively arrange a solution in such a way that causes minimal disturbances.

SegWit was created by Dr. Pieter Wuille – the 2017 winner of Coindesk’s Most Influential in Blockchain Award -, who is a co-founder of Blockstream and works with the Bitcoin Core development team. The first proposal SegWit2X was dropped, before releasing the code for the second proposal in 2015, which is the SegWit we know today. Following a couple of years of development, SegWit went live on the Bitcoin network on August 23rd, 2017.

The implementation of SegWit has increased the maximum block size and more than doubled the transactions per second (TPS) confirmed on the Bitcoin blockchain. Also, SegWit has brought innovative layer two scaling solutions to Bitcoin, creating the foundation of the Lightning Network.

Some of the Bitcoin mining community were unhappy with the update and felt SegWit was a weakness to the Bitcoin blockchain. Despite the SegWit protocol itself not forcing a hard fork, the Bitcoin blockchain did indeed hard fork into a new blockchain called Bitcoin Cash in 2017. Bitcoin Cash is the legacy Bitcoin blockchain that existed before the implementation of SegWit.

Why SegWit

Prior to the SegWit solution, there was a pernicious flaw in the Bitcoin code. Specifically, the collection of data for a transaction features a digital signature – signed by the sender of a transaction to confirm their intent to do so. The digital signature is also a part of the cryptographic hashing function used by the Bitcoin blockchain, resulting in a unique transaction ID.

The Bitcoin protocol featured a flaw that could potentially allow any malicious attackers to access the digital signature and manipulate the resulting transaction ID to steal funds. Further in this article, we explain in detail how SegWit has managed to solve the transaction malleability issue, while simultaneously increasing the block’s transaction density.

The introduction of SegWit was also in part to help scale the Bitcoin blockchain as the transaction speed was quite slow between 2009 and late 2017, at around 3 TPS. SegWit managed to more than double this to 7 TPS whilst increasing maximum block size capacity four-fold, from 1MB to 4MB.

With SegWit’s success in fixing the transaction malleability issues, this enabled the development of a layer two scaling solution, allowing further creation and development on top of the Bitcoin blockchain. This includes the Lightning Network which allows super-fast transaction times, by allowing peer-to-peer crypto transfers, without the transactions being public on the blockchain, with bad actors receiving penalties for invalid or fraudulent transactions.

Another important factor taken into consideration with SegWit’s proposal was the soft fork approach, meaning that mining nodes would still accept blocks whether they had updated to the SegWit protocol or not. The Bitcoin community aimed to find a solution that would be of minimum disruption to the chain, whilst maintaining network security and cooperation.

Forks

Cryptocurrency applications can’t simply be updated like, for example, traditional banking applications. There is no central entity that dictates changes to the protocol and instead, consensus must be attained. For a change to a decentralized protocol to take place, this can only be achieved by consensus or majority agreement between nodes.

When a blockchain community or the development team of a particular cryptocurrency cannot reach an agreement on changes to the rules of the protocol, or the future direction of the project, it may result in what is known as forking. Examples of well-known forks include: 

Ethereum Classic – the original iteration of the Ethereum network. The team was split on how to proceed after various flaws in the protocol were exposed, which resulted in the now-dominant Ethereum we all know. 

As previously mentioned, Bitcoin Cash is a fork of Bitcoin. Along with other cryptocurrencies such as Litecoin and Bitcoin SV, several forks of the Bitcoin protocol emerged, all boasting various advantages over the original cryptocurrency.

A fork allows an alternative chain to emerge from an existing chain. Forks can be used to add new features to a protocol or, to reverse or prevent hacking, without the need for a central authority.

There are two main types of forks:

Hard forks

A hard fork can be used to make upgrades to a protocol and requires full consensus from all nodes within the network. Unless all nodes reach consensus, a hard fork cannot take place.

Hard forks are a drastic change to the protocol and can validate blocks that were previously invalid and vice-versa. When a hard fork occurs, all nodes eventually reject the previous version of the software, creating a permanent shift from the previous version to a new upgraded version of the blockchain.

SegWit2X was proposed as a hard fork to update to 2MB blocks, however, this was rejected by the community.

Soft forks

A soft fork is backwards compatible. Non-upgraded nodes can still communicate with upgraded nodes. Soft forks change the protocol in a way that only invalidates previous transactions and blocks, and only requires a majority of miners to agree to upgrading the protocol, as opposed to every node, as with a hard fork.

Soft forks can be used to add new transaction types to a protocol and make temporary divergences in the blockchain when new consensus rules are violated. Soft forks are generally used to create rules that don’t disrupt older rules and are often a preferable choice.

SegWit made changes to the format of transactions. This didn’t break the rules, it just meant that only nodes that had upgraded to the latest software would actually understand all of the data from transaction requests.

How SegWit Works

To understand how SegWit works on the blockchain, you first need to understand a little more about how transactions work on the blockchain. 

Nodes of the network mathematically verify transactions, using data about the transaction itself, in the equation. Verified transactions are placed into a block with a 1MB capacity, which usually caters to an average of 3500 transactions per block. Once the block is full, it is then appended to the blockchain.

Part of the beauty of blockchain technology is the real-time, open-source distributed ledger that is available to anyone. A ledger is traditionally a book, or a collection of transactional records, the blockchain automatically stores all information and data about every transaction across several nodes, meaning there is no single point of failure.

The transaction data is cryptographically hashed within the algorithm and remains secure, so it cannot be recognizable or retractable to the original addresses. Within each block comprises:

– recipient’s public key

– the amount of BTC being sent

– sender’s public key

– sender’s digital signature

Digital Signatures

The digital signature is used to sign and confirm the transaction, hence also being referred to as the ‘witness’. Witnesses are needed to a) confirm the validity of the transaction, and b) to be used in the cryptographic hashing formula for the PoW mining algorithm.

Although crucial to the transaction, digital signatures take up the majority of the file size of a transaction – depending on where you read it can vary between up to 60-70%. In the early days, this wasn’t so much an issue, until growth in adoption congested the network resulting in extremely slow and expensive transactions.

Before SegWit was introduced, the digital signature used to be in the middle of the transaction data structure. Now, SegWit removes the witness from the center structure and places it at the end of the data structure. This means that now, unique transaction IDs are created using all transaction data except the witness, which are validated by different nodes.

The segregation of the witness removes the malleability threat, alongside reducing the file size of the transactions substantially. Reducing the file size of transactions allows more transactions per block, or higher transaction density, thereby increasing the transactions per second without any adjustments to the blocksize themselves.

Following the launch of SegWit there is a new way to calculate the block weight using the formula: (transaction size with witness data stripped)*3 + (transaction size).

Feeling a bit confused after reading about all of these crypto terms? In that case, you should absolutely enroll in Ivan on Tech Academy. Join over 20,000 students already studying at the Academy. Furthermore, right now you can get 20% off when enrolling with the exclusive promo code BLOG20!

SegWit Nodes

When a transaction is being validated by a legacy node or a non-SegWit node, the witness data is stripped from the center of the transaction data, thus creating a smaller transaction size allowing more transactions per block.

Legacy transactions don’t have witness data due to being stripped, whereas SegWit transactions do, but at the end of the structure and they are processed separately by SegWit nodes.

SegWit nodes are capable of mining blocks that are just shy of 4MB, nearly four times that of Bitcoin. How? When broken down, nodes can mine nearly 3MB of witness data (digital signatures), and up to 1MB of script data (data from the transaction) – so are still Bitcoin-friendly!

Although technically speaking, SegWit nodes are capable of mining a 4MB block, in reality, this is an abnormally large block to process. Most blocks don’t exceed 2MB for maximum transaction efficiency.

SegWit vs Native SegWit

Native Segwit, also known as bech32, further enhanced transaction speed, lowered transaction fees, improved the detection of errors, and made for greater scalability.

One of the most notable drawbacks to Native Segwit is that it is not supported by all exchanges and wallets. Though this is not a major issue, it can be an inconvenience. That being said, it is quickly becoming standardized.

SegWit as we know it, can occasionally also be referred to as ‘wrapped’ or ‘nested’ SegWit. The most recognizable visual difference between addresses is how they start.

Native SegWit Address: “bc1…”

SegWit Address: “3…”

The Future For SegWit

As such, some observers would say SegWit has solved a potentially fatal and fundamental flaw in the Bitcoin protocol, removing the vulnerability of manipulation of the transaction malleability loophole from hackers. Also, SegWit has allowed the Bitcoin blockchain to scale and increase the TPS as adoption continues to grow.

However, as well as this may be, not all nodes have updated to the Segwit protocol for a couple of different reasons:

  • SegWit is not compatible with mining firmware Asicboost, which promises to speed up transaction verification time by almost 20%. Some miners prefer to stay loyal to a known firmware brand, and not buy expensive new mining equipment if they don’t have to.
  • SegWit was not a compulsory upgrade, and the decision to implement SegWit is in the hands of the crypto business CEOs (wallets, exchanges, etc.) who may not want to rock the boat and adjust their protocol every time there is a new update. Binance CEO, Chanpeng Zhao, or, CZ, publicly discussed adding SegWit compatibility to the exchange in an interview with Altcoin Daily, saying that the addition of SegWit is underway, but requires a lot of work and is unable to give a timeline.

The adoption of SegWit has been growing exponentially since it’s released in 2017. By 2018, 29% of Bitcoin users had implemented SegWit, and in 2019, this increased to 60%.

The leading hardware wallets Ledger and Trezor support SegWit, and crypto exchange Gemini are leading the way being the largest centralized exchange supporting SegWit transactions, with hopes many more will follow.

Hopefully, we’ve answered all of your questions around ‘what is SegWit?’, and if you would like to learn more about the fundamentals of blockchain technology and cryptocurrency, feel free to look through our blog – packed full of insightful articles about the use cases of blockchainhow to keep yourself safe from scamstraveling the world with crypto and much more!