Segregated Witness, or SegWit, is the name used for an implemented soft fork change in the transaction format of Bitcoin.

The formal title "Segregated Witness (Consensus layer)" had Bitcoin Improvement Proposal number BIP141. The declared purpose was to prevent nonintentional bitcoin transaction malleability, allow optional data transmission, and to bypass certain protocol restrictions (such as the block size limit) with a soft fork.

SegWit

It was also intended to mitigate a blockchain size limitation problem that reduces bitcoin transaction speed. It does this by splitting the transaction into two segments, removing the unlocking signature ("witness" data) from the original portion and appending it as a separate structure at the end. The original section would continue to hold the sender and receiver data, and the new "witness" structure would contain scripts and signatures. The original data segment would be counted normally, but the "witness" segment would, in effect, be counted as a quarter of its real size.

SegWit

History

Block size limit

Bitcoin is a cryptocurrency, a form of currency using cryptography to keep transactions secure. A collection of bitcoin transactions prefaced by a block header, protected by proof of work, and recorded on a network of computers is called a "block". All blocks are tied together sequentially by using a cryptographic hash on the previous block and storing its output in the next. This forms a blockchain.

SegWit

Each block contains information about who sends and receives a given unit of bitcoin (a transaction), as well as the signature(s) that approves each transaction. Originally, there was no limit to the size of blocks. However, this allowed malicious actors to make up fake "block" data that was very long as a form of denial-of-service attack (DoS attack). These fake blocks would be detected, but doing so would take a very long time, slowing down the whole system. Therefore, a block size limit of 1 MB was introduced.

Scalability and malleability

The current bitcoin blockchain design is regarded as having two shortcomings.

Scalability

A new block is added to the chain at random intervals averaging, by design, ten minutes (proof of work causes this delay). Together with the limit on block-size, this limits the number of transactions that can be processed in a given time. Some sites work around this problem using "off-chain payments" conducting transactions without writing them to the blockchain, which involves various trade offs regarding trust and transaction finality. Others have proposed changes to bitcoin that would reform the block format in a backward-incompatible way. For example, FlexTrans (Flexible Transactions) would make transactions smaller by changing how they are described to a "tag" system, allowing more transactions per block. This is not compatible with systems that do not upgrade.

Malleability

A transaction uses unused outputs from a previous transaction(s) known as unspent transaction outputs (UTXO). This results in a chain of related transactions linked by their transaction identifier. However, it is possible for someone to change (mutate) unconfirmed bitcoin transactions without making them invalid, which changes the transaction's identifier, making child transactions invalid (i.e., link between transactions are broken).

Segregated Witnesses as a solution

The signature data called the witness would be separated from the Merkle tree record of who is sending or receiving the bitcoins. The witness data is moved to the end, and each byte of it would only count as one quarter of a "unit".

It also addresses signature malleability, by serializing signatures separately from the rest of the transaction data, so that the transaction ID is no longer malleable.

Activation

On 21 July 2017, bitcoin miners locked-in a software upgrade referred to as Bitcoin Improvement Proposal (BIP) 91, meaning that the Segregated Witness upgrade activated at block 477,120.

SegWit alleviates the scaling problem in two ways: SegWit solves Transaction Malleability, thereby enabling the Lightning Network, an overlay network of micropayment channels, hypothetically resolving the scaling problem by enabling virtually unlimited numbers of instant, low-fee transactions to occur "off chain".

By 8 August, another milestone was reached when 100% of the bitcoin mining pools signaled support for SegWit, although SegWit would not be fully activated until 21 August at the earliest, after which miners would begin rejecting blocks that do not support SegWit.

Initially, most bitcoin transactions have not been able to use the upgrade.