KEMBAR78
Introduction to Segwit | PDF
Introduction to
Segregated Witness
By Priyab Satoshi (@twitmyreview)
Agenda
• Bitcoin transactions
• The scaling debate
• Segwit - Segregated Witness
• Benefit from SegWit
• Bitcoin Improvement Proposals
Bitcoin Transactions
• A bitcoin transaction is data that describes the
movement of bitcoins.It is basically a series of
inputs and a series of outputs.
Bitcoin Transaction Structure
• The transaction data tells you how to unlock
existing packages of bitcoins (from previous
transactions), and how to lock them up again
Block Limit
• Originally, there was no limit to the size of blocks
• This allowed malicious actors to make up fake
"block" data and do DDOS Attacks
• The solution Satoshi Nakamoto designed was to
put a limit on block size, which was 1 MB.
• Attacks using huge blocks would be instantly
detected and rejected, without significantly
slowing down the network.
Block Structure
Scalability and Malleability
• A new block is added to the chain at random intervals
averaging, by design, ten minutes (proof-of-work
causes this delay). Miners can only add transactions
within these limits
• With the limit on block-size, this limits the number of
transactions that can be processed in a given time.
• Transaction malleability: Cryptographically signed
signature doesn't encompass all transaction data
several different ways of losing or stealing bitcoins are
possible.
Scalability and Malleability
• 60% - 70% of the transaction size is the
signature. This not only creates transaction bloat
but also creates malleability issues.
Scalability Problem
• As transactions increase and become data-
heavy, it clogs the blocks, which bogs down the
network when demand is high. This becomes an
increasing issue as more people start using
Bitcoin and adopt the technology. In order for
the Bitcoin to succeed and be useful, a solution
to process the blocks faster is necessary.
The Scaling Debate
Solutions to the scaleability problem
• Segwit (e.g. BTC)
• Increase the block size (e.g BCC)
• The Lightning Network
Segregated Witness
(SegWit)
• It was locked in on 8th of August. Two weeks to
signal support
• August 24th 2017 Segwit Activated on Block 481,824
• Aims to speed up Bitcoin confirmation of Bitcoin
transactions
• It also moves signatures out of the transaction
addressing the malleability problem. This will make it
safer to use with the Lightning Network.
SegWit Timeline
SegWit Support
What is Segwit?
• The proposal is to move all of the unlocking code to the
end of the transaction data. The TXID is then created from
all of the transaction data, except for the unlocking code.
• The TXID is only influenced by the effects of a transaction
(the movement of bitcoins), and not by any code needed
to validate the transaction (i.e. signatures used to unlock
existing bitcoins so that they can be spent).
• We separated the "validating" part (unlocking code) from
the "effective" part of the transaction.
Segwit vs Non SegWit
Transaction
Segwit Block Size
SegWit Adoption
How to Use SegWit
• Install a SegWit-supporting wallet.
• Receive money on new SegWit addresses, which start with 3. You must
generate new addresses; your old addresses will never be SegWit addresses.
Note that not all addresses starting with 3 are SegWit addresses, and it is
impossible to tell just from looking at an address whether it is a SegWit
address.
• Whenever you spend BTC which you have received via SegWit addresses,
you will receive the SegWit discount. If you send a transaction spending some
BTC received via non-SegWit addresses and some BTC received via SegWit
addresses, you will receive a partial discount. The destination address doesn't
matter.
• There are no compatibility issues: non-SegWit wallets can send BTC to SegWit
addresses, and SegWit wallets can send BTC to non-SegWit addresses.
Saving Transaction Fee
using Segwit 
• For segwit, a new concept called weight was introduced, so what matters now is fee / (virtual
size) .
• Here are the transaction ids for reference — Normal, Segwit in P2SH, Native Segwit. As you
can see you can get a cool 38% discount using native segwit !!
• You save on transaction fee and you transaction is smaller taking less space. This allows more
transactions to get into blocks. This reduces mempool congestion and decreases the average
transaction fee, because you are now competing with less unconfirmed tx to get into blocks
Segwit Address
• Originally proposed by Satoshi Nakamoto, legacy addresses of Bitcoin are
simple addresses that start with the digit
‘1’ (1Nh7uHdvY6fNwtQtM1G5EZAFPLC33B59rB).
• Activation of segwit simply means that you have new address formats
available on Bitcoin’s blockchain which are called multi-signature (P2SH)
addresses starting with the digit
‘3’ (3JxDR5iheVDMZP88tiFrtY4bw9UBZwTMcc).
• Benefits that you can enjoy by using segwit addresses.

