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