<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:2017-10-02&#xA;📝 Original message:On Sun, Oct 1, 2017 at 4:39 PM, Mark Friedenbach &lt;mark at friedenbach.org&gt;&#xA;wrote:&#xA;&#xA;&gt;&#xA;&gt; &gt; On Oct 1, 2017, at 12:41 PM, Russell O&#39;Connor &lt;roconnor at blockstream.io&gt;&#xA;&gt; wrote:&#xA;&gt; &gt;&#xA;&gt; &gt; Creating a Bitcoin script that does not allow malleability is difficult&#xA;&gt; and requires wasting a lot of bytes to do so, typically when handling&#xA;&gt; issues around non-0-or-1 witness values being used with OP_IF, and dealing&#xA;&gt; with non-standard-zero values, etc.&#xA;&gt;&#xA;&gt; Script validation flags of the correct place to do this. We already have&#xA;&gt; policy validation flags that check for these things. They were not made&#xA;&gt; consensus rules with Segwit v0 mainly due to concern over scope creep in an&#xA;&gt; already large overhaul, of my memory is correct. Script versions and&#xA;&gt; quadratic hashing fixes where the minimum necessary to allow segwit to&#xA;&gt; activate safely while still enabling future upgrades that would otherwise&#xA;&gt; have been hard forks. We knew that we would be later changing the EC&#xA;&gt; signature scheme to be something that supported signature aggregation, and&#xA;&gt; that would be more appropriate time to discuss such changes. As we are&#xA;&gt; considering to do now (although witness versions means we don’t need to&#xA;&gt; omnibus the script upgrade here either, so a v1 before signature&#xA;&gt; aggregation is ready is fine IMHO).&#xA;&gt;&#xA;&#xA;Script validation isn&#39;t the correct place to do this.  The reason is that&#xA;script operations are not aware of whether the stack items they are&#xA;processing are witness malleable items or Script computed values.  Let me&#xA;take OP_IF as one example.  When OP_IF operates directly on witness data,&#xA;it is subject to witness malleability, and therefore one needs to add extra&#xA;code around that to prevent witness malleability.  On the other hand, when&#xA;OP_IF operates on computed data, it isn&#39;t subject to malleability and can&#xA;safely process non-zero-or-one values. If OP_IF were restricted to&#xA;requiring canonical inputs, then for the cases that OP_IF operates on&#xA;computed data, they will need to add extra code to canonicalize their&#xA;inputs.  I don&#39;t think there is a correct answer here.  That is because I&#xA;believe this isn&#39;t the correct place to aim to restrict witness&#xA;malleability.&#xA;&#xA;OTOH, signatures are a fine place to aim to restrict witness malleability.&#xA;In fact, if signatures could securely cover all witness data, I think&#xA;everyone here would jump at the opportunity to implement that.  However,&#xA;since that isn&#39;t known to be possible, we are left with doing the best we&#xA;can, which is to have signatures cover weight (or bytes).  This prevents&#xA;the worst effects of witness malleability and does so without burdening&#xA;Script development.  (This also requires signatures have a fixed size, so&#xA;it is understandable that signature-covers-weight wasn&#39;t included in Segwit&#xA;v0 scripts).&#xA;&#xA;&#xA;&gt; In any case if there is any general witness malleability due to opcode&#xA;&gt; semantics that it’s not fixed by one of our existing policy flags, that is&#xA;&gt; a bug and I would encourage you to report it.&#xA;&gt; &gt; I&#39;ll argue that I don&#39;t want my counter-party going off and using a very&#xA;&gt; deeply nested key in order to subvert the fee rate we&#39;ve agreed upon after&#xA;&gt; I&#39;ve signed my part of the input.  If we are doing multi-party signing of&#xA;&gt; inputs we need to communicate anyways to construct the transaction.  I see&#xA;&gt; no problem with requiring my counter-party to choose their keys before I&#xA;&gt; sign so that I know up front what our fee rate is going to be.  If they&#xA;&gt; lose their keys and need a backup, they should have to come back to me to&#xA;&gt; resign in order that we can negotiate a new fee rate for the transaction&#xA;&gt; and who is going to be covering how much of the fee and on which inputs.&#xA;&gt;&#xA;&gt; Arguing that every single user should be forced to restart an interactive&#xA;&gt; signing session. That’s a very strong statement based on something that I&#xA;&gt; would say is a preference that depends on circumstances.&#xA;&gt;&#xA;&gt; What about an optional commitment to witness size in bytes? The value zero&#xA;&gt; meaning “I don’t care.” I would argue that it should be a maximum however,&#xA;&gt; and therefor serialized as part of the witness. The serialization of this&#xA;&gt; would be very compact (1 plus the difference between actual and maximum,&#xA;&gt; with zero meaning not used.)&#xA;&#xA;&#xA;I would be fine your suggestion above, though I think Luke&#39;s suggestion of&#xA;having both SIGHASH_WITNESS_SIZE and SIGHASH_WITNESS_DEPTH flag is better&#xA;because it is simpler.&#xA;&#xA;Those people worried about restarting interactive signing session in the&#xA;unlikely event of parties not knowing what keys they are planning to use&#xA;can use just the SIGHASH_WITNESS_DEPTH flag.  Those people worried about&#xA;counterparties fiddling with fee rates can use both flags.  The choice&#xA;doesn&#39;t even need to be made at script commitment time.&#xA;-------------- next part --------------&#xA;An HTML attachment was scrubbed...&#xA;URL: &lt;http://lists.linuxfoundation.org/pipermail/bitcoin-dev/attachments/20171002/36c4797d/attachment.html&gt;</html></oembed>