SegWit: Everything to Know

By  Beluga Research August 6, 2023

Image for SegWit: Everything to Know

Summary

  • Segregated Witness (SegWit) is a cryptocurrency upgrade that increases transaction capacity and reduces fees by separating transaction data from signature data
  • It separates transaction signatures from transaction data, reducing transaction size and increasing the number of transactions that can be stored in a block
  • SegWit also fixes the transaction malleability problem, enabling the development of second-layer solutions like the Lightning Network.
  • Slow adoption and increased complexity are among the challenges.

Overview

Segregated Witness (SegWit) is a cryptocurrency upgrade that increases transaction capacity and reduces fees by separating transaction data from signature data. In the world of cryptocurrencies, transactions are recorded on a public ledger called the blockchain. Each transaction consists of inputs and outputs, where inputs represent the funds being spent and outputs represent the destination addresses. However, the block size limit in the blockchain can pose challenges in terms of scalability and transaction speed.

A Brief History

To comprehend the significance of SegWit, it is essential to understand the challenges faced by the Bitcoin network. Bitcoin, being the first and most widely known cryptocurrency, has experienced a surge in popularity, leading to an increase in transaction volume. As more transactions were added to the blockchain, the block size limit of 1MB became a bottleneck, resulting in slower confirmation times and higher fees.

In 2017, the Bitcoin community faced a significant challenge known as transaction malleability. Transaction malleability refers to the ability to modify the unique identifier (hash) of a transaction without changing its content. This issue made it difficult to develop layer-two solutions such as the Lightning Network, which relies on unmodifiable transaction IDs.

SegWit: Everything to Know

Segregated Witness, often referred to as SegWit, was proposed as a solution to both scalability and transaction malleability issues. It was first introduced by Bitcoin Core developer Dr. Pieter Wuille in December 2015. SegWit aims to increase the number of transactions that can be stored in each block without increasing the block size limit.

So, how does SegWit achieve this? Instead of storing all transaction data within a block, SegWit separates the transaction signature (witness) from the transaction data. The transaction data, also known as the transaction record, includes information about sender, receiver, and the amount being transferred. By removing the transaction signature from the transaction data, SegWit reduces the size of each transaction, allowing more transactions to be included in a block.

Additionally, SegWit addresses the transaction malleability issue by removing the transaction ID's dependency on the transaction signature. With SegWit, the transaction ID is calculated based on the transaction data, excluding the signature. This ensures that the transaction ID remains unmodifiable, enabling the development of layer-two solutions such as the Lightning Network.

To implement SegWit, a soft fork was introduced to the Bitcoin network in August 2017. Soft forks are backward-compatible upgrades, meaning that nodes that haven't upgraded can still participate in the network. However, to fully benefit from SegWit's advantages, wallets and exchanges needed to update their software to support the new transaction format.

Getting Started

To understand SegWit, it is crucial to have a basic understanding of how transactions are structured in a blockchain network. In cryptocurrencies like Bitcoin, transactions consist of inputs and outputs. Inputs reference the unspent transaction outputs (UTXOs) that are being spent, while outputs specify the recipients and the corresponding amounts being transferred. Additionally, each transaction includes a digital signature, which provides proof of ownership and ensures the integrity of the transaction.

In the traditional Bitcoin transaction structure, the digital signature is an integral part of the transaction data. This inclusion of signatures leads to a larger transaction size, which, in turn, affects the scalability of the network. The larger the transaction size, the more data needs to be stored and transmitted, resulting in longer confirmation times and higher fees.

Unique Aspects

SegWit introduces a novel approach to transaction structure by separating the transaction data into two components: the transaction data and the witness data. The transaction data contains the inputs, outputs and other essential information, while the witness data includes the digital signatures and other related data. This separation is achieved by modifying the transaction format in a backward-compatible manner, ensuring that non-upgraded nodes can still process SegWit transactions without any issues.

