smartledger-bsv 3.1.0 → 3.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/CHANGELOG.md +123 -1
  2. package/README.md +233 -277
  3. package/bsv.bundle.js +39 -0
  4. package/bsv.min.js +8 -8
  5. package/docs/ADVANCED_COVENANT_DEVELOPMENT.md +533 -0
  6. package/docs/COVENANT_DEVELOPMENT_RESOLVED.md +169 -0
  7. package/docs/CUSTOM_SCRIPT_DEVELOPMENT.md +320 -0
  8. package/docs/README.md +201 -0
  9. package/docs/block.md +46 -0
  10. package/docs/ecies.md +102 -0
  11. package/docs/index.md +104 -0
  12. package/docs/nchain.md +958 -0
  13. package/docs/networks.md +55 -0
  14. package/docs/preimage.md +126 -0
  15. package/docs/script.md +139 -0
  16. package/docs/transaction.md +174 -0
  17. package/docs/unspentoutput.md +32 -0
  18. package/examples/README.md +200 -0
  19. package/examples/basic/transaction-creation.js +534 -0
  20. package/examples/basic/transaction_signature_api_gap.js +178 -0
  21. package/examples/covenants/advanced_covenant_demo.js +219 -0
  22. package/examples/covenants/covenant_interface_demo.js +270 -0
  23. package/examples/covenants/covenant_manual_signature_resolved.js +212 -0
  24. package/examples/covenants/covenant_signature_template.js +117 -0
  25. package/examples/covenants2/covenant_bidirectional_example.js +262 -0
  26. package/examples/covenants2/covenant_utils_demo.js +120 -0
  27. package/examples/covenants2/preimage_covenant_utils.js +287 -0
  28. package/examples/covenants2/production_integration.js +256 -0
  29. package/examples/data/covenant_utxos.json +28 -0
  30. package/examples/data/utxos.json +26 -0
  31. package/examples/preimage/README.md +178 -0
  32. package/examples/preimage/extract_preimage_bidirectional.js +421 -0
  33. package/examples/preimage/generate_sample_preimage.js +208 -0
  34. package/examples/preimage/generate_sighash_examples.js +152 -0
  35. package/examples/preimage/parse_preimage.js +117 -0
  36. package/examples/preimage/test_preimage_extractor.js +53 -0
  37. package/examples/preimage/test_varint_extraction.js +95 -0
  38. package/examples/scripts/custom_script_helper_example.js +273 -0
  39. package/examples/scripts/custom_script_signature_test.js +344 -0
  40. package/examples/scripts/script_interpreter.js +193 -0
  41. package/examples/smart_contract/complete_workflow_demo.js +343 -0
  42. package/examples/smart_contract/covenant_builder_demo.js +176 -0
  43. package/examples/smart_contract/script_testing_integration.js +198 -0
  44. package/index.js +3 -0
  45. package/lib/covenant-interface.js +713 -0
  46. package/lib/opcode.js +14 -7
  47. package/lib/smart_contract/API_REFERENCE.md +754 -0
  48. package/lib/smart_contract/DOCUMENTATION_SUMMARY.md +201 -0
  49. package/lib/smart_contract/EXAMPLES.md +751 -0
  50. package/lib/smart_contract/QUICK_START.md +549 -0
  51. package/lib/smart_contract/README.md +395 -0
  52. package/lib/smart_contract/builder.js +452 -0
  53. package/lib/smart_contract/covenant.js +336 -0
  54. package/lib/smart_contract/covenant_builder.js +512 -0
  55. package/lib/smart_contract/index.js +311 -0
  56. package/lib/smart_contract/opcode_list.js +30 -0
  57. package/lib/smart_contract/opcode_map.js +1174 -0
  58. package/lib/smart_contract/opcodes.md +1173 -0
  59. package/lib/smart_contract/preimage.js +903 -0
  60. package/lib/smart_contract/script_tester.js +487 -0
  61. package/lib/smart_contract/script_utils.js +609 -0
  62. package/lib/smart_contract/sighash.js +310 -0
  63. package/lib/smart_contract/smartledger-opcode_review.md +70 -0
  64. package/lib/smart_contract/test_integration.js +269 -0
  65. package/lib/smart_contract/utxo_generator.js +367 -0
  66. package/package.json +43 -10
  67. package/utilities/blockchain-state.json +20478 -3
