Sighash Flag
A signature hash (sighash) flag is a small part of each input in a transaction that determines which parts of the transaction become immutable once a signature has been added to the transaction.
A signature hash (sighash) flag is a small part of each input in a transaction that determines which parts of the transaction become immutable once a signature has been added to the transaction. A signature signs a hash of data, and thus a signature commits to an exact form of a piece of data. If the data is changed after the signature is created, the signature is invalidated.
Thus, a signature is a commitment to a certain piece of data. In this case, that data is a Bitcoin transaction, and the sighash flag determines what data within the transaction committed to. Almost all transactions use the sighash flag SIGHASH\_ALL, meaning that each input’s signature is only valid if all other inputs and outputs remain unchanged.
Other sighash flags allow an input signature to remain valid even if other inputs or outputs are altered. Within a transaction, each input requires its own signature and thus its own sighash flag. This means that inputs can be constructed flexibly.
When multiple parties contribute inputs to a certain transaction, they may only care about their own specific outputs. For example, if Alice contributes 1 BTC to a transaction and expects 1.2 BTC in return, she likely only cares that her output of 1.2 BTC is guaranteed upon signing. In this case, Alice could use the sighash flag SIGHASH\_SINGLE.
This flag commits to all inputs, but only a single output. This would allow the other parties to the transaction to add and alter their outputs as desired, so long as they do not alter Alice’s output of 1.2 BTC. Alternatively, in the rare case that a party to a transaction does not care what any of the outputs are, they may use the sighash flag SIGHASH\_NONE, which commits to all inputs but no outputs.
Lastly, the sighash flag SIGHASH\_ANYONECANPAY ensures that only the input at hand is signed, whereas the other three sighash flags alone ensure that all inputs are signed. This sighash flag can be combined with any of other sighash flag in order to control which outputs and which inputs are signed. In the future, more sighash flags may be added to the Bitcoin protocol, enabling more flexible use cases, but for now, only the four mentioned above are considered valid.
Sighash Flag is a Bitcoin protocol specification that defines technical standards for how Bitcoin software operates. Onramp's Bitcoin glossary provides detailed educational resources on Sighash Flag and other protocol-level concepts to help investors understand the technology underpinning their Bitcoin holdings.
Frequently Asked Questions
What is Sighash Flag?
Sighash Flag is a technical standard in the Bitcoin protocol that specifies how certain operations or data structures should be implemented. It helps ensure interoperability between different Bitcoin software implementations.
Why is Sighash Flag important for Bitcoin?
Sighash Flag improves Bitcoin's functionality, security, or efficiency. Technical standards like this ensure that all participants in the Bitcoin network follow consistent rules, maintaining network consensus.
How does Sighash Flag affect Bitcoin investors?
While Sighash Flag operates at the protocol level, Onramp ensures that clients benefit from these technical improvements through secure, up-to-date infrastructure for Bitcoin custody and transactions.
