You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/taproot-sighash.mediawiki
+9-7Lines changed: 9 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,6 +15,8 @@ The parameter ''hash_type'' is an 8-bit unsigned value. The <code>SIGHASH</code>
15
15
16
16
'''''NEW''''' If the input under consideration is a pegin input, the fields ''nAsset'', ''nValue'' and ''scriptPubKey'', where they appear, are taken from the pegin witness data. The asset used is the asset ID on the sidechain, not that on the parent chain (if any).
17
17
18
+
'''''NEW''''' The fields ''nNonce'', ''nAsset'' and ''nValue'' are serialized in a fixed-length format, which consists of their ordinary 1/9/33 byte encoding followed by sufficiently many 0 to pad the length out to 33. When we refer to ''extended <code>CTxOut</code> format'' below, we mean the fields ''nAsset'', ''nValue'', ''nNonce'' serialized in that order in fixed-length format, followed by the ordinary length-prefixed ''scriptPubKey''.
19
+
18
20
The parameter ''ext_flag'' is an integer in range 0-127, and is used for indicating (in the message) that extensions are added at the end of the message<ref>'''What extensions use the ''ext_flag'' mechanism?''' [https://github.com/bitcoin/bips/blob/master/bip-0342.mediawiki BIP-0342] reuses the same common signature message algorithm, but adds BIP-0342-specific data at the end, which is indicated using ''ext_flag = 1''.</ref>.
19
21
20
22
If the parameters take acceptable values, the message is the concatenation of the following data, in order (with byte size of each item listed in parentheses). Numerical values in 2, 4, or 8-byte are encoded in little-endian.
@@ -34,28 +36,28 @@ If the parameters take acceptable values, the message is the concatenation of th
34
36
*** '''''NEW'''''''sha_amounts_assets'' (32): the SHA256 of the serialization of all output ''nAsset'' fields followed by ''nValue'' fields
35
37
*** ''sha_scriptpubkeys'' (32): the SHA256 of the serialization of all spent output ''scriptPubKey''s.
36
38
*** ''sha_sequences'' (32): the SHA256 of the serialization of all input ''nSequence''.
37
-
*** '''''NEW'''''''sha_issuances'' (32): the SHA256 of the serialization of the concatenation of all input ''assetIssuance'' or '0x00' for inputs with no issuance. (Note: this is the same messaged hashed that used in Elements Segwit V0 signatures.)
39
+
*** '''''NEW'''''''sha_issuances'' (32): the SHA256 of the serialization of the concatenation of all input ''assetIssuance'' or 130 '0x00' bytes for inputs with no issuance
38
40
** If ''hash_type & 3'' does not equal <code>SIGHASH_NONE</code> or <code>SIGHASH_SINGLE</code>:
39
-
*** ''sha_outputs'' (32): the SHA256 of the serialization of all outputs in <code>CTxOut</code> format.
41
+
*** ''sha_outputs'' (32): the SHA256 of the serialization of all outputs in extended <code>CTxOut</code> format.
40
42
*** '''''NEW'''''''sha_output_witnesses'' (32): the SHA256 of the serialization of all output witnesses (rangeproof and surjection proof) in <code>CTxWitness</code> format.
41
43
* Data about this input:
42
44
** ''spend_type'' (1): equal to ''(ext_flag * 2) + annex_present'', where ''annex_present'' is 0 if no annex is present, or 1 otherwise (the original witness stack has two or more witness elements, and the first byte of the last element is ''0x50'')
43
45
** If ''hash_type & 0x80'' equals <code>SIGHASH_ANYONECANPAY</code>:
44
46
*** '''''NEW'''''''outpoint_flag'' (1): the input's outpoint flags shifted right by 24 bits. (Compare ''sha_outpoint_flags'' above.)
45
47
*** ''outpoint'' (36): the <code>COutPoint</code> of this input (32-byte hash + 4-byte little-endian).
46
-
*** '''''NEW'''''''nAsset'' (33): (possibly confidential) assetID of the previous output spent by this input.
47
-
*** '''''NEW'''''''nValue'' (9--33): (possibly confidential) amount of the previous output spent by this input.
48
+
*** '''''NEW'''''''nAsset'' (33): assetID of the previous output spent by this input, in fixed-length format
49
+
*** '''''NEW'''''''nValue'' (33): (possibly confidential) amount of the previous output spent by this input, in fixed-length format
48
50
*** ''scriptPubKey'' (35): ''scriptPubKey'' of the previous output spent by this input, serialized as script inside <code>CTxOut</code>. Its size is always 35 bytes.
49
51
*** ''nSequence'' (4): ''nSequence'' of this input.
50
-
*** '''''NEW'''''''asset_issuance'' (0 or 74--130): if ''outpoint_flag & 0x80 == 0x80'': asset issuance data of this input.
52
+
*** '''''NEW'''''''asset_issuance'' (130): if ''outpoint_flag & 0x80 == 0x80'': asset issuance data of this input; otherwise 130 zero bytes
51
53
** If ''hash_type & 0x80'' does not equal <code>SIGHASH_ANYONECANPAY</code>:
52
54
*** ''input_index'' (4): index of this input in the transaction input vector. Index of the first input is 0.
53
55
** If an annex is present (the lowest bit of ''spend_type'' is set):
54
56
*** ''sha_annex'' (32): the SHA256 of ''(compact_size(size of annex) || annex)'', where ''annex'' includes the mandatory ''0x50'' prefix.
55
57
* Data about this output:
56
58
** If ''hash_type & 3'' equals <code>SIGHASH_SINGLE</code>:
57
-
*** ''sha_single_output'' (32): the SHA256 of the corresponding output in <code>CTxOut</code> format.
59
+
*** ''sha_single_output'' (32): the SHA256 of the corresponding output in extended <code>CTxOut</code> format.
58
60
*** '''''NEW'''''''sha_single_output_witness'' (32): the SHA256 of the serialization of the corresponding output witnesses (rangeproof and surjection proof) in <code>CTxWitness</code> format.
59
61
60
-
The total length of ''SigMsg()'' is at most ''491'' bytes. Note that this does not include the size of sub-hashes such as ''sha_prevouts'', which may be cached across signatures of the same transaction.
62
+
The total length of ''SigMsg()'' is ''442'' bytes for <code>ANYONECANPAY</code> sighashes, ''366'' bytes for non-<code>ANYONECANPAY</code> sighashes, and both numbers are reduced by 64 bytes for <code>SIGHASH_NONE</code> sighashes. Note that this does not include the size of sub-hashes such as ''sha_prevouts'', which may be cached across signatures of the same transaction.
0 commit comments