By segregating the witness data from the transaction data, SegWit effectively removes the digital signature from the transaction size calculation. Instead, the signatures are stored in a separate data structure, known as the witness block. This modification significantly reduces the size of the transaction, allowing more transactions to be included in each block and improving the overall scalability of the network.

Furthermore, SegWit addresses the problem of transaction malleability. Transaction malleability refers to the ability to modify the transaction ID without changing its content. This issue can cause complications, particularly for advanced features built on top of the blockchain, such as the Lightning Network. SegWit solves this problem by removing the signatures from the transaction data, as the signatures were the primary source of malleability. Without the signatures, the transaction ID becomes more stable, providing a solid foundation for the development of second-layer protocols.

In addition to scalability and malleability improvements, SegWit also introduces a new transaction format that enables the implementation of future upgrades and enhancements. The new format uses a version number, allowing for backward compatibility and smooth integration of new features. This extensibility opens the door for further innovation and development within the cryptocurrency ecosystem, ensuring that the network can adapt to emerging needs and challenges.

Advantages

  • Increased Transaction Capacity - SegWit allows for more transactions to be included in a block by removing the signature data (witness) from the transaction block size calculation. This optimization effectively increases the block size, allowing more transactions within the same block. As a result, the network can handle a higher volume of transactions per second, improving scalability.
  • Transaction Fee Reduction - By separating the witness data, SegWit reduces the size of each transaction. As transaction fees are typically based on the size of the transaction, this results in lower fees for users. The decreased fees make microtransactions and smaller value transactions more feasible, promoting wider adoption and usability of cryptocurrencies.
  • Lightning Network Compatibility - SegWit's introduction was a crucial step in enabling the development of the Lightning Network, a layer-two scaling solution built on top of blockchain networks. The Lightning Network allows for near-instantaneous and low-cost transactions by creating payment channels between participants, reducing the load on the main blockchain. SegWit's transaction malleability fix was necessary for the secure implementation of the Lightning Network.
  • Enhanced Security - SegWit addresses the issue of transaction malleability, which refers to the ability to modify a transaction's unique identifier (hash) without changing its content. By removing the witness data from the transaction hash, SegWit prevents transaction malleability, improving the security of the network. This enhancement is particularly relevant for the development of smart contracts and second-layer protocols, as transaction malleability could lead to potential vulnerabilities.
  • Compatibility with Legacy Systems - One of the notable advantages of SegWit is its backward compatibility with older versions of cryptocurrency software. This means that users who have not upgraded to the latest version can still receive SegWit transactions. It allows for a smooth transition and wider adoption of the SegWit upgrade without requiring all participants to update their software simultaneously.

Disadvantages

  • Slow Adoption - While SegWit has been implemented in several blockchains, including Bitcoin, its adoption has been gradual. The upgrade requires participants, such as wallet providers and exchanges, to update software to support SegWit transactions fully. Due to the decentralized nature of cryptocurrencies, achieving widespread adoption can take time, and some participants may be hesitant to implement the necessary changes.
  • Increased Complexity - SegWit introduces additional complexity to the cryptocurrency protocol. The separation of witness data and transaction data adds a layer of intricacy that developers and users must understand and account for in their software. This complexity can make the development process more challenging and may require additional resources and expertise.
  • Reduced Block Space Efficiency for Non-SegWit Transactions - While SegWit optimizes block space for transactions using the new format, it does not have the same effect on non-SegWit transactions. As a result, blocks composed primarily of non-SegWit transactions may not fully utilize the available block space, leading to reduced efficiency. However, as SegWit adoption increases, the proportion of non-SegWit transactions is expected to decrease over time.
  • Potential Centralization of Witness Data - With SegWit, the witness data is stored outside the main transaction block. Some argue that this could potentially lead to centralization if a large portion of witness data is stored with a limited number of entities. However, it's important to note that witness data does not contain any critical transaction information and can be pruned without affecting the integrity of the blockchain.