Witness
In the context of Bitcoin, the "witness" refers to part of a SegWit (Segregated Witness) transaction that holds the input signatures and scripts needed to spend SegWit outputs. Unlike legacy transactions, where this unlocking data (called the ScriptSig) sits inside the main transaction data, SegWit moves it into the witness section. This witness region is not included in the transaction’s hash (txid), helping prevent transaction malleability, a problem where transaction IDs could be altered by tweaking the unlocking data.
For SegWit transactions, the ScriptSig is left empty because all necessary spending information is provided in the witness. Every Bitcoin node that supports SegWit saves witness data alongside each transaction. However, witness data is specially discounted when figuring out block size—while regular transaction bytes are worth 4 weight units each, witness bytes count as just 1. This means SegWit transactions are more efficient, making it cheaper to spend SegWit outputs and effectively lifting the block size limit from 1MB up to about 4MB.
To guarantee that the witness data can't be changed after a transaction is finalized in a block, a separate transaction ID based on the witness—called the wtxid—is used. The wtxids of all SegWit transactions in a block are organized into a Merkle tree, similar to legacy transactions. The root of this witness Merkle tree is stored in the scriptPubKey of an extra coinbase output using OP_RETURN, providing a cryptographic commitment to all witness data in the block.