What Is Segregated Witness (SegWit) And How Does It Work?

Read this blog in 中文, Indonesian, ΕΛΛΗΝΙΚΑ, Russian, Vietnamese, Türkçe, and हिंदी.

Despite the enthusiasm of Bitcoin Maximalists who view bitcoin as perfect from the start, the original blockchain design was not without flaws.

Among the most significant challenges were transaction scalability and mutability. These were the largest obstacles to bitcoin realizing its potential as a global currency and which hindered its broader application.

Transaction scalability refers to the amount of transactions bitcoin can process. Bitcoin was programmed to settle 1 mb of transactions about every 10 minutes. This comes out to about 4.6 transactions per second. Compared to Visa however, which processes about 1,700 transactions per second, the scalability issues hindering bitcoin from becoming a more widely used currency is clear.

Transaction mutability is the ability to alter a transaction ID before it is confirmed on the blockchain. This means that malicious actors could invalidate the next transaction a receiver makes. This feature of bitcoin makes building Layer 2 solutions difficult, as the second layer relies upon the consistency of the base layer.

SegWit not only helps alleviate these two issues with the original bitcoin network, but its solution also opens up an entirely new world of use cases for bitcoin.

This article will detail the history, inner workings, and impact of SegWit on the world of bitcoin.

History Of SegWit

SegWit was a proposal made by Dr. Pieter Wuille in December 2015 that suggested reformatting the composition of a bitcoin transaction.

A bitcoin transaction is a combination of the sender’s address, the receiver’s address, and a digital signature that verifies the sender owns the needed bitcoin.

Dr. Wuille proposed “segregating” the signature data, aka witness data, from the main transaction. This is where SegWit gets its name, segregating the witness data.

This upgrade is an ingenious way to store more transactions inside bitcoin’s 1-megabyte block size limit. Here’s how it’s done.

How Segwit Works

SegWit moves the signature/witness data outside the base transaction to its own separate structure. This data is still transmitted, but only as an attachment at the end of the transaction.

Leaving the witness data empty in the base transaction allows more transactions in the leftover space without exceeding the original 1mb limit.

Segwit is able to do this by introducing a new transaction format that is backwards-compatible with the original format. The new block format includes a 3 mb block extension, the new witness data location. This reformatting means that the block size becomes 4 mb while the base transaction is still just 1 mb.

When a SegWit transaction is broadcast, nodes that have upgraded to support SegWit recognize the new format and can process the transaction with witness data separately. No need for a hard fork, as the base transaction size is exactly the same.

Block Weight Versus Block Size

Given bitcoin’s decentralized nature, it might sound odd that an upgrade can come around and fundamentally change the block size of the bitcoin network. Part of the way SegWit does this is simply by redefining block capacity.

SegWit introduces a concept called “block weight,” calculated using the formula:

Block Weight = (Base Transaction Size * 3) + Total Transaction Size

Base Transaction Size: This refers to the transaction size without the witness data.

Total Transaction Size: This includes both the base transaction and the witness data.

Each block has a maximum weight of 4 million weight units, equivalent to the previous 1 mb size limit in terms of the old definition of block size.

What Segwit Directly Solves

The Segwit upgrade sought to alleviate transaction scalability and mutability issues, and was a great success by all accounts.

For scalability, the initial effect is obvious; by increasing the number of transactions per block, more transactions could be processed per second. This helps reduce congestion, enabling faster transaction processing and lower fees, especially when network activity surges.

SegWit solves transaction mutability in the same way. By separating the witness data from the transaction data, the transaction ID remains unchanged even if the witness data is altered. This protects the transaction ID from malicious tampering and ensures Layer 2 solutions have a secure, immutable base layer.

Although SegWit successfully fixes the core issues it was proposed for, its ultimate impact was far greater than Dr. Wuille could have ever expected.

A Snowball Effect

SegWit resulted in a series of interlocking and mutually dependent developments that ultimately transformed the face of the bitcoin ecosystem. The most important achievements resulting from SegWit are the advent of Bitcoin Layer 2 solutions, smart contracts on bitcoin, the Taproot upgrade, and Ordinals.

Layer 2 Solutions

