Skip to content

Commit 0a8c271

Browse files
authored
Merge pull request #1902 from josibake/bip352-updates
BIP352: be explicit for the input_hash corner case
2 parents e8c0202 + c70bc9f commit 0a8c271

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

bip-0352.mediawiki

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -298,13 +298,14 @@ After the inputs have been selected, the sender can create one or more outputs f
298298
* Let ''a = a<sub>1</sub> + a<sub>2</sub> + ... + a<sub>n</sub>'', where each ''a<sub>i</sub>'' has been negated if necessary
299299
** If ''a = 0'', fail
300300
* Let ''input_hash = hash<sub>BIP0352/Inputs</sub>(outpoint<sub>L</sub> || A)'', where ''outpoint<sub>L</sub>'' is the smallest ''outpoint'' lexicographically used in the transaction<ref name="why_smallest_outpoint"></ref> and ''A = a·G''
301+
** If ''input_hash'' is not a valid scalar, i.e., if ''input_hash = 0'' or ''input_hash'' is larger or equal to the secp256k1 group order, fail
301302
* Group receiver silent payment addresses by ''B<sub>scan</sub>'' (e.g. each group consists of one ''B<sub>scan</sub>'' and one or more ''B<sub>m</sub>'')
302303
* For each group:
303304
** Let ''ecdh_shared_secret = input_hash·a·B<sub>scan</sub>''
304305
** Let ''k = 0''
305306
** For each ''B<sub>m</sub>'' in the group:
306307
*** Let ''t<sub>k</sub> = hash<sub>BIP0352/SharedSecret</sub>(ser<sub>P</sub>(ecdh_shared_secret) || ser<sub>32</sub>(k))''
307-
**** If ''t<sub>k</sub>'' is not valid tweak, i.e., if ''t<sub>k</sub> = 0'' or ''t<sub>k</sub>'' is larger or equal to the secp256k1 group order, fail
308+
**** If ''t<sub>k</sub>'' is not a valid scalar, i.e., if ''t<sub>k</sub> = 0'' or ''t<sub>k</sub>'' is larger or equal to the secp256k1 group order, fail
308309
*** Let ''P<sub>mn</sub> = B<sub>m</sub> + t<sub>k</sub>·G''
309310
*** Encode ''P<sub>mn</sub>'' as a [https://github.com/bitcoin/bips/blob/master/bip-0341.mediawiki BIP341] taproot output
310311
*** Optionally, repeat with k++ to create additional outputs for the current ''B<sub>m</sub>''
@@ -331,12 +332,13 @@ If each of the checks in ''[[#scanning-silent-payment-eligible-transactions|Scan
331332
* Let ''A = A<sub>1</sub> + A<sub>2</sub> + ... + A<sub>n</sub>'', where each ''A<sub>i</sub>'' is the public key of an input from the ''[[#inputs-for-shared-secret-derivation|Inputs For Shared Secret Derivation]]'' list
332333
** If ''A'' is the point at infinity, skip the transaction
333334
* Let ''input_hash = hash<sub>BIP0352/Inputs</sub>(outpoint<sub>L</sub> || A)'', where ''outpoint<sub>L</sub>'' is the smallest ''outpoint'' lexicographically used in the transaction<ref name="why_smallest_outpoint"></ref>
335+
** If ''input_hash'' is not a valid scalar, i.e., if ''input_hash = 0'' or ''input_hash'' is larger or equal to the secp256k1 group order, fail
334336
* Let ''ecdh_shared_secret = input_hash·b<sub>scan</sub>·A''
335337
* Check for outputs:
336338
** Let ''outputs_to_check'' be the taproot output keys from all taproot outputs in the transaction (spent and unspent).
337339
** Starting with ''k = 0'':
338340
*** Let ''t<sub>k</sub> = hash<sub>BIP0352/SharedSecret</sub>(ser<sub>P</sub>(ecdh_shared_secret) || ser<sub>32</sub>(k))''
339-
**** If ''t<sub>k</sub>'' is not valid tweak, i.e., if ''t<sub>k</sub> = 0'' or ''t<sub>k</sub>'' is larger or equal to the secp256k1 group order, fail
341+
**** If ''t<sub>k</sub>'' is not a valid scalar, i.e., if ''t<sub>k</sub> = 0'' or ''t<sub>k</sub>'' is larger or equal to the secp256k1 group order, fail
340342
*** Compute ''P<sub>k</sub> = B<sub>spend</sub> + t<sub>k</sub>·G''
341343
*** For each ''output'' in ''outputs_to_check'':
342344
**** If ''P<sub>k</sub>'' equals ''output'':
@@ -484,6 +486,8 @@ The <code>MAJOR</code> version is incremented if changes to the BIP are introduc
484486
The <code>MINOR</code> version is incremented whenever the inputs or the output of an algorithm changes in a backward-compatible way or new backward-compatible functionality is added.
485487
The <code>PATCH</code> version is incremented for other changes that are noteworthy (bug fixes, test vectors, important clarifications, etc.).
486488

489+
* '''1.0.2''' (2025-07-25):
490+
** Clarify how to handle the improbable corner case where the output of SHA256 is equal to 0 or greater than or equal to the secp256k1 curve order.
487491
* '''1.0.1''' (2024-06-22):
488492
** Add steps to fail if private key sum is zero (for sender) or public key sum is point at infinity (for receiver), add corresponding test vectors.
489493
* '''1.0.0''' (2024-05-08):

0 commit comments

Comments
 (0)