on
October2024 - BTC | What is a Witness in Signing Process
4 What is a Witness in Bitcoin Signing Process
In the context of Bitcoin, a “witness” refers to data that is used to prove the validity of a transaction but is not included in the transaction’s weight (size) for the purpose of transaction fees.
This concept was introduced with Segregated Witness (SegWit), which was a soft fork implemented to address transaction malleability and increase the block size limit. Here’s how it works:
-
Segregation of Data: SegWit separates the transaction signature (the witness data) from the transaction data itself. Before SegWit, both the transaction details and the signatures were part of the transaction’s input size, which affected the transaction’s size and thus its fee.
-
Witness Data: The witness data includes the scriptSig (transaction signatures) that proves the transaction is valid. This data is still included in the block but in a way that it doesn’t count towards the transaction’s size for fee calculation purposes.
-
Signing Process:
-
Transaction Creation: When creating a transaction, the sender specifies the inputs (previous transactions’ outputs they want to spend) and outputs (where the coins should go).
-
Signing: The sender signs the transaction with their private key. This signature proves ownership of the funds and is part of the witness data.
-
Transaction Propagation: The transaction, now including the witness data, is broadcast to the network. Nodes can choose to include or not include this witness data when relaying or mining transactions.
-
-
Verification with Witness: - When miners or full nodes validate a transaction, they check the witness data against the transaction’s scriptPubKey (the locking script) to ensure that the person spending the coins has the correct private key.
-
Block Size and Weight: - With SegWit, blocks have a new measurement called “weight” rather than just size. The witness data is given less weight, allowing blocks to contain more transaction data than before SegWit without increasing the block size limit in terms of bytes. The introduction of the witness in Bitcoin’s transaction structure has several benefits:
-
Scalability: By not counting the signature data in the transaction’s size for fee purposes, more transactions can fit into a block.
-
Transaction Malleability Fix: This made it harder for transactions to be altered in a way that could affect second-layer technologies like the Lightning Network.
-
In summary, in Bitcoin’s signing process, the “witness” is essentially the signature data separated by SegWit, which allows for more efficient use of block space and fixes issues related to transaction malleability.