Understanding Bitcoin SIGHASH Types and Their Applications
Bitcoin, a decentralized cryptocurrency, relies on various cryptographic techniques to ensure secure and transparent transactions. One of the key aspects of these transactions is the use of Sign Hash (SIGHASH) types, which are used to verify input scripts in the Bitcoin context.
In this article, we will delve into the world of SIGHASH types, their significance in the Bitcoin transaction verification process, and provide guidance on how to determine which type to add to the end of a truncated transaction during input script verification.
SIGHASH Types
Bitcoin transactions are divided into two categories: signed and unsigned. Signed transactions contain signed scripts using Sign Hash (SIGHASH) types, while unsigned transactions do not contain any script signatures.
The primary SIGHASH types used in Bitcoin transactions are:
- SIGHASH zero: This type indicates that the transaction is not signed.
- SIGHASH one: This type allows for input script validation, allowing a miner to verify the contents of the transaction.
- SIGHASH three: Similar to SIGHASH one, but with a larger block size limit.
Trimmed Transactions and Input Script Verification
During input script validation, a truncated transaction goes through several stages before being verified by a miner:
- Verification: The truncated transaction is checked for errors or invalid data.
- Input script verification: If the truncated transaction has input scripts, they are verified using SIGHASH types.
When determining which type of SIGHASH to append to the end of a truncated transaction during verification, we must consider the following factors:
- Transaction signature: The presence and content of the transaction signature (also known as a “SIGHASH zero” signature) will indicate whether input scripts are allowed.
- Input scripts

: If input scripts are present in the transaction, they are verified with SIGHASH one. To verify input scripts, the miner must have the corresponding private key for each script.
- Block size limit: The maximum block size limit set by the network (currently 2 MB) will determine which type of SIGHASH is allowed.
Example: Understanding a Sample Transaction
Let’s examine an example transaction:
{
"version": 2,
"txid": "abcdef123",
"vout": [1, 2],
"locktime": 100,000,
"commitments": 10
}
In this case:
- The
version' field (2) indicates an unsigned transaction.
- Thetxid
,vout, andlocktimefields are present, indicating that input scripts are allowed.
- Thecommitments’ field (10) also confirms that the transaction is valid.
To determine which type of SIGHASH to append to the end of this truncated transaction during verification:
- Check that the transaction signature is a “SIGHASH zero” signature (i.e., not signed). In this case, we assume that the transaction is indeed unsigned.
- Verify the presence and content of the input scripts by examining the
voutfield.
Based on our analysis, since the transaction contains input scripts (the vout field), we should append one SIGHASH to allow for verification of the input scripts during verification.
Conclusion
In conclusion, determining which type of SIGHASH to append to the end of a truncated transaction during verification of input scripts in Bitcoin involves considering various factors, including the presence and content of the transaction signature, input script verification, and block size limits. By understanding these concepts, you will be able to ensure that secure and transparent transactions are conducted on the Bitcoin network.
Be sure to read the official documentation for more detailed information on SIGHASH types, transaction verification processes, and other relevant Bitcoin-related topics.