Layer 2 solutions require stable transaction IDs to create secure additional layers. Segwit gives bitcoin this crucial property by eliminating transaction malleability.

A great example of this is the Lighting Network, the most significant Layer 2 that bloomed after SegWit. The Lightning Network relies on the creation of payment channels that allow users to conduct multiple transactions off-chain, with only the final state being recorded on the blockchain. With SegWit-enabled transactions, these payment channels can be securely managed without the risk of transaction malleability affecting the channel’s integrity.

All other Layer 2s, such as Stacks, Liquid Networks, Rootstock, and more, require the same stability in the base layer for their various operations.

Smart Contracts

Smart contracts are computer programs built on a blockchain that automatically execute a set of rules. Smart contracts are the essential infrastructure powering the entire decentralized economy: All its platforms, tools, and organizations run on these programs.

Although bitcoin’s scripting language is not as advanced as those of some other blockchain platforms, SegWit enhances its capabilities in several ways that allow for smart contracts:

  • Layer 2 solutions: Layer 2s can use their increased throughput and programmability to add smart contracts to bitcoin themselves. For example, Rootstock and Stacks are Layer 2 solutions that support smart contract execution, enabling the development of a decentralized infrastructure on bitcoin.
  • Script versioning: SegWit introduces the script versioning concept, allowing new features and upgrades to be added to the bitcoin scripting language without requiring a hard fork.
  • Block space: More space is available in each block, which means larger smart contracts can be executed. This is especially beneficial for smart contracts that require a lot of data to be processed.

Taproot

Taproot is an upgrade to the bitcoin protocol that builds on SegWit signatures to improve privacy and efficiency. Taproot allows all participants in a transaction to agree on a single public key and signature.

Taproot reduces the size of these transactions, making them cheaper and faster to process. SegWit’s improvements in transaction structure and script versioning made the Taproot upgrade possible without needing a hard fork.

Ordinals

Ordinals are a numbering system applied to individual satoshis (aka sats, the smallest unit of bitcoin). Like a serial number, each sat has a unique ordinal number. This number is an individual identifier for each satoshi based on when it was mined.

In principle, this numbering system is all that is needed to make sats nonfungible. Every sat is unique and identifiable through its individual number. Once the satoshi is connected to external media, it can function as an NFT. This is where SegWit comes in.

The SegWit upgrade means users can store more data inside bitcoin’s 1-megabyte block size via the new witness data structure. The introduction of this arbitrary data is what helps enable Ordinals; now, full pieces of media can be added in as additional arbitrary data with the bitcoin transaction. Once a piece of media is attached to a bitcoin transaction with a single satoshi, this data is forever linked to that satoshi.

Even if this interaction with satoshis was possible after SegWit, it was impractical due to the speed and efficiency of making such transactions. Taproot solved this problem, and soon after this upgrade, bitcoin NFTs were born.

The Legacy Of SegWit

The implementation of SegWit has been instrumental in addressing significant challenges to bitcoin’s growth and functionality. In essence, SegWit has resolved foundational technical challenges and catalyzed a wave of innovation, expanding bitcoin’s capabilities and securing its place as a versatile foundation for the future decentralized world.

As bitcoin continues to evolve, the success of SegWit will undoubtedly shape the possibility of additional upgrades and be a symbol of how bitcoin can address seeming limitations.

More fromLorenzo academy

December 10, 2024
Bitcoin - Core Concepts

What Is Bitcoin Mining?

Bitcoin mining is the engine driving the world’s largest decentralized financial network. But how does it work, and why does it matter? This article dives into the intricate process of mining, detailing how miners validate transactions, secure the blockchain, and introduce new bitcoin into circulation. From the evolution of mining hardware to its environmental controversies, we explore the pivotal role mining plays in Bitcoin’s ecosystem and its implications for the future of global finance.

December 7, 2024
Bitcoin - DeFi

Bitcoin & The Move Ecosystem: An Overview Of Key Players And Implications

Dive into the groundbreaking convergence of the Move ecosystem and Bitcoin DeFi.

December 6, 2024
Bitcoin - Core Concepts

Who Owns The Most Bitcoin? View The Biggest Whales

An overview of the world's top Bitcoin holders, spanning individuals, companies, and countries.