Signature Hash Types

OP_CHECKSIG extracts a non-stack argument from each signaturesignature - A value related to a public key which could only have reasonably been created by someone who has the private key that created that public key. Used in Dash to authorize spending duffs previously sent to a public key. it evaluates, allowing the signer to decide which parts of the transactiontransaction - A transaction spending satoshis. to sign. Since the signature protects those parts of the transaction from modification, this lets signers selectively choose to let other people modify their transactions.

The various options for what to sign are called signature hashsignature hash - A flag to Dash signatures that indicates what parts of the transaction the signature signs. (The default is SIGHASH_ALL.) The unsigned parts of the transaction may be modified. types. There are three base SIGHASH types currently available:

  • SIGHASH_ALLSIGHASH_ALL - Default signature hash type which signs the entire transaction except any signature scripts, preventing modification of the signed parts., the default, signs all the inputsinputs - An input in a transaction which contains three fields: an outpoint, a signature script, and a sequence number. The outpoint references a previous output and the signature script allows spending it. and outputsoutputs - An output in a transaction which contains two fields: a value field for transferring zero or more duffs and a pubkey script for indicating what conditions must be fulfilled for those duffs to be further spent., protecting everything except the signature scripts against modification.

  • SIGHASH_NONESIGHASH_NONE - Signature hash type which only signs the inputs, allowing anyone to change the outputs however they'd like. signs all of the inputs but none of the outputs, allowing anyone to change where the duffsduffs - Denominations of Dash value, usually measured in fractions of a dash but sometimes measured in multiples of a duff. One dash equals 100,000,000 duffs. are going unless other signatures using other signature hash flags protect the outputs.

  • SIGHASH_SINGLESIGHASH_SINGLE - Signature hash type that signs the output corresponding to this input (the one with the same index value), this input, and any other inputs partially. Allows modification of other outputs and the sequence number of other inputs. the only output signed is the one corresponding to this input (the output with the same output index number as this input), ensuring nobody can change your part of the transaction but allowing other signers to change their part of the transaction. The corresponding output must exist or the value "1" will be signed, breaking the security scheme. This input, as well as other inputs, are included in the signature. The sequence numbers of other inputs are not included in the signature, and can be updated.

The base types can be modified with the SIGHASH_ANYONECANPAYSIGHASH_ANYONECANPAY - A signature hash type which signs only the current input. (anyone can pay) flag, creating three new combined types:

  • SIGHASH_ALL|SIGHASH_ANYONECANPAY signs all of the outputs but only this one input, and it also allows anyone to add or remove other inputs, so anyone can contribute additional duffs but they cannot change how many duffs are sent nor where they go.

  • SIGHASH_NONE|SIGHASH_ANYONECANPAY signs only this one input and allows anyone to add or remove other inputs or outputs, so anyone who gets a copy of this input can spend it however they'd like.

  • SIGHASH_SINGLE|SIGHASH_ANYONECANPAY signs this one input and its corresponding output. Allows anyone to add or remove other inputs.

Because each input is signed, a transaction with multiple inputs can have multiple signature hash types signing different parts of the transaction. For example, a single-input transaction signed with NONE could have its output changed by the miner who adds it to the block chain. On the other hand, if a two-input transaction has one input signed with NONE and one input signed with ALL, the ALL signer can choose where to spend the duffs without consulting the NONE signer---but nobody else can modify the transaction.

Did this page help you?