package/docs/nchain.md ADDED
@@ -0,0 +1,958 @@
1
+ PUSHTX and its Building Blocks
2
+ White Paper
3
+ WP1605
4
+ Created:
5
+ Last updated:
6
+ 20/05/2021
7
+ 14/12/2021PUSHTX and Its Building Blocks
8
+ Copyright
9
+ Information in this document is subject to change without notice and is furnished under a
10
+ license agreement or nondisclosure agreement. The information may only be used or copied in
11
+ accordance with the terms of those agreements.
12
+ All rights reserved. No part of this publication may be reproduced, stored in a retrieval system,
13
+ or transmitted in any form or any means electronic or mechanical, including photocopying and
14
+ recording for any purpose other than the purchaser’s personal use without the written
15
+ permission of nChain Licensing AG. The names of actual companies and products mentioned in
16
+ this document may be trademarks of their respective owners. nChain Licensing AG accepts no
17
+ responsibility or liability for any errors or inaccuracies that may appear in this documentation.
18
+ Disclaimer
19
+ The information contained herein, such as code, data structures, pseudo-code, etc. is provided
20
+ “as is”, no warranty, express or implied, regarding the merchantability or fitness for purpose of
21
+ the information contained herein, is provided by nChain Licensing AG or any of its group
22
+ companies. Neither nChain Licensing AG, nor any of its group companies, accepts any liability
23
+ for any consequential, incidental, special or indirect damages that may occur through use of the
24
+ information contained herein.
25
+ Authors
26
+ NameTitle
27
+ Wei ZhangPrincipal Researcher
28
+ WP1605
29
+ © nChain Licensing AG
30
+ 2 of 25PUSHTX and Its Building Blocks
31
+ Contents
32
+ 1PUSHTX and Its Building Blocks ..................................................................................... 4
33
+ 1.1Generating the signature in-script ...................................................................... 4
34
+ 1.2Constructing the message in-script ....................................................................5
35
+ 1.3Example of a PELS .................................................................................................... 8
36
+ 1.4Optimisation ................................................................................................................ 12
37
+ 2Security Analysis .................................................................................................................. 15
38
+ 3Appendix ................................................................................................................................. 18
39
+ WP1605
40
+ © nChain Licensing AG
41
+ 3 of 25PUSHTX and Its Building Blocks
42
+ 1
43
+ PUSHTX and Its Building Blocks
44
+ The core idea of PUSHTX (originally invented by Y. Chan and D. Kramer at nChain in 2017) is to
45
+ generate a signature in-script on a data element on the stack and call OP_CHECKSIG to verify
46
+ the signature. If it passes, it implies that the message constructed by OP_CHECKSIG is identical
47
+ to the data element pushed to the stack. Therefore, it achieves the effect of pushing the
48
+ current spending transaction to the stack. Since its adoption by sCrypt, STAS token and
49
+ Sensible Contracts, the PUSHTX idea has been widely discussed and tested in practice. The
50
+ purpose of this document is to offer some security insight and optimisations while revisiting
51
+ PUSHTX with an example of a perpetually enforcing locking script. We focus on two most
52
+ important building blocks of PUSHTX, the signature generation and the message construction.
53
+ The size of its spending transaction is intended to be a benchmark for reference. Other
54
+ techniques of pushing transactions to the stack are out of scope of this white paper.
55
+ A perpetually enforcing locking script (PELS) is a locking script that enforces some condition or
56
+ conditions on all future transactions in the spending chain that originates from the output that
57
+ contains this locking script. One example to achieve this is to design a locking script that forces
58
+ the locking script in the spending transaction to be the same as itself. Note that a locking script
59
+ with an enforcement only on the next spending transaction would have a much simpler design.
60
+ PELS are particularly useful for the sender (originator) as they can be ensured that all future
61
+ spending transactions will follow the rules which they set out in the locking script. Any violation
62
+ of the rules would invalidate the transaction in terms of script execution.
63
+ 1.1 Generating the signature in-script
64
+ The first building block is to generate the signature for a given message 𝑚. We assume that the
65
+ following script segment is part of a locking script, and the input data can be either in an
66
+ unlocking script or hard coded in the same locking script.
67
+ [sign]:= OP_HASH256 𝑘 −1 OP_MUL 𝑘 −1 𝑟𝑎 OP_ADD 𝑛 OP_MOD 𝑟 [toDER]
68
+ SIGHASH_FLAG OP_CAT
69
+ Input data: 𝑚
70
+ Remarks
71
+ 1. The equation for computing 𝑠 in the ECDSA signature is 𝑘 −1 (𝑧 + 𝑟𝑎) 𝑚𝑜𝑑 𝑛, where 𝑧 is
72
+ the double SHA256 of the message 𝑚 to be signed. We write the equation in script as
73
+ (𝑘 −1 𝑧 + 𝑘 −1 𝑟𝑎) 𝑚𝑜𝑑 𝑛 to indicate that 𝑘 −1 and 𝑘 −1 𝑟𝑎 can be precomputed. It would be
74
+ very costly to compute modular inverse 𝑘 −1 𝑚𝑜𝑑 𝑛 in script. As we are not using the
75
+ signature for authenticity, the private key 𝑎 and the ephemeral key 𝑘 can be chosen at
76
+ wish and shown publicly.
77
+ 2. The script segment [sign] as part of the locking script needs to fix both the
78
+ ephemeral key 𝑘 and the private key 𝑎. Although anyone can generate a valid signature
79
+ using [sign], the focus is on the input 𝑚. The requirement is that there is only one
80
+ value of 𝑚 that can pass OP_CHECKSIG for any given spending transaction. If the
81
+ private key or the public key is not fixed, then the transaction will be malleable. The
82
+ detail can be found in Section 2. If the ephemeral key 𝑘 is not fixed, then anyone can
83
+ WP1605
84
+ © nChain Licensing AG
85
+ 4 of 25PUSHTX and Its Building Blocks
86
+ use a different 𝑘 to create a valid transaction with a different transaction ID, which is
87
+ not desirable in some use cases.
88
+ 3. To further optimise the script segment, one can choose small values for 𝑘 and 𝑎 such
89
+ as 1, and they can be the same every time. Note that if 𝑘 = 𝑎 = 1, then 𝑠 = 𝑧 +
90
+ 𝐺𝑥 𝑚𝑜𝑑 𝑛, where 𝐺𝑥 is the 𝑥-coordinate of the generator point 𝐺. The compressed
91
+ public key will be 𝐺𝑥 too. The definition of [sign] can be re-written as
92
+ [sign]:= OP_HASH256 𝐺𝑥 OP_ADD 𝑛 OP_MOD 𝐺𝑥 [toDER]
93
+ SIGHASH_FLAG OP_CAT
94
+ 4. The script segment [toDER] is to convert the pair (𝑟, 𝑠) to the canonical DER format.
95
+ This is the only format accepted by OP_CHECKSIG. It forces 𝑠 to be in the range
96
+ between 0 and 𝑛/2 to avoid transaction ID malleability. Although this is a policy rule in
97
+ the Bitcoin network, it seems that Bitcoin nodes are unlikely to accept alternatives.
98
+ 5. Note that SIGHASH_FLAG in [sign] is compulsory as OP_CHECKSIG expects it. It can
99
+ be used to specify which part of the spending transaction should be pushed to the
100
+ stack. For example, the flag ALL would require all the inputs and outputs to be
101
+ included in the message 𝑚, while SINGLE|ANYONECANPAY would require the input
102
+ corresponding to this locking script and its paired output to be included in 𝑚.
103
+ 6. If we extend the script segment to “OP_DUP [sign] < 𝑃𝐾 >” with input 𝑚, the stack
104
+ from bottom to top will look like [𝑚, 𝑆𝑖𝑔, 𝑃𝐾] after its execution. A call to
105
+ OP_CHECKSIGVERIFY will consume the signature and the public key, leaving 𝑚 on the
106
+ top of the stack. If the verification is successful, then one can be convinced that the
107
+ message 𝑚 left on the stack is an accurate representation of the spending transaction.
108
+ 1.2 Constructing the message in-script
109
+ The signed message in its serialised format is different from the serialised transaction. The
110
+ latter gives away all the information about the transaction, while the signed message
111
+ unintentionally conceals some information about the transaction in hash values and offers
112
+ some information about the output being spent, i.e., its value and its locking script.
113
+ The message 𝑚 cannot be fully embedded in the locking script as it contains the locking script
114
+ itself and some unknown information on the future spending transaction. Only some of the
115
+ fields can be explicitly enforced in the locking script, e.g., version, sequence number, or
116
+ locktime. The message 𝑚 is either provided in the unlocking script in its entirety or constructed
117
+ in script with some inputs from the unlocking script and instructions from the locking script. We
118
+ will focus on the latter as it is more restrictive from the perspective of a spending transaction.
119
+ Note that the goal of constructing the message is to enforce desired values for some data fields
120
+ in the spending transaction. The table below captures all the data fields in the message and
121
+ whether they should or can be fixed in the locking script. “Optional” is given if it is use-case
122
+ specific.
123
+ WP1605
124
+ © nChain Licensing AG
125
+ 5 of 25PUSHTX and Its Building Blocks
126
+ Table 1 - Components of a signed message
127
+ ItemsFixed explicitly in locking script or not
128
+ 1Version 4 bytes little endianOptional
129
+ 2Hash of input outpoints 32 bytesInfeasible due to circular reference of TxID
130
+ 3Hash of input sequence numbers 32
131
+ bytesOptional, recommend “Not” to allow more
132
+ flexibility in spending transaction
133
+ 4Input outpoint 32 bytes + 4 bytes in little
134
+ endianInfeasible due to circular reference of TxID
135
+ (although 4 bytes index can be optional)
136
+ 5Length of previous locking scriptOptional, recommend “Not” for simplicity
137
+ 6Previous locking scriptInfeasible due to circular reference of the
138
+ locking script
139
+ 7Value of previous locking script 8 bytes
140
+ (little endian)Optional
141
+ 8Sequence number 4 bytes (little endian)Optional
142
+ 9Hash of outputs 32 bytesOptional if it is known before hand,
143
+ otherwise, infeasible to be fixed.
144
+ 10Locktime 4 bytes in little endianOptional
145
+ 11Sighash flag 4 bytes in little endianRecommend being fixed for more
146
+ restrictiveness
147
+ From now on, the data fields in the table will be referred as item 1, 2, 3, etc.
148
+ When it is optional, whether to provide the data in the locking or unlocking script depends on
149
+ use cases. A general rule is that if the data is available or known at the time of creating the
150
+ locking script, then they can be included in the locking script. Another aspect to consider is the
151
+ size of the transaction and its spending transaction. By shifting the data between the locking
152
+ and unlocking script, one can shift some of the transaction fee cost between the senders of the
153
+ two transactions.
154
+ Note that when we say infeasible due to circular references, the granularity is set at date fields.
155
+ For example, partial locking script or even a small part of a transaction ID (e.g., fixing the first
156
+ two bytes of a 32-byte transaction ID and allow iterations through some fields in a serialised
157
+ transaction) can be fixed in the locking script if required.
158
+ As mentioned earlier, although the focus is to construct the message 𝑚, the goal is to use 𝑚 to
159
+ enforce values on different fields in the spending transaction. To enforce the data behind the
160
+ hash values, i.e., item 9, the locking script should be designed to request the pre-image, hash
161
+ WP1605
162
+ © nChain Licensing AG
163
+ 6 of 25PUSHTX and Its Building Blocks
164
+ them in-script, and then construct the message to be signed in-script. Taking item 9 as an
165
+ example, to enforce the outputs in the current transaction, we can have
166
+ [outputsRequest]:= OP_DUP OP_HASH256 OP_ROT OP_SWAP OP_CAT <item 10 and
167
+ 11> OP_CAT
168
+ Input data: <item 1 to 8> <serialised outputs in current transaction>
169
+ Remarks
170
+ 1. The script segment [outputsRequest] takes item 1 to 8 and the serialised outputs
171
+ on the stack to construct item 9, and concatenate with item 10 and 11 to obtain the
172
+ message 𝑚 in-script. By calling [sign] <𝐺𝑥 > OP_CHECKSIGVERIFY after
173
+ [outputsRequest] and passing the verification, one can be convinced that the
174
+ serialised outputs left on the top of the stack is a true representation of the outputs in
175
+ the current transaction.
176
+ 2. It is also very useful to leave a copy of <item 1 to 7> on the stack for comparison.
177
+ This can be achieved by modifying the script segment as below.
178
+ [outputsRequest]:= OP_2DUP OP_HASH256 OP_SWAP <item 8> OP_CAT
179
+ OP_SWAP OP_CAT <item 10 and 11> OP_CAT
180
+ Input data: <item 1 to 7> <serialised outputs in current
181
+ transaction>
182
+ After executing the modified [outputsRequest] on the input data, we can call
183
+ [sign] <𝐺𝑥 > OP_CHECKSIGVERIFY to consume the message. The stack will have the
184
+ current serialised outputs on the top followed by <item 1 to 7>. We will use the
185
+ modified script segment later to enforce the output in a spending transaction.
186
+ 3. It is simpler if consecutive items are grouped together as in <item 1 to 7>. They are
187
+ either all in an unlocking script or all fixed in a locking script. However, a more granular
188
+ approach is available at a potential cost of having a more complex script.
189
+ Note that the serialisation format for current outputs is
190
+ a. value of the output 8 bytes (little endian),
191
+ b. length of the locking script,
192
+ c. the locking script, and
193
+ d. concatenate serialised outputs in order if there is more than one output.
194
+ The serialisation format for previous output (item 5 to 7) in a signed message is
195
+ a. length of the locking script,
196
+ b. the locking script, and
197
+ c. value of the output 8 bytes (little endian).
198
+ In the following example, we will compare the previous output with the output in the current
199
+ spending transaction and force them to be identical. The two formats will be useful for
200
+ designing the locking script for the comparison.
201
+ WP1605
202
+ © nChain Licensing AG
203
+ 7 of 25PUSHTX and Its Building Blocks
204
+ 1.3 Example of a PELS
205
+ Suppose that Alice is a root Certificate Authority (CA) and Bob is a subordinate CA. Alice is going
206
+ to delegate some work to Bob which would require Bob to publish transactions on-chain as
207
+ attestations to certificates. Alice does not want Bob to spend the output on anything else.
208
+ Therefore, Alice is going to force all the subsequent spending transactions to have a fixed
209
+ [P2PKH Bob] locking script and a fixed output value. Bob can spend the output as he can
210
+ generate valid signatures, but he cannot choose any output other than sending the same
211
+ amount to himself. For illustration purpose and simplicity, we ignore OP_RETURN payload
212
+ throughout the example.
213
+ Alice constructs the initial transaction as shown below.
214
+ 𝑇𝑥𝐼𝐷0
215
+ Version1Locktime0
216
+ In-count1Out-count1
217
+ Input list
218
+ Output list
219
+ OutpointUnlocking scriptnSeqValueLocking script
220
+ 𝑂𝑢𝑡𝑝𝑜𝑖𝑛𝑡𝐴< 𝑆𝑖𝑔𝐴 >
221
+ < 𝑃𝐾𝐴 >FFFFFFFF1000[outputsRequest][sign] OP_CHECKSIGVERIFY
222
+ OP_SWAP <0x68> OP_SPLIT OP_NIP OP_SWAP OP_8
223
+ OP_SPLIT OP_SWAP OP_CAT OP_EQUALVERIFY OP_DUP
224
+ OP_HASH160 <𝐻(𝑃𝐾𝐵 )> OP_EQUALVERIFY OP_CHECKSIG
225
+ Figure 1 - Initial transaction that contains a PELS output
226
+ The script segments are defined as:
227
+ [outputsRequest]:= OP_2DUP OP_HASH256 OP_SWAP <item 8> OP_CAT OP_SWAP
228
+ OP_CAT <item 10 and 11> OP_CAT
229
+ [sign]:= OP_HASH256 𝐺𝑥 OP_ADD 𝑛 OP_MOD [toDER] SIGHASH_FLAG OP_CAT
230
+ 𝐺𝑐𝑜𝑚𝑝𝑟𝑒𝑠𝑠𝑒𝑑
231
+ [toDER]:= [toCanonical][concatenations]
232
+ [toCanonical]1:= OP_DUP 𝑛/2 OP_GREATERTHAN OP_IF 𝑛 OP_SWAP OP_SUB OP_ENDIF
233
+ [concatenations]:= OP_SIZE OP_DUP <0x24> OP_ADD <0x30> OP_SWAP OP_CAT
234
+ <0220||𝐺𝑥 ||02> OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT
235
+ Note that “OP_SWAP <0x68> OP_SPLIT OP_NIP OP_SWAP OP_8 OP_SPLIT OP_SWAP OP_CAT
236
+ OP_EQUALVERIFY” is to extract the previous output from the signed message (verified and left
237
+ on the top of the stack), then swap the position of the value field and the locking script to form
238
+ the expected current output, and finally compare it with the actual current output provided in
239
+ the unlocking script and its integrity is implied by the integrity of the signed message.
240
+ The length of the locking script is roughly
241
+ 1
242
+ This is to make sure that 𝑠 is in the range between 0 and 𝑛/2. If 𝑠 > 𝑛/2, we let 𝑠 = 𝑛 − 𝑠.
243
+ WP1605
244
+ © nChain Licensing AG
245
+ 8 of 25PUSHTX and Its Building Blocks
246
+ (7 + 12) + (6 + 32 + 32 + 33) + (6 + 32 + 32) + (11) + (15 + 34) + (14 + 20)
247
+ = 286 = 0𝑥011𝑒.
248
+ Note that these numbers are not meant to be precise, but they should be accurate enough to
249
+ be in the right magnitude. For a more accurate result, please refer to Appendix.
250
+ To spend the transaction, Bob creates the spending transaction as below.
251
+ 𝑇𝑥𝐼𝐷1
252
+ Version1Locktime0
253
+ In-count1Out-count1
254
+ Input list
255
+ OutpointUnlocking script
256
+ 𝑇𝑥𝐼𝐷0 ||0< 𝑆𝑖𝑔𝐵 >
257
+ < 𝑃𝐾𝐵 >
258
+ < 𝐷𝑎𝑡𝑎1 >
259
+ < 𝐷𝑎𝑡𝑎2 >
260
+ Output list
261
+ nSeq
262
+ FFFFFFFF
263
+ ValueLocking script
264
+ 1000[outputsRequest][sign] OP_CHECKSIGVERIFY
265
+ OP_SWAP <0x68> OP_SPLIT OP_NIP OP_SWAP OP_8
266
+ OP_SPLIT OP_SWAP OP_CAT OP_EQUALVERIFY OP_DUP
267
+ OP_HASH160 <H(PK_B)> OP_EQUALVERIFY
268
+ OP_CHECKSIG
269
+ Figure 2 - spending the PELS output
270
+ The unlocking script contains a data element 𝐷𝑎𝑡𝑎1 which represents items 1 to 7 and can be
271
+ written as:
272
+ 010000002268f59280bdb73a24aae224a0b30c1f60b8a386813d63214f86b98261a6b8763
273
+ bb13029ce7b1f559ef5e747fcac439f1455a2ec7c5f09b72290795e70665044𝑇𝑥𝐼𝐷0 00000
274
+ 000011e{[outputsRequest] [sign] OP_CHECKSIGVERIFY OP_SWAP <0x68> OP_SPLIT
275
+ OP_NIP OP_SWAP OP_8 OP_SPLIT OP_SWAP OP_CAT OP_EQUALVERIFY OP_DUP
276
+ OP_HASH160 <H(PK_B)> OP_EQUALVERIFY OP_CHECKSIG}e803000000000000
277
+ Table 2 - Data element 𝑑𝑎𝑡𝑎1 explained
278
+ ItemsValue
279
+ 1version01000000
280
+ 2Hash of input outpoints2268f59280bdb73a24aae224a0b30c1f60b8a3868
281
+ 13d63214f86b98261a6b876
282
+ 3Hash of input sequence
283
+ numbers3bb13029ce7b1f559ef5e747fcac439f1455a2ec7
284
+ c5f09b72290795e70665044
285
+ 4Input outpoint𝑇𝑥𝐼𝐷000000000
286
+ 5Length of previous locking script011e
287
+ WP1605
288
+ © nChain Licensing AG
289
+ 9 of 25PUSHTX and Its Building Blocks
290
+ 6Previous locking script{[outputsRequest] [sign]
291
+ OP_CHECKSIGVERIFY OP_SWAP <0x68> OP_SPLIT
292
+ OP_NIP OP_SWAP OP_8 OP_SPLIT OP_SWAP
293
+ OP_CAT OP_EQUALVERIFY OP_DUP OP_HASH160
294
+ <H(PK_B)> OP_EQUALVERIFY OP_CHECKSIG}
295
+ 7Value of previous locking scripte803000000000000
296
+ The data element 𝐷𝑎𝑡𝑎2 represents the output in 𝑇𝑥𝐼𝐷1 (value || locking script length || locking
297
+ script) and can be written as:
298
+ e803000000000000011e{[outputsRequest] [sign] OP_CHECKSIGVERIFY OP_SWAP
299
+ <0x68> OP_SPLIT OP_NIP OP_SWAP OP_8 OP_SPLIT OP_SWAP OP_CAT
300
+ OP_EQUALVERIFY OP_DUP OP_HASH160 <H(PK_B)> OP_EQUALVERIFY OP_CHECKSIG}
301
+ The full script to be executed during the validation of 𝑇𝑥𝐼𝐷1 is
302
+ < 𝑆𝑖𝑔𝐵 > < 𝑃𝐾𝐵 > < 𝐷𝑎𝑡𝑎1 > < 𝐷𝑎𝑡𝑎2 > [outputsRequest] [sign] OP_CHECKSIGVERIFY
303
+ OP_SWAP <0x68> OP_SPLIT OP_NIP OP_SWAP OP_8 OP_SPLIT OP_SWAP OP_CAT
304
+ OP_EQUALVERIFY OP_DUP OP_HASH160 <H(PK_B)> OP_EQUALVERIFY OP_CHECKSIG
305
+ After the first OP_CHECKSIGVERIFY, we will have < 𝑆𝑖𝑔𝐵 > < 𝑃𝐾𝐵 > < 𝐷𝑎𝑡𝑎1 > < 𝐷𝑎𝑡𝑎2 > on
306
+ the stack (rightmost on the top).
307
+ Table 3 - Stack execution
308
+ StepThe stackTo execute
309
+ 1< 𝑆𝑖𝑔𝐵 > < 𝑃𝐾𝐵 > < 𝐷𝑎𝑡𝑎1 > < 𝐷𝑎𝑡𝑎2 >OP_SWAP <0x68>
310
+ 2< 𝑆𝑖𝑔𝐵 > < 𝑃𝐾𝐵 > < 𝐷𝑎𝑡𝑎2 > < 𝐷𝑎𝑡𝑎1 > <0x68>OP_SPLIT OP_NIP
311
+ 3< 𝑆𝑖𝑔𝐵 > < 𝑃𝐾𝐵 > < 𝐷𝑎𝑡𝑎2 >
312
+ <011e
313
+ {[outputsRequest] [sign] OP_CHECKSIGVERIFY
314
+ OP_SWAP <0x68> OP_SPLIT OP_NIP OP_SWAP OP_8
315
+ OP_SPLIT OP_SWAP OP_CAT OP_EQUALVERIFY
316
+ OP_DUP OP_HASH160 <H(PK_B)> OP_EQUALVERIFY
317
+ OP_CHECKSIG}
318
+ e803000000000000>OP_SWAP OP_8 OP_SPLIT
319
+ 4< 𝑆𝑖𝑔𝐵 > < 𝑃𝐾𝐵 > < 𝐷𝑎𝑡𝑎2 >
320
+ <011e
321
+ {[outputsRequest] [sign] OP_CHECKSIGVERIFY
322
+ OP_SWAP <0x68> OP_SPLIT OP_NIP OP_SWAP OP_8
323
+ OP_SPLIT OP_SWAP OP_CAT OP_EQUALVERIFYOP_SWAP OP_CAT
324
+ WP1605
325
+ © nChain Licensing AG
326
+ 10 of 25PUSHTX and Its Building Blocks
327
+ OP_DUP OP_HASH160 <H(PK_B)> OP_EQUALVERIFY
328
+ OP_CHECKSIG}
329
+ e803000000000000>
330
+ <e803000000000000>
331
+ <011e
332
+ {[outputsRequest] [sign] OP_CHECKSIGVERIFY
333
+ OP_SWAP <0x68> OP_SPLIT OP_NIP OP_SWAP OP_8
334
+ OP_SPLIT OP_SWAP OP_CAT OP_EQUALVERIFY
335
+ OP_DUP OP_HASH160 <H(PK_B)> OP_EQUALVERIFY
336
+ OP_CHECKSIG}>
337
+ 5< 𝑆𝑖𝑔𝐵 > < 𝑃𝐾𝐵 > < 𝐷𝑎𝑡𝑎2 >
338
+ <011e
339
+ {[outputsRequest] [sign] OP_CHECKSIGVERIFY
340
+ OP_SWAP <0x68> OP_SPLIT OP_NIP OP_SWAP OP_8
341
+ OP_SPLIT OP_SWAP OP_CAT OP_EQUALVERIFY
342
+ OP_DUP OP_HASH160 <H(PK_B)> OP_EQUALVERIFY
343
+ OP_CHECKSIG}
344
+ e803000000000000>
345
+ <011e
346
+ {[outputsRequest] [sign] OP_CHECKSIGVERIFY
347
+ OP_SWAP <0x68> OP_SPLIT OP_NIP OP_SWAP OP_8
348
+ OP_SPLIT OP_SWAP OP_CAT OP_EQUALVERIFY
349
+ OP_DUP OP_HASH160 <H(PK_B)> OP_EQUALVERIFY
350
+ OP_CHECKSIG}
351
+ e803000000000000>OP_EQUALVERIFY
352
+ 6< 𝑆𝑖𝑔𝐵 > < 𝑃𝐾𝐵 >OP_DUP OP_HASH160
353
+ <H(PK_B)>
354
+ OP_EQUALVERIFY
355
+ OP_CHECKSIG
356
+ 7True
357
+ The size of 𝑇𝑥𝐼𝐷1 is
358
+ 𝑣𝑒𝑟𝑠𝑖𝑜𝑛 + 𝑙𝑜𝑐𝑘𝑡𝑖𝑚𝑒 + 𝑖𝑛𝑝𝑢𝑡 + 𝑜𝑢𝑡𝑝𝑢𝑡
359
+ = 4 + 4 + (36 + 72 + 33 + 104 + 287 + 8 + 287 + 8 + 4) + (8 + 287)
360
+ = 1142 bytes.
361
+ Transaction Fee
362
+ Given the current setting, Bob can add his own input to cover the transaction fee. If Alice uses
363
+ SIGHASH_SINGLE|ANYONECANPAY in the script segment [sign], then Bob can add another
364
+ output to collect changes. This effectively makes the enforcement from Alice’s locking script
365
+ perpetual. One can think of this as a node-enforced smart contract between Alice and Bob.
366
+ It is also possible for the locking script to take the transaction fee into consideration. After step
367
+ 3, the top element on the stack is the value from the previous output. By adding <𝑇𝑥𝐹𝑒𝑒>
368
+ OP_SUB before the concatenation in step 4, Alice allows Bob to pay the transaction fee from the
369
+ previous output. This will lead to diminishing value of the output over spends, which can act as
370
+ a desired feature as it sets the total number of spends Bob are entitled to.
371
+ WP1605
372
+ © nChain Licensing AG
373
+ 11 of 25PUSHTX and Its Building Blocks
374
+ 1.4 Optimisation
375
+ As 𝐷𝑎𝑡𝑎1 contains 𝐷𝑎𝑡𝑎2 , we can construct 𝐷𝑎𝑡𝑎2 from 𝐷𝑎𝑡𝑎1 . In other words, we assume that
376
+ the current output is identical to the previous output and use the previous output to construct
377
+ the message. If it passes OP_CHECKSIG, then the two outputs must be identical. The script
378
+ segment of [outputsRequest] can be re-written as:
379
+ [outputsRequest]:= OP_2DUP OP_CAT OP_TOALTSTACK OP_SWAP OP_CAT OP_HASH256
380
+ <item 8> OP_SWAP OP_CAT OP_FROMALTSTACK OP_SWAP OP_CAT OP_CAT <item 10
381
+ and 11> OP_CAT
382
+ Input data: <item 1 to 4> <item 5 and 6> <item 7>
383
+ With this new [outputsRequest], we can update the locking script in 𝑇𝑥𝐼𝐷0 and 𝑇𝑥𝐼𝐷1 as:
384
+ [outputsRequest][sign] OP_CHECKSIGVERIFY OP_DUP OP_HASH160 <H(PK_B)>
385
+ OP_EQUALVERIFY OP_CHECKSIG
386
+ and the unlocking script as:
387
+ < 𝑆𝑖𝑔𝐵 > < 𝑃𝐾𝐵 > < 𝐷𝑎𝑡𝑎1 > < 𝐷𝑎𝑡𝑎2 > < 𝐷𝑎𝑡𝑎3 >
388
+ where 𝐷𝑎𝑡𝑎1 is item 1 to 4:
389
+ 010000002268f59280bdb73a24aae224a0b30c1f60b8a386813d63214f86b98261a6b8763bb
390
+ 13029ce7b1f559ef5e747fcac439f1455a2ec7c5f09b72290795e70665044𝑇𝑥𝐼𝐷000000000
391
+ 𝐷𝑎𝑡𝑎2 is item 5 and 6:
392
+ 011b{[outputsRequest] [sign] OP_CHECKSIGVERIFY OP_SWAP <0x68> OP_SPLIT
393
+ OP_NIP OP_SWAP OP_8 OP_SPLIT OP_SWAP OP_CAT OP_EQUALVERIFY OP_DUP
394
+ OP_HASH160 <H(PK_B)> OP_EQUALVERIFY OP_CHECKSIG}
395
+ 𝐷𝑎𝑡𝑎3 is item 7: e803000000000000.
396
+ The size of 𝑇𝑥𝐼𝐷1 is 941 bytes. A step-by-step execution is given below, where Step 1 to 5 is
397
+ from [outputsRequest].
398
+ Table 4 - Stack execution with optimisation
399
+ StepThe stacksTo execute
400
+ 1< 𝑆𝑖𝑔𝐵 > < 𝑃𝐾𝐵 > < 𝐷𝑎𝑡𝑎1 > < 𝐷𝑎𝑡𝑎2 > < 𝐷𝑎𝑡𝑎3 >OP_2DUP OP_CAT
401
+ OP_TOALTSTACK
402
+ WP1605
403
+ © nChain Licensing AG
404
+ 12 of 25PUSHTX and Its Building Blocks
405
+ 2< 𝑆𝑖𝑔𝐵 > < 𝑃𝐾𝐵 > < 𝐷𝑎𝑡𝑎1 > < 𝐷𝑎𝑡𝑎2 > < 𝐷𝑎𝑡𝑎3 >
406
+ ALTSTACK: <item 5 to 7>OP_SWAP OP_CAT
407
+ OP_HASH256
408
+ 3< 𝑆𝑖𝑔𝐵 > < 𝑃𝐾𝐵 > < 𝐷𝑎𝑡𝑎1 > <item 9>
409
+ ALTSTACK: <item 5 to 7><item 8> OP_SWAP
410
+ OP_CAT
411
+ 4< 𝑆𝑖𝑔𝐵 > < 𝑃𝐾𝐵 > < 𝐷𝑎𝑡𝑎1 > <item 8 and 9>
412
+ ALTSTACK: <item 5 to 7>OP_FROMALTSTACK
413
+ OP_SWAP OP_CAT
414
+ 5< 𝑆𝑖𝑔𝐵 > < 𝑃𝐾𝐵 > < 𝐷𝑎𝑡𝑎1 > <item 5 to 9>OP_CAT <item 10 and
415
+ 11> OP_CAT
416
+ 6< 𝑆𝑖𝑔𝐵 > < 𝑃𝐾𝐵 > <item 1 to 11>[sign]
417
+ OP_CHECKSIGVERIFY
418
+ 7< 𝑆𝑖𝑔𝐵 > < 𝑃𝐾𝐵 >OP_DUP OP_HASH160
419
+ <H(PK_B)>
420
+ OP_EQUALVERIFY
421
+ OP_CHECKSIG
422
+ 8True
423
+ Further improvement can be made by using the alt stack for storing 𝐺𝑥 and 𝑛. Each of them is
424
+ 𝑛
425
+ of size 32 bytes. As 𝐺𝑐𝑜𝑚𝑝𝑟𝑒𝑠𝑠 is 𝐺𝑥 and 2 can be derived from 𝑛, we can use several opcodes to
426
+ reference them from the alt stack. However, it would introduce complications when designing
427
+ the script. For example, a comparison of two versions of [sign] is shown below.
428
+ Before:
429
+ [sign]:= OP_HASH256 𝐺𝑥 OP_ADD 𝑛 OP_MOD [toDER] SIGHASH_FLAG OP_CAT 𝐺𝑥
430
+ [toDER]:= [toCanonical][concatenations]
431
+ [toCanonical]:= OP_DUP 𝑛/2 OP_GREATERTHAN OP_IF 𝑛 OP_SWAP OP_SUB OP_ENDIF
432
+ [concatenations]:= OP_SIZE OP_DUP <0x24> OP_ADD <0x30> OP_SWAP OP_CAT
433
+ <0220||G_x> OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT
434
+ WP1605
435
+ © nChain Licensing AG
436
+ 13 of 25PUSHTX and Its Building Blocks
437
+ After:
438
+ [sign]:= OP_HASH256 𝐺𝑥 OP_DUP OP_TOALTSTACK OP_ADD 𝑛 OP_DUP OP_TOALTSTACK
439
+ OP_MOD [toDER] SIGHASH_FLAG OP_CAT OP_FROMALTSTACK
440
+ [toDER]:= [toCanonical][concatenations]
441
+ [toCanonical]:= OP_DUP OP_FROMALTSTACK OP_DUP OP_TOALTSTACK OP_2 OP_DIV
442
+ OP_GREATERTHAN OP_IF OP_FROMALTSTACK OP_SWAP OP_SUB OP_ENDIF
443
+ [concatenations]:= OP_SIZE OP_DUP <0x24> OP_ADD <0x30> OP_SWAP OP_CAT
444
+ <0220> OP_FROMALTSTACK OP_DUP OP_TOALTSTACK OP_CAT OP_CAT OP_SWAP OP_CAT
445
+ OP_SWAP OP_CAT
446
+ We added 15 opcodes and removed two instances of 𝐺𝑥 and two instances of 𝑛. The total saving
447
+ is (32 × 2 + 32 × 2) − 15 = 113 bytes. Therefore, the size of the spending transaction 𝑇𝑥𝐼𝐷1 can
448
+ be further reduced to 828 bytes.
449
+ It is safe to say that with all available optimisations, the size of a spending transaction can be
450
+ around 1KB.
451
+ Note that any example scripts shown above are not meant to be used in mainnet transactions.
452
+ They are written for illustration purpose. Some simplifications are implicitly assumed. For
453
+ example, reversing endianness is omitted. For a more practical and comprehensive guide,
454
+ please refer to Appendix.
455
+ WP1605
456
+ © nChain Licensing AG
457
+ 14 of 25PUSHTX and Its Building Blocks
458
+ 2
459
+ Security Analysis
460
+ In this section, we offer some security proofs and analysis around PUSHTX. This is considered a
461
+ formal approach to PUSHTX and some of the insights we described in the previous section.
462
+ First of all, we notice that there are effectively two signatures in the script execution. One is
463
+ created by PUSHTX technique, the other one is provided in the unlocking script for P2PKH. The
464
+ first signature provides data integrity and enables enforcement on the spending transaction,
465
+ while the second provides authenticity and ensure that only the intended recipient can create
466
+ the spending transaction2.
467
+ Claim 1:
468
+ If (𝑟, 𝑠) is a valid ECDSA signature with respect to a public key 𝑃 on the messages 𝑚,
469
+ then it is computationally infeasible to construct 𝑚 ′ such that 𝑚 ′ ≠ 𝑚 and (𝑟, 𝑠) is
470
+ still valid on 𝑚 ′ with respect to 𝑃, assuming that the cryptographic hash function
471
+ used is pre-image resistant and collision resistant.
472
+ Proof:
473
+ let 𝑧 = ℎ𝑎𝑠ℎ(𝑚) and 𝑧 ′ = ℎ𝑎𝑠ℎ(𝑚 ′) for some 𝑚 ′.
474
+ Let 𝑢 = 𝑧𝑠 −1 𝑚𝑜𝑑 𝑛 , 𝑢′ = 𝑧 ′ 𝑠 −1 𝑚𝑜𝑑 𝑛, 𝑣 = 𝑟𝑠 −1 𝑚𝑜𝑑 𝑛, and 𝑅 = 𝑘𝐺 where
475
+ 𝑅𝑥 = 𝑟 𝑚𝑜𝑑 𝑛.
476
+ Also let 𝑅′ denote the points such that 𝑅′ ≠ 𝑅 and 𝑅𝑥′ = 𝑟 𝑚𝑜𝑑 𝑛.
477
+ Note that3 𝑅′ can either be −𝑅 or one of the two points, (𝑥, ±𝑦),
478
+ where 𝑥 = 𝑅𝑥 + 𝑛 if 𝑅𝑥 < 𝑛 and 𝑥 = 𝑅𝑥 − 𝑛 if 𝑅𝑥 > 𝑛.
479
+ So, from the signature verification, we have [𝑢𝐺 + 𝑣𝑃]𝑥 = [𝑢′ 𝐺 + 𝑣𝑃]𝑥 = 𝑟 𝑚𝑜𝑑 𝑛.
480
+ There are two cases to consider.
481
+ Case 1: 𝑢𝐺 + 𝑣𝑃 = 𝑢′ 𝐺 + 𝑣𝑃 = 𝑅
482
+  𝑢 = 𝑢′ 𝑚𝑜𝑑 𝑛
483
+  𝑧 = 𝑧 ′ 𝑚𝑜𝑑 𝑛
484
+  𝑚 = 𝑚 ′ under the assumption that the hash function is collision
485
+ resistant.
486
+ Case 2: 𝑢𝐺 + 𝑣𝑃 = 𝑅 and 𝑢′ 𝐺 + 𝑣𝑃 = 𝑅′
487
+  𝑢′ 𝐺 = 𝑅′ − 𝑣𝑃
488
+  Given that the message 𝑚, the public 𝑃, and the value 𝑟 are all fixed,
489
+ there are maximum three different values that 𝑢′ can take, each of which
490
+ corresponds to a value of 𝑅′.
491
+ In some use cases where authenticity is not required and it is desired to have anyone
492
+ being able to create a spending transaction, the script segment P2PKH can be omitted.
493
+ However, any implications and risks should be analysed and assessed before such
494
+ approach.
495
+ 3
496
+ On secp256k1 curve, the group order 𝑛 is less than the curve modulo 𝑝, but they are of
497
+ the same bit length. Therefore, an equation 𝑥 = 𝑎 𝑚𝑜𝑑 𝑛 will have maximum two solutions
498
+ for 𝑥 ∈ [0, 𝑝 − 1]. The maximum number of solutions can only be achieved when 𝑎 ∈ [0, 𝑝 −
499
+ 𝑛).
500
+ 2
501
+ WP1605
502
+ © nChain Licensing AG
503
+ 15 of 25PUSHTX and Its Building Blocks
504
+  𝑧 ′ = 𝑢′ 𝑠 also has maximum three values.
505
+  Finding 𝑚 ′ such that ℎ𝑎𝑠ℎ(𝑚 ′ ) = 𝑧 ′ where 𝑧 ′ can only be one of the three
506
+ fixed values is computationally infeasible assuming that the hash
507
+ function is pre-image resistant.
508
+ Therefore, we can conclude that it is computationally infeasible to find 𝑚 ′ such that
509
+ 𝑚 ′ ≠ 𝑚 and (𝑟, 𝑠) is still valid on 𝑚 ′ with respect to 𝑃.
510
+ Note that Claim 1 implies that PUSHTX technic is secure to use if we assume that double
511
+ SHA256 is preimage resistant and collision resistant. Moreover, it implies that the data integrity
512
+ is preserved even when we sacrifice authenticity in ECDSA by making both the private key and
513
+ the ephemeral key available to the public.
514
+ Claim 2:
515
+ Public key 𝑃 must be fixed in the locking script.
516
+ Reasoning:
517
+ Suppose 𝑃 is not fixed and (𝑟, 𝑠) is a valid signature with respect to 𝑃 on 𝑚.
518
+ Let 𝑧 ′ = ℎ𝑎𝑠ℎ(𝑚 ′ ). 𝑢′ = 𝑧 ′ 𝑠 −1 , and 𝑣 = 𝑟𝑠 −1
519
+ We want to find 𝑃′ such that 𝑢′ 𝐺 + 𝑣𝑃 ′ = 𝑅
520
+ 𝑃 ′ = 𝑣 −1 (𝑅 − 𝑢′ 𝐺)
521
+ Now (𝑟, 𝑠) is valid with respect to 𝑃 ′ on 𝑚′.
522
+ Therefore 𝑃 must be fixed in the locking script.
523
+ Claim 3:
524
+ 𝑘 should be fixed in the locking script.
525
+ Reasoning:
526
+ Suppose (𝑟, 𝑠) is a valid signature generated in the locking script with respect to 𝑃
527
+ on 𝑚.
528
+ Suppose 𝑘 is not fixed in the locking script and is provided in the unlocking script.
529
+ Then an adversary can:
530
+ 1.intercept the spending transaction, and
531
+ 2.replace 𝑘 with 𝑘′ in the unlocking script.
532
+ Then (𝑟 ′ , 𝑠 ′ ) generated in the locking script will be a valid signature with respect to
533
+ 𝑃 on 𝑚.
534
+ Transaction will still be valid, but the transaction ID is changed.
535
+ Claim 4:
536
+ Sighash flag should be fixed in the locking script.
537
+ Reasoning:
538
+ Suppose (𝑟, 𝑠) is a valid signature generated in the locking script with respect to 𝑃
539
+ on 𝑚.
540
+ Suppose sighash flag is not fixed in the locking script and is provided in the
541
+ unlocking script.
542
+ 1.
543
+ WP1605
544
+ Intercept the spending transaction
545
+ © nChain Licensing AG
546
+ 16 of 25PUSHTX and Its Building Blocks
547
+ 2.Change the sighash flag
548
+ 3.Update the message 𝑚 accordingly to 𝑚 ′.
549
+ In some use case, this would invalidate the transaction. E.g., the locking script
550
+ expects multiple inputs and outputs with sighash flag “ALL”; changing the flag to
551
+ anything else would invalidate the script execution.
552
+ In others, this would change the transaction ID without invalidating the transaction.
553
+ E.g., the locking script only enforces conditions on the outputs of its spending
554
+ transaction; adding or removing “ANYONECANPAY” would not invalidate the
555
+ transaction, but will change the transaction ID.
556
+ WP1605
557
+ © nChain Licensing AG
558
+ 17 of 25PUSHTX and Its Building Blocks
559
+ 3
560
+ Appendix
561
+ All implementations have been tested on regtest on Bitcoin SV v1.0.8. Please be warned that the
562
+ scripts below are for testing purpose only. Any attempt of using them on mainnet should
563
+ undergo thorough testing and rigorous reviews.
564
+ The result shows that a spending transaction is of size 1415 bytes. The overhead is mainly
565
+ coming from reversing endianness. A 32-byte string would require 124 bytes of opcodes to
566
+ reverse its endianness. We need to reverse endianness twice in the locking script. The locking
567
+ script appears both in the unlocking script and the output in the spending transaction.
568
+ Therefore, the total overhead from endianness in our implementation is over 500 bytes. We did
569
+ not use Alt Stack to store 𝐺𝑥 and 𝑛 in our current implementation for simplicity. This would save
570
+ us about 200 bytes in total.
571
+ We present two example locking scripts first and explain what they do. We then present two
572
+ transactions with one spending the other using the second locking script, demonstrating that
573
+ the locking script works and can be spent as expected.
574
+ Locking Script 1 (LS1) – generateSig and checkSig
575
+ "aa517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f51
576
+ 7f517f517f517f517f517f517f517f517f517f517f517f517f517f7c7e7c7e7c7e7c7e7c7
577
+ e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e
578
+ 7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e01007e81209817f8165b81f259d928ce2ddbfc9b0
579
+ 2070b87ce9562a055acbbdcf97e66be799321414136d08c5ed2bf3ba048afe6dcaebafeff
580
+ ffffffffffffffffffffffffffff00977621414136d08c5ed2bf3ba048afe6dcaebafefff
581
+ fffffffffffffffffffffffffff005296a06321414136d08c5ed2bf3ba048afe6dcaebafe
582
+ ffffffffffffffffffffffffffffff007c946882766b6b517f517f517f517f517f517f517
583
+ f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f
584
+ 517f517f517f517f517f517f6c0120a063517f687c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7
585
+ c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c
586
+ 7e7c7e7c7e7c7e7c7e6c0120a0637c7e68827601249301307c7e23022079be667ef9dcbba
587
+ c55a06295ce870b07029bfcdb2dce28d959f2815b16f81798027e7c7e7c7e01417e210279
588
+ be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798ac"
589
+ Input: serialised transaction message for signing as in Section 1.2
590
+ The locking script takes the message 𝑚, and
591
+ 1. double SHA256 on 𝑚 to obtain 𝑧,
592
+ 2. reverse endianness of 𝑧,
593
+ 3. add 0x00 to ensure 𝑧 is not interpreted as a negative number,
594
+ 4. call OP_BIN2NUM to have minimal encoding on 𝑧 (would take care the case when step
595
+ 3 introduces redundancy),
596
+ 5. compute 𝑠 = 𝑧 + 𝐺𝑥 𝑚𝑜𝑑 𝑛,
597
+ 6. convert 𝑠 to 𝑛 − 𝑠 if 𝑠 > 𝑛/2,
598
+ 7. obtain length of 𝑠,
599
+ 8. reverse endianness of 𝑠 (32 bytes),
600
+ 9. reverse one more byte if the length of 𝑠 is greater than 32,
601
+ 10. compute the total length of a DER signature (0x24 + 𝑙𝑒𝑛𝑔𝑡ℎ 𝑜𝑓 𝑠),
602
+ 11. add DER prefix 0x30,
603
+ 12. concatenate 𝑟 = 𝐺𝑥 ,
604
+ WP1605
605
+ © nChain Licensing AG
606
+ 18 of 25PUSHTX and Its Building Blocks
607
+ 13. concatenate 𝑠,
608
+ 14. concatenate sighash flag “ALL”,
609
+ 15. push compressed public key 𝐺𝑥 , and
610
+ 16. call OP_CHECKSIG.
611
+ Note that in step 7 to 9, we have assumed that the length of 𝑠 is either 32 or 33 bytes. However,
612
+ 𝑠 may be shorter than that. Some care should be taken to pad 𝑠 using OP_NUM2BIN if it is too
613
+ short.
614
+ Locking Script 2 (LS2) – constructMsg + LS1 + P2PKH
615
+ "6e810200029458807c7eaa04ffffffff7c7e7e7e7e0800000000410000007eaa517f517f
616
+ 517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f5
617
+ 17f517f517f517f517f517f517f517f517f517f517f7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c
618
+ 7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7
619
+ e7c7e7c7e7c7e7c7e7c7e01007e81209817f8165b81f259d928ce2ddbfc9b02070b87ce95
620
+ 62a055acbbdcf97e66be799321414136d08c5ed2bf3ba048afe6dcaebafefffffffffffff
621
+ fffffffffffffffff00977621414136d08c5ed2bf3ba048afe6dcaebafeffffffffffffff
622
+ ffffffffffffffff005296a06321414136d08c5ed2bf3ba048afe6dcaebafefffffffffff
623
+ fffffffffffffffffff007c946882766b6b517f517f517f517f517f517f517f517f517f51
624
+ 7f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517
625
+ f517f517f517f6c0120a063517f687c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e
626
+ 7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7
627
+ c7e7c7e6c0120a0637c7e68827601249301307c7e23022079be667ef9dcbbac55a06295ce
628
+ 870b07029bfcdb2dce28d959f2815b16f81798027e7c7e7c7e01417e210279be667ef9dcb
629
+ bac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798ad76a914751e76e8199196
630
+ d454941c45d1b3a323f1433bd688ac"
631
+ Input: <𝑆𝑖𝑔> <𝑃𝐾> <Item 1 to 4> <Item 5 and 6> <Item 7>
632
+ The locking script takes a pair of signature and public key, and item 1 to 7 as in the table in
633
+ Section 1.2 in three PUSHDATA operations, and
634
+ 1.
635
+ take the previous value and work out the new output value (subtracting a fixed
636
+ transaction fee),
637
+ 2. take the previous locking script as the new locking script for the new output,
638
+ 3. concatenate the new output value and new locking script to obtain the new output,
639
+ 4. double SHA256 the new output to obtain the hash of outputs (item 9),
640
+ 5. push sequence number (item 8),
641
+ 6. concatenate to get message string (item 1 to 9),
642
+ 7. push locktime and sigahash flag (item 10 and 11),
643
+ 8. concatenate to obtain the message to be signed 𝑚,
644
+ 9. call LS1 with OP_CHECKSIGVERIFY, and
645
+ 10. call P2PKH to check 𝑆𝑖𝑔 with respect to 𝑃𝐾.
646
+ Transaction 0 – genesis transaction
647
+ {
648
+ "txid":
649
+ "88b9d41101a4c064b283f80ca73837d96f974bc3fbe931b35db7bca8370cca34",
650
+ "hash":
651
+ "88b9d41101a4c064b283f80ca73837d96f974bc3fbe931b35db7bca8370cca34",
652
+ "version": 1,
653
+ "size": 730,
654
+ "locktime": 0,
655
+ WP1605
656
+ © nChain Licensing AG
657
+ 19 of 25PUSHTX and Its Building Blocks
658
+ "vin": [
659
+ {
660
+ "txid":
661
+ "52685bdbaae5c76887c23cee699bc48f293192a313c19b9fad4c77b993655df5",
662
+ "vout": 0,
663
+ "scriptSig": {
664
+ "asm":
665
+ "3044022079be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798
666
+ 02201229c3605c61c4133b282cc30ece9e7d5c3693bf2cd1c03a3caadcd9f25900a5[ALL|
667
+ FORKID]
668
+ 0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798",
669
+ "hex":
670
+ "473044022079be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f817
671
+ 9802201229c3605c61c4133b282cc30ece9e7d5c3693bf2cd1c03a3caadcd9f25900a5412
672
+ 10279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"
673
+ },
674
+ "sequence": 4294967295
675
+ }
676
+ ],
677
+ "vout": [
678
+ {
679
+ "value": 49.99999388,
680
+ "n": 0,
681
+ "scriptPubKey": {
682
+ "asm": "OP_2DUP OP_BIN2NUM 512 OP_SUB 8 OP_NUM2BIN OP_SWAP OP_CAT
683
+ OP_HASH256 -2147483647 OP_SWAP OP_CAT OP_CAT OP_CAT OP_CAT
684
+ 0000000041000000 OP_CAT OP_HASH256 1 OP_SPLIT 1 OP_SPLIT 1 OP_SPLIT 1
685
+ OP_SPLIT 1 OP_SPLIT 1 OP_SPLIT 1 OP_SPLIT 1 OP_SPLIT 1 OP_SPLIT 1
686
+ OP_SPLIT 1 OP_SPLIT 1 OP_SPLIT 1 OP_SPLIT 1 OP_SPLIT 1 OP_SPLIT 1
687
+ OP_SPLIT 1 OP_SPLIT 1 OP_SPLIT 1 OP_SPLIT 1 OP_SPLIT 1 OP_SPLIT 1
688
+ OP_SPLIT 1 OP_SPLIT 1 OP_SPLIT 1 OP_SPLIT 1 OP_SPLIT 1 OP_SPLIT 1
689
+ OP_SPLIT 1 OP_SPLIT 1 OP_SPLIT 1 OP_SPLIT OP_SWAP OP_CAT OP_SWAP OP_CAT
690
+ OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP
691
+ OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT
692
+ OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP
693
+ OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT
694
+ OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP
695
+ OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT
696
+ OP_SWAP OP_CAT OP_SWAP OP_CAT 0 OP_CAT OP_BIN2NUM
697
+ 9817f8165b81f259d928ce2ddbfc9b02070b87ce9562a055acbbdcf97e66be79 OP_ADD
698
+ 414136d08c5ed2bf3ba048afe6dcaebafeffffffffffffffffffffffffffffff00 OP_MOD
699
+ OP_DUP 414136d08c5ed2bf3ba048afe6dcaebafeffffffffffffffffffffffffffffff00
700
+ 2 OP_DIV OP_GREATERTHAN OP_IF
701
+ 414136d08c5ed2bf3ba048afe6dcaebafeffffffffffffffffffffffffffffff00
702
+ OP_SWAP OP_SUB OP_ENDIF OP_SIZE OP_DUP OP_TOALTSTACK OP_TOALTSTACK 1
703
+ OP_SPLIT 1 OP_SPLIT 1 OP_SPLIT 1 OP_SPLIT 1 OP_SPLIT 1 OP_SPLIT 1
704
+ OP_SPLIT 1 OP_SPLIT 1 OP_SPLIT 1 OP_SPLIT 1 OP_SPLIT 1 OP_SPLIT 1
705
+ OP_SPLIT 1 OP_SPLIT 1 OP_SPLIT 1 OP_SPLIT 1 OP_SPLIT 1 OP_SPLIT 1
706
+ OP_SPLIT 1 OP_SPLIT 1 OP_SPLIT 1 OP_SPLIT 1 OP_SPLIT 1 OP_SPLIT 1
707
+ OP_SPLIT 1 OP_SPLIT 1 OP_SPLIT 1 OP_SPLIT 1 OP_SPLIT 1 OP_SPLIT 1
708
+ OP_SPLIT OP_FROMALTSTACK 32 OP_GREATERTHAN OP_IF 1 OP_SPLIT OP_ENDIF
709
+ WP1605
710
+ © nChain Licensing AG
711
+ 20 of 25PUSHTX and Its Building Blocks
712
+ OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP
713
+ OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT
714
+ OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP
715
+ OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT
716
+ OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP
717
+ OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT
718
+ OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT
719
+ OP_FROMALTSTACK 32 OP_GREATERTHAN OP_IF OP_SWAP OP_CAT OP_ENDIF OP_SIZE
720
+ OP_DUP 36 OP_ADD 48 OP_SWAP OP_CAT
721
+ 022079be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f8179802
722
+ OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT 65 OP_CAT
723
+ 0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798
724
+ OP_CHECKSIGVERIFY OP_DUP OP_HASH160
725
+ 751e76e8199196d454941c45d1b3a323f1433bd6 OP_EQUALVERIFY OP_CHECKSIG",
726
+ "hex":
727
+ "6e810200029458807c7eaa04ffffffff7c7e7e7e7e0800000000410000007eaa517f517f
728
+ 517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f5
729
+ 17f517f517f517f517f517f517f517f517f517f517f7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c
730
+ 7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7
731
+ e7c7e7c7e7c7e7c7e7c7e01007e81209817f8165b81f259d928ce2ddbfc9b02070b87ce95
732
+ 62a055acbbdcf97e66be799321414136d08c5ed2bf3ba048afe6dcaebafefffffffffffff
733
+ fffffffffffffffff00977621414136d08c5ed2bf3ba048afe6dcaebafeffffffffffffff
734
+ ffffffffffffffff005296a06321414136d08c5ed2bf3ba048afe6dcaebafefffffffffff
735
+ fffffffffffffffffff007c946882766b6b517f517f517f517f517f517f517f517f517f51
736
+ 7f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517
737
+ f517f517f517f6c0120a063517f687c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e
738
+ 7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7
739
+ c7e7c7e6c0120a0637c7e68827601249301307c7e23022079be667ef9dcbbac55a06295ce
740
+ 870b07029bfcdb2dce28d959f2815b16f81798027e7c7e7c7e01417e210279be667ef9dcb
741
+ bac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798ad76a914751e76e8199196
742
+ d454941c45d1b3a323f1433bd688ac",
743
+ "type": "nonstandard"
744
+ }
745
+ }
746
+ ],
747
+ "hex":
748
+ "0100000001f55d6593b9774cad9f9bc113a39231298fc49b69ee3cc28768c7e5aadb5b68
749
+ 52000000006a473044022079be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f
750
+ 2815b16f8179802201229c3605c61c4133b282cc30ece9e7d5c3693bf2cd1c03a3caadcd9
751
+ f25900a541210279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f
752
+ 81798ffffffff019cef052a01000000fd32026e810200029458807c7eaa04ffffffff7c7e
753
+ 7e7e7e0800000000410000007eaa517f517f517f517f517f517f517f517f517f517f517f5
754
+ 17f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f51
755
+ 7f517f7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7
756
+ e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e01007e81209817f8
757
+ 165b81f259d928ce2ddbfc9b02070b87ce9562a055acbbdcf97e66be799321414136d08c5
758
+ ed2bf3ba048afe6dcaebafeffffffffffffffffffffffffffffff00977621414136d08c5e
759
+ d2bf3ba048afe6dcaebafeffffffffffffffffffffffffffffff005296a06321414136d08
760
+ c5ed2bf3ba048afe6dcaebafeffffffffffffffffffffffffffffff007c946882766b6b51
761
+ 7f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517
762
+ f517f517f517f517f517f517f517f517f517f517f517f517f6c0120a063517f687c7e7c7e
763
+ WP1605
764
+ © nChain Licensing AG
765
+ 21 of 25PUSHTX and Its Building Blocks
766
+ 7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7
767
+ c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e6c0120a0637c7e6882760124930130
768
+ 7c7e23022079be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f8179
769
+ 8027e7c7e7c7e01417e210279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959
770
+ f2815b16f81798ad76a914751e76e8199196d454941c45d1b3a323f1433bd688ac0000000
771
+ 0"
772
+ }
773
+ Transaction 1 – spending transaction
774
+ {
775
+ "txid":
776
+ "c700e1d6c995e4c77014536d4431be84d7fb40d3fbef52ed85be2ad06414eac8",
777
+ "hash":
778
+ "c700e1d6c995e4c77014536d4431be84d7fb40d3fbef52ed85be2ad06414eac8",
779
+ "version": 1,
780
+ "size": 1415,
781
+ "locktime": 0,
782
+ "vin": [
783
+ {
784
+ "txid":
785
+ "88b9d41101a4c064b283f80ca73837d96f974bc3fbe931b35db7bca8370cca34",
786
+ "vout": 0,
787
+ "scriptSig": {
788
+ "asm":
789
+ "3044022079be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798
790
+ 0220388bd5f619c02287145cf0bb3bc440f883b09e35e67a4adcf50635800219ed34[ALL|
791
+ FORKID]
792
+ 0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798
793
+ 01000000fb472de1f838d9560dc7b19b1ab62b0c6ed60580779017d3cd32d22bcc051ce13
794
+ bb13029ce7b1f559ef5e747fcac439f1455a2ec7c5f09b72290795e7066504434ca0c37a8
795
+ bcb75db331e9fbc34b976fd93738a70cf883b264c0a40111d4b98800000000
796
+ fd32026e810200029458807c7eaa04ffffffff7c7e7e7e7e0800000000410000007eaa517
797
+ f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f
798
+ 517f517f517f517f517f517f517f517f517f517f517f517f7c7e7c7e7c7e7c7e7c7e7c7e7
799
+ c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c
800
+ 7e7c7e7c7e7c7e7c7e7c7e7c7e01007e81209817f8165b81f259d928ce2ddbfc9b02070b8
801
+ 7ce9562a055acbbdcf97e66be799321414136d08c5ed2bf3ba048afe6dcaebafeffffffff
802
+ ffffffffffffffffffffff00977621414136d08c5ed2bf3ba048afe6dcaebafefffffffff
803
+ fffffffffffffffffffff005296a06321414136d08c5ed2bf3ba048afe6dcaebafeffffff
804
+ ffffffffffffffffffffffff007c946882766b6b517f517f517f517f517f517f517f517f5
805
+ 17f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f51
806
+ 7f517f517f517f517f6c0120a063517f687c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7
807
+ e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e
808
+ 7c7e7c7e7c7e6c0120a0637c7e68827601249301307c7e23022079be667ef9dcbbac55a06
809
+ 295ce870b07029bfcdb2dce28d959f2815b16f81798027e7c7e7c7e01417e210279be667e
810
+ f9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798ad76a914751e76e81
811
+ 99196d454941c45d1b3a323f1433bd688ac 9cef052a01000000",
812
+ "hex":
813
+ "473044022079be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f817
814
+ 980220388bd5f619c02287145cf0bb3bc440f883b09e35e67a4adcf50635800219ed34412
815
+ 10279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f817984c6801
816
+ WP1605
817
+ © nChain Licensing AG
818
+ 22 of 25PUSHTX and Its Building Blocks
819
+ 000000fb472de1f838d9560dc7b19b1ab62b0c6ed60580779017d3cd32d22bcc051ce13bb
820
+ 13029ce7b1f559ef5e747fcac439f1455a2ec7c5f09b72290795e7066504434ca0c37a8bc
821
+ b75db331e9fbc34b976fd93738a70cf883b264c0a40111d4b988000000004d3502fd32026
822
+ e810200029458807c7eaa04ffffffff7c7e7e7e7e0800000000410000007eaa517f517f51
823
+ 7f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517
824
+ f517f517f517f517f517f517f517f517f517f517f7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e
825
+ 7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7
826
+ c7e7c7e7c7e7c7e7c7e01007e81209817f8165b81f259d928ce2ddbfc9b02070b87ce9562
827
+ a055acbbdcf97e66be799321414136d08c5ed2bf3ba048afe6dcaebafefffffffffffffff
828
+ fffffffffffffff00977621414136d08c5ed2bf3ba048afe6dcaebafeffffffffffffffff
829
+ ffffffffffffff005296a06321414136d08c5ed2bf3ba048afe6dcaebafefffffffffffff
830
+ fffffffffffffffff007c946882766b6b517f517f517f517f517f517f517f517f517f517f
831
+ 517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f5
832
+ 17f517f517f6c0120a063517f687c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c
833
+ 7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7
834
+ e7c7e6c0120a0637c7e68827601249301307c7e23022079be667ef9dcbbac55a06295ce87
835
+ 0b07029bfcdb2dce28d959f2815b16f81798027e7c7e7c7e01417e210279be667ef9dcbba
836
+ c55a06295ce870b07029bfcdb2dce28d959f2815b16f81798ad76a914751e76e8199196d4
837
+ 54941c45d1b3a323f1433bd688ac089cef052a01000000"
838
+ },
839
+ "sequence": 4294967295
840
+ }
841
+ ],
842
+ "vout": [
843
+ {
844
+ "value": 49.99998876,
845
+ "n": 0,
846
+ "scriptPubKey": {
847
+ "asm": "OP_2DUP OP_BIN2NUM 512 OP_SUB 8 OP_NUM2BIN OP_SWAP OP_CAT
848
+ OP_HASH256 -2147483647 OP_SWAP OP_CAT OP_CAT OP_CAT OP_CAT
849
+ 0000000041000000 OP_CAT OP_HASH256 1 OP_SPLIT 1 OP_SPLIT 1 OP_SPLIT 1
850
+ OP_SPLIT 1 OP_SPLIT 1 OP_SPLIT 1 OP_SPLIT 1 OP_SPLIT 1 OP_SPLIT 1
851
+ OP_SPLIT 1 OP_SPLIT 1 OP_SPLIT 1 OP_SPLIT 1 OP_SPLIT 1 OP_SPLIT 1
852
+ OP_SPLIT 1 OP_SPLIT 1 OP_SPLIT 1 OP_SPLIT 1 OP_SPLIT 1 OP_SPLIT 1
853
+ OP_SPLIT 1 OP_SPLIT 1 OP_SPLIT 1 OP_SPLIT 1 OP_SPLIT 1 OP_SPLIT 1
854
+ OP_SPLIT 1 OP_SPLIT 1 OP_SPLIT 1 OP_SPLIT OP_SWAP OP_CAT OP_SWAP OP_CAT
855
+ OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP
856
+ OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT
857
+ OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP
858
+ OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT
859
+ OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP
860
+ OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT
861
+ OP_SWAP OP_CAT OP_SWAP OP_CAT 0 OP_CAT OP_BIN2NUM
862
+ 9817f8165b81f259d928ce2ddbfc9b02070b87ce9562a055acbbdcf97e66be79 OP_ADD
863
+ 414136d08c5ed2bf3ba048afe6dcaebafeffffffffffffffffffffffffffffff00 OP_MOD
864
+ OP_DUP 414136d08c5ed2bf3ba048afe6dcaebafeffffffffffffffffffffffffffffff00
865
+ 2 OP_DIV OP_GREATERTHAN OP_IF
866
+ 414136d08c5ed2bf3ba048afe6dcaebafeffffffffffffffffffffffffffffff00
867
+ OP_SWAP OP_SUB OP_ENDIF OP_SIZE OP_DUP OP_TOALTSTACK OP_TOALTSTACK 1
868
+ OP_SPLIT 1 OP_SPLIT 1 OP_SPLIT 1 OP_SPLIT 1 OP_SPLIT 1 OP_SPLIT 1
869
+ OP_SPLIT 1 OP_SPLIT 1 OP_SPLIT 1 OP_SPLIT 1 OP_SPLIT 1 OP_SPLIT 1
870
+ WP1605
871
+ © nChain Licensing AG
872
+ 23 of 25PUSHTX and Its Building Blocks
873
+ OP_SPLIT 1 OP_SPLIT 1 OP_SPLIT 1 OP_SPLIT 1 OP_SPLIT 1 OP_SPLIT 1
874
+ OP_SPLIT 1 OP_SPLIT 1 OP_SPLIT 1 OP_SPLIT 1 OP_SPLIT 1 OP_SPLIT 1
875
+ OP_SPLIT 1 OP_SPLIT 1 OP_SPLIT 1 OP_SPLIT 1 OP_SPLIT 1 OP_SPLIT 1
876
+ OP_SPLIT OP_FROMALTSTACK 32 OP_GREATERTHAN OP_IF 1 OP_SPLIT OP_ENDIF
877
+ OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP
878
+ OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT
879
+ OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP
880
+ OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT
881
+ OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP
882
+ OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT
883
+ OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT
884
+ OP_FROMALTSTACK 32 OP_GREATERTHAN OP_IF OP_SWAP OP_CAT OP_ENDIF OP_SIZE
885
+ OP_DUP 36 OP_ADD 48 OP_SWAP OP_CAT
886
+ 022079be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f8179802
887
+ OP_CAT OP_SWAP OP_CAT OP_SWAP OP_CAT 65 OP_CAT
888
+ 0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798
889
+ OP_CHECKSIGVERIFY OP_DUP OP_HASH160
890
+ 751e76e8199196d454941c45d1b3a323f1433bd6 OP_EQUALVERIFY OP_CHECKSIG",
891
+ "hex":
892
+ "6e810200029458807c7eaa04ffffffff7c7e7e7e7e0800000000410000007eaa517f517f
893
+ 517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f5
894
+ 17f517f517f517f517f517f517f517f517f517f517f7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c
895
+ 7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7
896
+ e7c7e7c7e7c7e7c7e7c7e01007e81209817f8165b81f259d928ce2ddbfc9b02070b87ce95
897
+ 62a055acbbdcf97e66be799321414136d08c5ed2bf3ba048afe6dcaebafefffffffffffff
898
+ fffffffffffffffff00977621414136d08c5ed2bf3ba048afe6dcaebafeffffffffffffff
899
+ ffffffffffffffff005296a06321414136d08c5ed2bf3ba048afe6dcaebafefffffffffff
900
+ fffffffffffffffffff007c946882766b6b517f517f517f517f517f517f517f517f517f51
901
+ 7f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517
902
+ f517f517f517f6c0120a063517f687c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e
903
+ 7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7
904
+ c7e7c7e6c0120a0637c7e68827601249301307c7e23022079be667ef9dcbbac55a06295ce
905
+ 870b07029bfcdb2dce28d959f2815b16f81798027e7c7e7c7e01417e210279be667ef9dcb
906
+ bac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798ad76a914751e76e8199196
907
+ d454941c45d1b3a323f1433bd688ac",
908
+ "type": "nonstandard"
909
+ }
910
+ }
911
+ ],
912
+ "hex":
913
+ "010000000134ca0c37a8bcb75db331e9fbc34b976fd93738a70cf883b264c0a40111d4b9
914
+ 8800000000fd1503473044022079be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d
915
+ 959f2815b16f817980220388bd5f619c02287145cf0bb3bc440f883b09e35e67a4adcf506
916
+ 35800219ed3441210279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815
917
+ b16f817984c6801000000fb472de1f838d9560dc7b19b1ab62b0c6ed60580779017d3cd32
918
+ d22bcc051ce13bb13029ce7b1f559ef5e747fcac439f1455a2ec7c5f09b72290795e70665
919
+ 04434ca0c37a8bcb75db331e9fbc34b976fd93738a70cf883b264c0a40111d4b988000000
920
+ 004d3502fd32026e810200029458807c7eaa04ffffffff7c7e7e7e7e08000000004100000
921
+ 07eaa517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f
922
+ 517f517f517f517f517f517f517f517f517f517f517f517f517f517f7c7e7c7e7c7e7c7e7
923
+ c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c
924
+ WP1605
925
+ © nChain Licensing AG
926
+ 24 of 25PUSHTX and Its Building Blocks
927
+ 7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e01007e81209817f8165b81f259d928ce2ddbfc9
928
+ b02070b87ce9562a055acbbdcf97e66be799321414136d08c5ed2bf3ba048afe6dcaebafe
929
+ ffffffffffffffffffffffffffffff00977621414136d08c5ed2bf3ba048afe6dcaebafef
930
+ fffffffffffffffffffffffffffff005296a06321414136d08c5ed2bf3ba048afe6dcaeba
931
+ feffffffffffffffffffffffffffffff007c946882766b6b517f517f517f517f517f517f5
932
+ 17f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f51
933
+ 7f517f517f517f517f517f517f6c0120a063517f687c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7
934
+ e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e
935
+ 7c7e7c7e7c7e7c7e7c7e6c0120a0637c7e68827601249301307c7e23022079be667ef9dcb
936
+ bac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798027e7c7e7c7e01417e2102
937
+ 79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798ad76a9147
938
+ 51e76e8199196d454941c45d1b3a323f1433bd688ac089cef052a01000000ffffffff019c
939
+ ed052a01000000fd32026e810200029458807c7eaa04ffffffff7c7e7e7e7e08000000004
940
+ 10000007eaa517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f51
941
+ 7f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f7c7e7c7e7c7
942
+ e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e
943
+ 7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e01007e81209817f8165b81f259d928ce2
944
+ ddbfc9b02070b87ce9562a055acbbdcf97e66be799321414136d08c5ed2bf3ba048afe6dc
945
+ aebafeffffffffffffffffffffffffffffff00977621414136d08c5ed2bf3ba048afe6dca
946
+ ebafeffffffffffffffffffffffffffffff005296a06321414136d08c5ed2bf3ba048afe6
947
+ dcaebafeffffffffffffffffffffffffffffff007c946882766b6b517f517f517f517f517
948
+ f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f517f
949
+ 517f517f517f517f517f517f517f517f6c0120a063517f687c7e7c7e7c7e7c7e7c7e7c7e7
950
+ c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c7e7c
951
+ 7e7c7e7c7e7c7e7c7e7c7e7c7e6c0120a0637c7e68827601249301307c7e23022079be667
952
+ ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798027e7c7e7c7e0141
953
+ 7e210279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798ad7
954
+ 6a914751e76e8199196d454941c45d1b3a323f1433bd688ac00000000"
955
+ }
956
+ WP1605
957
+ © nChain Licensing AG
958
+ 25 of 25