Skip to content

Commit 2218f69

Browse files
authored
BIP352: Improve input_hash wording (bitcoin#1629)
BIP352: Improve `input_hash` wording
2 parents 2a99b8f + 8ac84bd commit 2218f69

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

bip-0352.mediawiki

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -279,12 +279,6 @@ The sender performs the tweak using the private key for the nested ''P2WPKH'' ou
279279
280280
The receiver obtains the public key from the ''scriptSig''. The receiver MUST parse the ''scriptSig'' for the public key, even if the ''scriptSig'' does not match the template specified (e.g. <code><dummy> OP_DROP <Signature> <Public Key></code>). This is to address the [https://en.bitcoin.it/wiki/Transaction_malleability third-party malleability of ''P2PKH'' ''scriptSigs''].
281281

282-
=== Input hash ===
283-
284-
The sender and receiver MUST calculate an input hash for the transaction in the following manner:
285-
286-
* Let ''input_hash = hash<sub>BIP0352/Inputs</sub>(outpoint<sub>L</sub> || A)'', where ''outpoint<sub>L</sub>'' is the smallest outpoint lexicographically by txid and vout used in the transaction<ref name="why_smallest_outpoint"></ref>
287-
288282
=== Sender ===
289283

290284
==== Selecting inputs ====
@@ -303,7 +297,7 @@ After the inputs have been selected, the sender can create one or more outputs f
303297
* For each private key ''a<sub>i</sub>'' corresponding to a [https://github.com/bitcoin/bips/blob/master/bip-0341.mediawiki BIP341] taproot output, check that the private key produces a point with an even Y coordinate and negate the private key if not<ref name="why_negate_taproot_private_keys">'''Why do taproot private keys need to be checked?''' Recall from [https://github.com/bitcoin/bips/blob/master/bip-0340.mediawiki BIP340] that each X-only public key has two corresponding private keys, ''d'' and ''n - d''. To maintain parity between sender and receiver, it is necessary to use the private key corresponding to the even Y coordinate when performing the ECDH step since the receiver will assume the even Y coordinate when summing the taproot X-only public keys.</ref>
304298
* 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
305299
** If ''a = 0'', fail
306-
* Generate the ''input_hash'' with the smallest outpoint lexicographically and ''A = a·G'', using the method described above
300+
* 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''
307301
* 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>'')
308302
* For each group:
309303
** Let ''ecdh_shared_secret = input_hash·a·B<sub>scan</sub>''
@@ -336,7 +330,7 @@ If each of the checks in ''[[#scanning-silent-payment-eligible-transactions|Scan
336330

337331
* 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
338332
** If ''A'' is the point at infinity, skip the transaction
339-
* Generate the ''input_hash'' with the smallest outpoint lexicographically and ''A'', using the method described above
333+
* 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>
340334
* Let ''ecdh_shared_secret = input_hash·b<sub>scan</sub>·A''
341335
* Check for outputs:
342336
** Let ''outputs_to_check'' be the taproot output keys from all taproot outputs in the transaction (spent and unspent).

0 commit comments

Comments
 (0)