- Signature Time Optimization up to 60%

- Reduction In Transaction Fees up to 40%

- Future Scaling Optimizations Such As Lightning Networks
• To upgrade to segwit, it is simple as sending a transaction from a Non-
Segwit address to a Segwit Adress.
Benefits of SegWit
• First, by improving efficiency, it enables transactions to be
confirmed faster. As a result of that, it will also potentially reduce the
relatively higher transaction fees that were an offshoot of the
increased demand.
• SegWit laid the groundwork for a “Lightning Network”, where
transactions are faster, cheaper, and more scalable. It also opens
up payment channels that move transactions off the main
blockchain, and some developers have already worked on this
technology.
• Because the witness structure contains Script versioning, it is also
possible to make changes to or introduce new opcodes to SegWit
scripts that would have originally required a hardfork to function
without SegWit.
Bitcoin Improvement
Proposal
• BIP141 Segregated Witness (Consensus layer) – activated on August 24,
2017
• BIP142 Address Format for Segregated Witness – withdrawn, superseded
by BIP 173
• BIP143 Transaction Signature Verification for Version 0 Witness Program [1]
– activated on August 24, 2017
• BIP144 Segregated Witness (Peer Services) – activated on August 24, 2017
• BIP148 Mandatory activation of segwit deployment – activated (mandated
the activation of BIP141, 143, 144)
• BIP173 Bech32 addresses, released as part of Bitcoin Core version 0.16.0
in February 2018.[31]
Useful Reference
• https://www.reddit.com/r/indiacryptogrp/comments/84lcba/
introduction_to_segregated_witness_online_event/
• https://bitcoincore.org/en/2016/01/26/segwit-benefits/
• https://bitcoincore.org/en/segwit_wallet_dev/
• https://bitcoincore.org/en/2016/10/27/segwit-upgrade-guide/
• https://bitcoincore.org/en/2016/10/28/segwit-costs/
• https://www.youtube.com/watch?v=QYZv92F2kCw - Segwit explained
• https://www.youtube.com/watch?v=M_GmiapVJAQ - Bitcoin Scaling
Explained: Big Blocks vs. SegWit
Thank You

