What is Segregated Witness (SEGWIT)?
In Segregated Witness (SegWit), transaction data is protected against malleability, and block capacity is maximized. Witnesses are separated from inputs by SegWit. A witness contains data needed to check the validity of a transaction but is not required to determine the effect of a transaction. Moreover, the block weight parameter has been specified, and the maximum number of weight units (WU) per block is set to 4 million. In non-wound and pre-segwit blocks, each byte of witness data weighs 4 WU, but for Segwit blocks, each byte weighs only 1 WU, allowing larger blocks without the need to hardfork.
It took SegWit as the last protocol change for the Lightning Network deployment on the Bitcoin network to become safe. OP_CLTV and OP_CSV had already been activated successfully.
Since the new witness field facilitates Script versioning, SegWit scripts that would otherwise require additional complexity are also able to be modified or introduced with new opcodes while maintaining the same functionality.
History of Segregated Witness (SEGWIT):
In 2015, Pieter Wuille introduced the idea of SegWit at a bitcoin conference. Besides developing Bitcoin, Wille is co-founder of Blockstream, an organization specializing in digital security for financial services.
In response to a flaw in the Bitcoin protocol, Wuille proposed SegWit. Fixes for flaws in software are called patches. He was attempting to solve the problem of transaction malleability. Simply put, transaction malleability refers to the possibility of altering and stealing data related to transactions.
SegWit was nearly two years in the making when Willem’s proposal was first announced and there was fierce debate among Bitcoiners. August 23, 2017, marked the official activation of the system. Litecoin’s protocol was patched on May 10, 2017.
Apart from resolving the malleability issue, SegWit also made Bitcoin better in other ways. There are still many critics of the Bitcoin network and not all users are pleased with the changes. Several members of the bitcoin community are so opposed to SegWit that they’ve developed their cryptocurrencies to compete with it
SegWit: what are its advantages?
Most Bitcoin-based services have adopted SegWit, a feature of the Bitcoin protocol. You can easily find out whether an exchange supports SegWit transactions by conducting a simple Google search. SegWit, however, offers benefits beyond simply reducing blocks sizes and increasing network speed.Â
Segregated Witness is a critical step towards scaling Bitcoin and several other major crypto networks. SegWit paved the way for mainstream adoption of blockchain networks, directly and indirectly, thanks to the ability to scale blockchain networks.Â
SegWit has downsides, but what are they?
Although the adoption of SegWit transactions, which are currently 65% on the Bitcoin network, is rising, they will naturally take longer to adapt due to the sheer importance and size of Bitcoin. Even today, not everyone supports SegWit transactions.Â
Since the beginning of 2017, multiple hard forks of the Bitcoin blockchain have been caused by the continuous scaling debate. A hard fork of Bitcoin Cash occurred in August 2017, and this was the largest of them. The block size limit increased from 1MB to 8MB on 15 November 2018.Â
Fixing transaction malleability
It was possible to tamper with the signatures of Bitcoin transactions, and this proved to be a major problem. The alteration of a signature could corrupt a transaction between two parties. Due to the immutability of blockchain data, invalid transactions could be permanently stored on a blockchain.
 The SegWit standard removes signatures from transaction data, making it impossible to alter this information. The blockchain community has been able to innovate further with second-layer protocols and smart contracts thanks to this fix.
Using Segregated witness (SegWit) to fix transaction malleability
Transactions can be malleated in two ways. ScriptSig is a part of the transaction that holds the signature and other information necessary to unlock the bitcoin, and it can be further modified after a transaction is signed. A second change is that the signature itself can be changed, which is contained within the ScriptSig. Both possibilities are possible when a signature can be made immutable and signed. ScriptSigs and signatures it contains constitute part of the preimage of the TxID, so if they change, the TxID will also change.
In SegWit, all information from the ScriptSig is removed, so this possibility is eliminated. A SegWit transaction is not hashed to calculate its txid, but ScriptSig data-such as signatures and public keys-is moved to the Witness. SegWit ScriptSig inputs become immutable after they are signed; on the other hand, bitcoin’s Witness contains all of the data needed to unlock it, which is not immutable. Since the ScriptSig cannot be modified, no modification of the transaction ID can be performed without invalidating the entire transaction.
 Segregated Witness and Lightning Network
 The second-layer protocols were developed after the transaction malleability bug was fixed. As another way to put it, a second-layer protocol is a product or platform built on top of blockchain technology. The second-layer micropayment network that runs off-chain is the Lightning Network.
The Lightning Network is a peer-to-peer network layered on top of the Bitcoin network. In general, the Lightning Network allows more transactions to be confirmed faster so that users can transact faster. Bitcoin network eventually processes transactions collected off-chain.
Lightning Network was originally based on Bitcoin. However, some cryptocurrency and blockchain projects are in the process of implementing the technology on their platforms. The scalability problem can be solved by avoiding confirmation time transactions as well as developing new scalable solutions.