Skip to content

Commit ff5703c

Browse files
committed
443: fix some errors in the python pseudocode and a wrong reference.
1 parent e22eaa5 commit ff5703c

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

bip-0443.mediawiki

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ exhaustive, as there are many more possible combinations.
100100
in the same transaction, or multiple times with the ''deduct'' logic. This prevents duplicate or inconsistent counting
101101
of the same amounts.
102102

103-
'''Remark:''' it is allowed to check for multiple inputs to check the same output with the ''default'' logic. This
103+
'''Remark:''' it is allowed for multiple inputs to check the same output with the ''default'' logic. This
104104
allows multiple inputs to aggregate (in full or in part) their amounts to the same output.
105105

106106
-----
@@ -176,7 +176,7 @@ would always be hard-coded via a push in the script, the risk of mistakes seems
176176

177177
The following values of the other parameters have special meanings:
178178
* If the <code><taptree></code> is -1, it is replaced with the Merkle root of the current input's tapscript tree. If the taptree is the empty buffer, then the taptweak is skipped.
179-
* If the <code><pk></code> is 0, it is replaced with the NUMS x-only pubkey <code>0x50929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac0</code> defined in [[bip-0340.mediawiki|BIP-340]]. If the <code><pk></code> is -1, it is replaced with the taproot internal key of the current input.
179+
* If the <code><pk></code> is 0, it is replaced with the NUMS x-only pubkey <code>0x50929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac0</code> defined in [[bip-0341.mediawiki|BIP-341]]. If the <code><pk></code> is -1, it is replaced with the taproot internal key of the current input.
180180
* If the <code><index></code> is -1, it is replaced with the index of the current input.
181181
* If the <code><data></code> is the empty buffer, then there is no data tweak for the input/output being checked.
182182
@@ -190,13 +190,17 @@ The specification is divided into three parts:
190190
* the input initialization;
191191
* the opcode evaluation.
192192
193-
The following helper function is a version of <code>taproot_tweak_pubkey</code>, except that a raw 32-byte data is used
194-
as the tweak.
193+
The following helper function is a variant of <code>taproot_tweak_pubkey</code> from [[bip-0341.mediawiki|BIP341]],
194+
except that a regular SHA256-hash is used instead of a tagged hash, and the pubkey is returned unchanged if the length
195+
of <code>data</code> is 0.
195196

196197
<source lang="python">
197198
def tweak_embed_data(pubkey, data):
198199
assert len(pubkey) == 32
199200

201+
if len(data) == 0:
202+
return None, pubkey
203+
200204
data_tweak = sha256(pubkey + data)
201205

202206
t = int_from_bytes(data_tweak)
@@ -209,7 +213,7 @@ def tweak_embed_data(pubkey, data):
209213
return 0 if has_even_y(Q) else 1, bytes_from_int(x(Q))
210214
</source>
211215

212-
The <code>taproot_tweak_pubkey</code> from [[bip-0341.mediawiki|BIP-341]] is also used as a helper function.
216+
The <code>taproot_tweak_pubkey</code> function is also used as a helper in the pseudocode below.
213217

214218
The following notations are used in the pseudocode below:
215219
* <code>n_inputs</code> and <code>n_outputs</code> are the number of inputs and outputs of the transaction, respectively;

0 commit comments

Comments
 (0)