Introduction to Segwit

  • 1.
    Introduction to Segregated Witness ByPriyab Satoshi (@twitmyreview)
  • 2.
    Agenda • Bitcoin transactions •The scaling debate • Segwit - Segregated Witness • Benefit from SegWit • Bitcoin Improvement Proposals
  • 3.
    Bitcoin Transactions • Abitcoin transaction is data that describes the movement of bitcoins.It is basically a series of inputs and a series of outputs.
  • 4.
    Bitcoin Transaction Structure •The transaction data tells you how to unlock existing packages of bitcoins (from previous transactions), and how to lock them up again
  • 5.
    Block Limit • Originally,there was no limit to the size of blocks • This allowed malicious actors to make up fake "block" data and do DDOS Attacks • The solution Satoshi Nakamoto designed was to put a limit on block size, which was 1 MB. • Attacks using huge blocks would be instantly detected and rejected, without significantly slowing down the network.
  • 6.
  • 7.
    Scalability and Malleability •A new block is added to the chain at random intervals averaging, by design, ten minutes (proof-of-work causes this delay). Miners can only add transactions within these limits • With the limit on block-size, this limits the number of transactions that can be processed in a given time. • Transaction malleability: Cryptographically signed signature doesn't encompass all transaction data several different ways of losing or stealing bitcoins are possible.
  • 8.
    Scalability and Malleability •60% - 70% of the transaction size is the signature. This not only creates transaction bloat but also creates malleability issues.
  • 9.
    Scalability Problem • Astransactions increase and become data- heavy, it clogs the blocks, which bogs down the network when demand is high. This becomes an increasing issue as more people start using Bitcoin and adopt the technology. In order for the Bitcoin to succeed and be useful, a solution to process the blocks faster is necessary.
  • 10.
    The Scaling Debate Solutionsto the scaleability problem • Segwit (e.g. BTC) • Increase the block size (e.g BCC) • The Lightning Network
  • 11.
    Segregated Witness (SegWit) • Itwas locked in on 8th of August. Two weeks to signal support • August 24th 2017 Segwit Activated on Block 481,824 • Aims to speed up Bitcoin confirmation of Bitcoin transactions • It also moves signatures out of the transaction addressing the malleability problem. This will make it safer to use with the Lightning Network.
  • 12.
  • 13.
  • 14.
    What is Segwit? •The proposal is to move all of the unlocking code to the end of the transaction data. The TXID is then created from all of the transaction data, except for the unlocking code. • The TXID is only influenced by the effects of a transaction (the movement of bitcoins), and not by any code needed to validate the transaction (i.e. signatures used to unlock existing bitcoins so that they can be spent). • We separated the "validating" part (unlocking code) from the "effective" part of the transaction.
  • 15.
    Segwit vs NonSegWit Transaction
  • 16.
  • 17.
  • 18.
    How to UseSegWit • Install a SegWit-supporting wallet. • Receive money on new SegWit addresses, which start with 3. You must generate new addresses; your old addresses will never be SegWit addresses. Note that not all addresses starting with 3 are SegWit addresses, and it is impossible to tell just from looking at an address whether it is a SegWit address. • Whenever you spend BTC which you have received via SegWit addresses, you will receive the SegWit discount. If you send a transaction spending some BTC received via non-SegWit addresses and some BTC received via SegWit addresses, you will receive a partial discount. The destination address doesn't matter. • There are no compatibility issues: non-SegWit wallets can send BTC to SegWit addresses, and SegWit wallets can send BTC to non-SegWit addresses.
  • 19.
    Saving Transaction Fee usingSegwit  • For segwit, a new concept called weight was introduced, so what matters now is fee / (virtual size) . • Here are the transaction ids for reference — Normal, Segwit in P2SH, Native Segwit. As you can see you can get a cool 38% discount using native segwit !! • You save on transaction fee and you transaction is smaller taking less space. This allows more transactions to get into blocks. This reduces mempool congestion and decreases the average transaction fee, because you are now competing with less unconfirmed tx to get into blocks
  • 20.
    Segwit Address • Originallyproposed by Satoshi Nakamoto, legacy addresses of Bitcoin are simple addresses that start with the digit ‘1’ (1Nh7uHdvY6fNwtQtM1G5EZAFPLC33B59rB). • Activation of segwit simply means that you have new address formats available on Bitcoin’s blockchain which are called multi-signature (P2SH) addresses starting with the digit ‘3’ (3JxDR5iheVDMZP88tiFrtY4bw9UBZwTMcc). • Benefits that you can enjoy by using segwit addresses.
 - Signature Time Optimization up to 60%
 - Reduction In Transaction Fees up to 40%
 - Future Scaling Optimizations Such As Lightning Networks • To upgrade to segwit, it is simple as sending a transaction from a Non- Segwit address to a Segwit Adress.
  • 21.
    Benefits of SegWit •First, by improving efficiency, it enables transactions to be confirmed faster. As a result of that, it will also potentially reduce the relatively higher transaction fees that were an offshoot of the increased demand. • SegWit laid the groundwork for a “Lightning Network”, where transactions are faster, cheaper, and more scalable. It also opens up payment channels that move transactions off the main blockchain, and some developers have already worked on this technology. • Because the witness structure contains Script versioning, it is also possible to make changes to or introduce new opcodes to SegWit scripts that would have originally required a hardfork to function without SegWit.
  • 22.
    Bitcoin Improvement Proposal • BIP141Segregated Witness (Consensus layer) – activated on August 24, 2017 • BIP142 Address Format for Segregated Witness – withdrawn, superseded by BIP 173 • BIP143 Transaction Signature Verification for Version 0 Witness Program [1] – activated on August 24, 2017 • BIP144 Segregated Witness (Peer Services) – activated on August 24, 2017 • BIP148 Mandatory activation of segwit deployment – activated (mandated the activation of BIP141, 143, 144) • BIP173 Bech32 addresses, released as part of Bitcoin Core version 0.16.0 in February 2018.[31]
  • 23.
    Useful Reference • https://www.reddit.com/r/indiacryptogrp/comments/84lcba/ introduction_to_segregated_witness_online_event/ •https://bitcoincore.org/en/2016/01/26/segwit-benefits/ • https://bitcoincore.org/en/segwit_wallet_dev/ • https://bitcoincore.org/en/2016/10/27/segwit-upgrade-guide/ • https://bitcoincore.org/en/2016/10/28/segwit-costs/ • https://www.youtube.com/watch?v=QYZv92F2kCw - Segwit explained • https://www.youtube.com/watch?v=M_GmiapVJAQ - Bitcoin Scaling Explained: Big Blocks vs. SegWit
  • 24.