<oembed><type>rich</type><version>1.0</version><author_name>npub1dw88wd5gqsqn6ufxhf9h03uk8087l7gfzdtez5csjlt6pupu4pwsj8plrw</author_name><author_url>https://nostr.ae/npub1dw88wd5gqsqn6ufxhf9h03uk8087l7gfzdtez5csjlt6pupu4pwsj8plrw</author_url><provider_name>njump</provider_name><provider_url>https://nostr.ae</provider_url><html>📅 Original date posted:2020-05-01&#xA;📝 Original message:While I&#39;m not entirely convinced yet that accertaining non-ownership of an&#xA;input is a robust method of solving the problem here, I also see little&#xA;reason not to amend BIP-341 as proposed. The ScriptPubKeys in question is&#xA;already indirectly covered through the outpoints, so it is just a matter of&#xA;optimization.  Furthermore in the consensus code, the ScriptPubKeys are&#xA;part of the UTXO data set, and it is already being retrieved as part of the&#xA;transaction checking process, so it is readily available.&#xA;&#xA;I&#39;m not sure how much my opinion on the topic matters, but I did include&#xA;this kind of functionality in my design for Simplicity on Elements, and I&#xA;have been leaning towards adding this kind of functionality in my Bitcoin&#xA;demo application of Simplicity.&#xA;&#xA;Regarding specifics, I personally think it would be better to keep the&#xA;hashes of the ScriptPubKeys separate from the hashes of the input values.&#xA;This way anyone only interested in input values does not need to wade&#xA;through what are, in principle, arbitrarily long ScriptPubKeys in order to&#xA;check the input values (which each fixed size).  To that end, I would also&#xA;(and independently) propose separating the hashing of the output values&#xA;from the output ScriptPubKeys in `sha_outputs` so again, applications&#xA;interested only in summing the values of the outputs (for instance to&#xA;compute fees) do not have to wade through those arbitrarily long&#xA;ScriptPubKeys in the outputs.&#xA;&#xA;On Thu, Apr 30, 2020 at 4:22 AM Andrew Kozlik via bitcoin-dev &lt;&#xA;bitcoin-dev at lists.linuxfoundation.org&gt; wrote:&#xA;&#xA;&gt; Hi everyone,&#xA;&gt;&#xA;&gt; In the current draft of BIP-0341 [1] the signature message commits to the&#xA;&gt; scriptPubKey of the output being spent by the input. I propose that the&#xA;&gt; signature message should commit to the scriptPubKeys of *all* transaction&#xA;&gt; inputs.&#xA;&gt;&#xA;&gt; In certain applications like CoinJoin, a wallet has to deal with&#xA;&gt; transactions containing external inputs. To calculate the actual amount&#xA;&gt; that the user is spending, the wallet needs to reliably determine for each&#xA;&gt; input whether it belongs to the wallet or not. Without such a mechanism an&#xA;&gt; adversary can fool the wallet into displaying incorrect information about&#xA;&gt; the amount being spent, which can result in theft of user funds [2].&#xA;&gt;&#xA;&gt; In order to ascertain non-ownership of an input which is claimed to be&#xA;&gt; external, the wallet needs the scriptPubKey of the previous output spent by&#xA;&gt; this input. It must acquire the full transaction being spent and verify its&#xA;&gt; hash against that which is given in the outpoint. This is an obstacle in&#xA;&gt; the implementation of lightweight air-gapped wallets and hardware wallets&#xA;&gt; in general. If the signature message would commit to the scriptPubKeys of&#xA;&gt; all transaction inputs, then the wallet would only need to acquire the&#xA;&gt; scriptPubKey of the output being spent without having to acquire and verify&#xA;&gt; the hash of the entire previous transaction. If an attacker would provide&#xA;&gt; an incorrect scriptPubKey, then that would cause the wallet to generate an&#xA;&gt; invalid signature message.&#xA;&gt;&#xA;&gt; Note that committing only to the scriptPubKey of the output being spent is&#xA;&gt; insufficient for this application, because the scriptPubKeys which are&#xA;&gt; needed to ascertain non-ownership of external inputs are precisely the ones&#xA;&gt; that would not be included in any of the signature messages produced by the&#xA;&gt; wallet.&#xA;&gt;&#xA;&gt; The obvious way to implement this is to add another hash to the signature&#xA;&gt; message:&#xA;&gt; sha_scriptPubKeys (32): the SHA256 of the serialization of all&#xA;&gt; scriptPubKeys of the previous outputs spent by this transaction.&#xA;&gt;&#xA;&gt; Cheers,&#xA;&gt; Andrew Kozlik&#xA;&gt;&#xA;&gt; [1]&#xA;&gt; https://github.com/bitcoin/bips/blob/master/bip-0341.mediawiki#common-signature-message&#xA;&gt; [2]&#xA;&gt; https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2017-August/014843.html&#xA;&gt; _______________________________________________&#xA;&gt; bitcoin-dev mailing list&#xA;&gt; bitcoin-dev at lists.linuxfoundation.org&#xA;&gt; https://lists.linuxfoundation.org/mailman/listinfo/bitcoin-dev&#xA;&gt;&#xA;-------------- next part --------------&#xA;An HTML attachment was scrubbed...&#xA;URL: &lt;http://lists.linuxfoundation.org/pipermail/bitcoin-dev/attachments/20200501/cc57f1b0/attachment.html&gt;</html></oembed>