<oembed><type>rich</type><version>1.0</version><author_name>npub1fgnnmg7f4wzup9hct8nv5pnd9l07wcjqdjku9ax432n4g69v4rgq7xak44</author_name><author_url>https://nostr.ae/npub1fgnnmg7f4wzup9hct8nv5pnd9l07wcjqdjku9ax432n4g69v4rgq7xak44</author_url><provider_name>njump</provider_name><provider_url>https://nostr.ae</provider_url><html>📅 Original date posted:2020-01-13&#xA;📝 Original message:I agree with Dimitry. I don&#39;t see the point of having the MiTM&#xA;protection within the PSBT structure itself, in addition to the fact&#xA;that adding new fields is largely unnecessary. In fact, I&#39;m not quite&#xA;sure what kind of attack you are trying to defend against with this&#xA;proposal.&#xA;&#xA;If there is a MiTM who can modify your PSBT, then they can just modify&#xA;the result the signed PSBT to drop the auth signatures. Furthermore, any&#xA;modifications to scripts or UTXOs would just result in an invalid&#xA;signature, so only time is wasted. But you&#39;ll just waste time anyways&#xA;when you see a failed auth sig.&#xA;&#xA;Additionally, when a signer processes a PSBT, it will either accept the&#xA;PSBT and add a signature for its inputs, or reject it and do nothing.&#xA;Given this behavior (and I assume you aren&#39;t going to add auth sigs for&#xA;rejected PSBTs because that doesn&#39;t make any sense), then you already&#xA;have a signature there that covers everything your auth signature would&#xA;cover. So just verify those signatures instead; for any inputs with&#xA;signatures, everything you need to verify them are already there.&#xA;&#xA;Lastly, IMO, if you want MiTM protection, then you should do your&#xA;protection with out of band communication. Just PGP sign the PSBT (or&#xA;something similar) and send the signature along separately.&#xA;&#xA;Andrew&#xA;&#xA;On 1/11/20 3:17 PM, Dmitry Petukhov via bitcoin-dev wrote:&#xA;&gt; &#xA;&gt; I am not sure that this particular task should be done with data&#xA;&gt; embedded in PSBT itself, and not with some sort of container that&#xA;&gt; includes PSBT and the authentication information.&#xA;&gt; &#xA;&gt; The benefit seems to be in reusing PSBT structure for compatibilty, and&#xA;&gt; this might be a valid way, although I do not agree with some of your&#xA;&gt; points. I elaborate below:&#xA;&gt; &#xA;&gt;&gt; 1) In the PSBT globals section, a signature over the &#34;source&#34; PSBT&#xA;&gt;&gt; file. It would cover all the bytes of the original PSBT file, as&#xA;&gt;&gt; it was received by the Signer.&#xA;&gt; &#xA;&gt; The problem of authenticating the contents of PSBT is independent of&#xA;&gt; the signing action. PSBT might be altered on the path from Creator to&#xA;&gt; Signer. Therefore you cannot always say that Signer will be an&#xA;&gt; authority over &#39;correctness&#39; of PSBT.&#xA;&gt; &#xA;&gt;&gt; - At the end of the signing process, the Finalizer should check all&#xA;&gt;&gt; the Signers have worked from the same PSBT file (assuming that&#39;s&#xA;&gt;&gt; the flow expected)&#xA;&gt; &#xA;&gt; If there is MitM, checking something at Finalizer is likely too&#xA;&gt; late - the party that can intercept PSBTs can finalize before the&#xA;&gt; legitimate Finalizer and broadcast the transaction.&#xA;&gt; &#xA;&gt; Participants can work from the same PSBT file if they all receive the&#xA;&gt; same PSBT, and not working in chain where next particpant receives&#xA;&gt; updated PSBT from the previous participant. Otherwise they will need to&#xA;&gt; either pass two files (original and updated), or work out which fields&#xA;&gt; (key-value blobs) to remove to get the &#39;source&#39; PSBT (which might not be&#xA;&gt; trivial with presense of proprietary and unknown fields). Even if you&#xA;&gt; know which key-value pairs to remove, there is no requirement for&#xA;&gt; ordering of the fields, and some signer can serialize them in different&#xA;&gt; order after dserialize/sign/add-signatures/re-serialize operation.&#xA;&gt; &#xA;&gt; Introducing additional ordering or other structure requirements over&#xA;&gt; simple key-value structure will add complexity to PSBT processing, and&#xA;&gt; adding complexity on such a basic level should have really serious&#xA;&gt; reasons, because that increases effort required for even basic&#xA;&gt; implementations and increases chance of bugs.&#xA;&gt; &#xA;&gt; If there is some authority on the &#39;correctness&#39; of &#39;original&#39; PSBT&#xA;&gt; (all particpants receive same PSBT at the start), particpants should&#xA;&gt; check the signature by that authority. That authority might use&#xA;&gt; the key used only for authentication, and not in the tx signing.&#xA;&gt; &#xA;&gt; If particpants send PSBT in chain after adding their signatures, then&#xA;&gt; each participant can add their signature to say &#39;the contents&#xA;&gt; of PSBT after my updates should match this hash&#39;.&#xA;&gt; &#xA;&gt; The signatures of previous participants in the chain most likely do not&#xA;&gt; matter because of difficulty of restoring the contents of PSBT as it&#xA;&gt; was before the previous particpant, if you do not pass _all_ the PSBTs&#xA;&gt; (which is excessive).&#xA;&gt; &#xA;&gt;&gt; 2) In the output section, specifically, the last key/value pair of&#xA;&gt;&gt; the last output of the transaction, I want to add a similar signature,&#xA;&gt;&gt; again signed by one of the keys used in the signing process. This&#xA;&gt;&gt; signature will cover all the bytes of the resulting (signed) PSBT&#xA;&gt;&gt; up to that point. Because it is the last output of the output&#xA;&gt;&gt; section, that signature will be the last few bytes of the PSBT file.&#xA;&gt;&gt; By &#34;appending&#34; the signature in this way, it&#39;s easier to validate&#xA;&gt;&gt; and create the signature, without blanking the signature area during&#xA;&gt;&gt; digest step.&#xA;&gt; &#xA;&gt; This will introduce unnecessary higher-level structure to PSBT for the&#xA;&gt; reasons that I do not find strong enough for the amount of complexity&#xA;&gt; added.&#xA;&gt; &#xA;&gt; Also, as I said above, you likely do not need more than one&#xA;&gt; signature - if this is &#39;fan-out&#39; scheme, then participants need do&#xA;&gt; check the sig of authority that created PSBT; if this is piggy-back&#xA;&gt; chain, then only previous particpant&#39;s signature is easily verifiable.&#xA;&gt; &#xA;&gt;&gt; ## Next Steps&#xA;&gt;&gt;&#xA;&gt;&gt; I&#39;d like to get two officially-assigned BIP-174 key numbers assigned&#xA;&gt;&gt; for these two signatures, and then I will see that it gets added&#xA;&gt;&gt; into Coldcard&#39;s firmware immediately. In time, other tools are&#xA;&gt;&gt; welcome to take advantage of these checks. I will also write a BIP&#xA;&gt;&gt; for this, and/or make an addition to BIP-174.&#xA;&gt; &#xA;&gt; I think you do not need to wait for officially-assigned key numbers,&#xA;&gt; and can just implement the scheme you envision with proprietary keys,&#xA;&gt; document and promote it. Then if it shows its usefulness, it will&#xA;&gt; either become de-facto standard with your proprietary keys (and&#xA;&gt; everyone will want to support &#39;Coldard PSBT auth&#39; or whatever the name),&#xA;&gt; or the scheme will have serious grounds to be converted to standard and&#xA;&gt; have non-proprietary keys assigned.&#xA;&gt; &#xA;&gt; // Dmitry.&#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;</html></oembed>