<oembed><type>rich</type><version>1.0</version><author_name>npub10vqyu8x3f0lfttk98xc28ppuyufaz4df8x4aspa9w9xz5z05snzq7t058y</author_name><author_url>https://nostr.ae/npub10vqyu8x3f0lfttk98xc28ppuyufaz4df8x4aspa9w9xz5z05snzq7t058y</author_url><provider_name>njump</provider_name><provider_url>https://nostr.ae</provider_url><html>📅 Original date posted:2020-01-13&#xA;📝 Original message:Thanks for the useful comments guys. I understand where you are&#xA;coming from, but my PoV is from the deep embedded side.&#xA;&#xA;On Mon, Jan 13, 2020 at 06:39:28AM +0000, Andrew Chow wrote:&#xA;&gt; ... In fact, I&#39;m not quite&#xA;&gt; sure what kind of attack you are trying to defend against with this&#xA;&gt; proposal.&#xA;&#xA;I don&#39;t have a specific attack in mind, but these signatures, if&#xA;adopted by the community at large, will allow detection of-, and&#xA;could mitigate damage from-, some broad &#34;bug-classes&#34;.&#xA;&#xA;Consider if the PSBT Signer (hardware wallet) has bugs. Perhaps if&#xA;you tweak the PSBT in some unnatural way it produces output that&#xA;reveals the private key (duplicate k-value perhaps), or corrupts&#xA;the display of the transaction in helpful (to the attacker) ways&#xA;(typically case: output hidden as change).&#xA;&#xA;Seeing a corrupted file signature would alert you of the attempt&#xA;to do this. So maybe you don&#39;t transmit the transaction, maybe you&#xA;warn the user and so on. What happens next is up to you, but at&#xA;least we know something is happening.&#xA;&#xA;There could also be bugs in the Combiner/Finalizer which the MiTM&#xA;wants to trigger. Legimate files, signed by the PSBT Signer, will not&#xA;contain those attacks, so are &#34;safer&#34; to process, even if your&#xA;Combiner&#39;s PSBT parser has bugs or is tragically dumb.&#xA;&#xA;It&#39;s just another layer of security and confidence, on top of the&#xA;existing system-level security (which is already excellent).&#xA;&#xA;&gt; If there is a MiTM who can modify your PSBT, then they can just modify&#xA;&gt; the result the signed PSBT to drop the auth signatures.&#xA;&#xA;Yes, the MiTM can remove the signatures. However, if your tools expect&#xA;and require the signatures in place, then the feature is working&#xA;as intended, because the user will be alerted to the funny-business.&#xA;&#xA;More importantly: nothing has been lost by implementing the feature,&#xA;and Coldcard (and other PSBT Signers) have to be first to implement it.&#xA;&#xA;&gt; ... then you already&#xA;&gt; have a signature there that covers everything your auth signature would&#xA;&gt; cover. So just verify those signatures instead; for any inputs with&#xA;&#xA;That&#39;s just it, when we receive a signed PSBT, at present we don&#39;t&#xA;know *what* was signed without a complete understanding of the&#xA;transaction, the input UTXO (at least syntactially), and PSBT file&#xA;contents.  If there are bugs in that understanding (ie. checks we&#xA;all know are needed, but no-one actually implemented) then we might&#xA;transmit an harmful transaction, or continue to process a file&#xA;that has been corrupted-with-intent by a MiTM.&#xA;&#xA;&gt; Lastly, IMO, if you want MiTM protection, then you should do your&#xA;&gt; protection with out of band communication. Just PGP sign the PSBT (or&#xA;&gt; something similar) and send the signature along separately.&#xA;&#xA;It&#39;s fine to say that, but in an embedded environment, with very&#xA;limited memory like the Coldcard, PGP isn&#39;t an option (signing vs.&#xA;signature verification). I want to leverage the existing crypto and&#xA;PKI that we already have in play.&#xA;&#xA;&gt; On 1/11/20 3:17 PM, Dmitry Petukhov via bitcoin-dev wrote:&#xA;... [many valid points, repeated by Andrew] ...&#xA;&gt; &gt; If there is MitM, checking something at Finalizer is likely too&#xA;&gt; &gt; late - the party that can intercept PSBTs can finalize before the&#xA;&gt; &gt; legitimate Finalizer and broadcast the transaction.&#xA;&#xA;Yes, that is a problem which is proposal does not address. If the&#xA;MitM has control over both directions, in and out, then whatever&#xA;he or she was trying to do will still happen. Personally, I&#39;m okay&#xA;with that as a limition, but using the same signatures features,&#xA;and a pre-shared public key between the PSBT Creator and the Signer,&#xA;we could block the Signer from looking at MitM&#39;ed files. (The Signer&#xA;would require and verify incoming unsigned PSBT to contain the&#xA;last-output-section-signature thing.) I&#39;m not planning on supporting&#xA;that on the Coldcard (at least not yet), but with the proposed&#xA;additions, it is possible to do without further changes to the PSBT&#xA;spec.&#xA;&#xA;&gt; &gt; Participants can work from the same PSBT ...&#xA;&gt; &gt; either pass two files (original and updated), or work out which fields&#xA;&gt; &gt; (key-value blobs) to remove to get the &#39;source&#39; PSBT (which might not be&#xA;&gt; &gt; trivial with presense of proprietary and unknown fields). Even if you&#xA;&gt; &gt; know which key-value pairs to remove, there is no requirement for&#xA;&gt; &gt; ordering of the fields, and some signer can serialize them in different&#xA;&gt; &gt; order after dserialize/sign/add-signatures/re-serialize operation.&#xA;...&#xA;&gt; &gt; Introducing additional ordering or other structure requirements over&#xA;&gt; &gt; simple key-value structure will add complexity to PSBT processing, and&#xA;&gt; &gt; adding complexity on such a basic level should have really serious&#xA;&gt; &gt; reasons, because that increases effort required for even basic&#xA;&gt; &gt; implementations and increases chance of bugs.&#xA;&#xA;I want these signatures to protect against PSBT parsing bugs. That&#39;s&#xA;why they are byte-level on the whole file contents, and not based&#xA;on sub-sections of the file or various fields inside the file. Yes,&#xA;there are non-linear PSBT paths that will be difficult or impossible&#xA;to support with this approach. I would not expect implementations to&#xA;do anything fancy to reconstruct PSBT contents, I think they would&#xA;just track the complete file. In most setups today the Creator,&#xA;Combiner and Finalizer are the same device, and they are desktop&#xA;systems with gigs of memory.&#xA;&#xA;&gt; &gt; If there is some authority on the &#39;correctness&#39; of &#39;original&#39; PSBT&#xA;&gt; &gt; (all particpants receive same PSBT at the start), particpants should&#xA;&gt; &gt; check the signature by that authority. That authority might use&#xA;&gt; &gt; the key used only for authentication, and not in the tx signing.&#xA;&#xA;Yes, this can be acheived by pre-sharing a public key with the&#xA;Signer (described above). Only signed incoming PSBT&#39;s would be&#xA;accepted. That key doesn&#39;t have anything to do with the blockchain&#xA;or value transfer.&#xA;&#xA;&gt; &gt; I think you do not need to wait for officially-assigned key numbers,&#xA;&gt; &gt; and can just implement the scheme you envision with proprietary keys,&#xA;&gt; &gt; document and promote it. Then if it shows its usefulness, it will&#xA;&gt; &gt; either become de-facto standard with your proprietary keys...&#xA;&#xA;Yes, 100% ... but I value the list&#39;s feedback, and I would prefer to&#xA;start with a legitimate key number which I don&#39;t need to change later. It&#39;s&#xA;a non-breaking change and I wouldn&#39;t propose it otherwise.&#xA;&#xA;---&#xA;Peter D. Gray  ||  Founder, Coinkite  ||  Twitter: @dochex  ||  GPG: A3A31BAD 5A2A5B10&#xA;&#xA;On Mon, Jan 13, 2020 at 06:39:28AM +0000, Andrew Chow wrote:&#xA;&gt; I agree with Dimitry. I don&#39;t see the point of having the MiTM&#xA;&gt; protection within the PSBT structure itself, in addition to the fact&#xA;&gt; that adding new fields is largely unnecessary. In fact, I&#39;m not quite&#xA;&gt; sure what kind of attack you are trying to defend against with this&#xA;&gt; proposal.&#xA;&gt; &#xA;&gt; If there is a MiTM who can modify your PSBT, then they can just modify&#xA;&gt; the result the signed PSBT to drop the auth signatures. Furthermore, any&#xA;&gt; modifications to scripts or UTXOs would just result in an invalid&#xA;&gt; signature, so only time is wasted. But you&#39;ll just waste time anyways&#xA;&gt; when you see a failed auth sig.&#xA;&gt; &#xA;&gt; Additionally, when a signer processes a PSBT, it will either accept the&#xA;&gt; PSBT and add a signature for its inputs, or reject it and do nothing.&#xA;&gt; Given this behavior (and I assume you aren&#39;t going to add auth sigs for&#xA;&gt; rejected PSBTs because that doesn&#39;t make any sense), then you already&#xA;&gt; have a signature there that covers everything your auth signature would&#xA;&gt; cover. So just verify those signatures instead; for any inputs with&#xA;&gt; signatures, everything you need to verify them are already there.&#xA;&gt; &#xA;&gt; Lastly, IMO, if you want MiTM protection, then you should do your&#xA;&gt; protection with out of band communication. Just PGP sign the PSBT (or&#xA;&gt; something similar) and send the signature along separately.&#xA;&gt; &#xA;&gt; Andrew&#xA;&gt; &#xA;&gt; On 1/11/20 3:17 PM, Dmitry Petukhov via bitcoin-dev wrote:&#xA;&gt; &gt; &#xA;&gt; &gt; I am not sure that this particular task should be done with data&#xA;&gt; &gt; embedded in PSBT itself, and not with some sort of container that&#xA;&gt; &gt; includes PSBT and the authentication information.&#xA;&gt; &gt; &#xA;&gt; &gt; The benefit seems to be in reusing PSBT structure for compatibilty, and&#xA;&gt; &gt; this might be a valid way, although I do not agree with some of your&#xA;&gt; &gt; points. I elaborate below:&#xA;&gt; &gt; &#xA;&gt; &gt;&gt; 1) In the PSBT globals section, a signature over the &#34;source&#34; PSBT&#xA;&gt; &gt;&gt; file. It would cover all the bytes of the original PSBT file, as&#xA;&gt; &gt;&gt; it was received by the Signer.&#xA;&gt; &gt; &#xA;&gt; &gt; The problem of authenticating the contents of PSBT is independent of&#xA;&gt; &gt; the signing action. PSBT might be altered on the path from Creator to&#xA;&gt; &gt; Signer. Therefore you cannot always say that Signer will be an&#xA;&gt; &gt; authority over &#39;correctness&#39; of PSBT.&#xA;&gt; &gt; &#xA;&gt; &gt;&gt; - At the end of the signing process, the Finalizer should check all&#xA;&gt; &gt;&gt; the Signers have worked from the same PSBT file (assuming that&#39;s&#xA;&gt; &gt;&gt; the flow expected)&#xA;&gt; &gt; &#xA;&gt; &gt; If there is MitM, checking something at Finalizer is likely too&#xA;&gt; &gt; late - the party that can intercept PSBTs can finalize before the&#xA;&gt; &gt; legitimate Finalizer and broadcast the transaction.&#xA;&gt; &gt; &#xA;&gt; &gt; Participants can work from the same PSBT file if they all receive the&#xA;&gt; &gt; same PSBT, and not working in chain where next particpant receives&#xA;&gt; &gt; updated PSBT from the previous participant. Otherwise they will need to&#xA;&gt; &gt; either pass two files (original and updated), or work out which fields&#xA;&gt; &gt; (key-value blobs) to remove to get the &#39;source&#39; PSBT (which might not be&#xA;&gt; &gt; trivial with presense of proprietary and unknown fields). Even if you&#xA;&gt; &gt; know which key-value pairs to remove, there is no requirement for&#xA;&gt; &gt; ordering of the fields, and some signer can serialize them in different&#xA;&gt; &gt; order after dserialize/sign/add-signatures/re-serialize operation.&#xA;&gt; &gt; &#xA;&gt; &gt; Introducing additional ordering or other structure requirements over&#xA;&gt; &gt; simple key-value structure will add complexity to PSBT processing, and&#xA;&gt; &gt; adding complexity on such a basic level should have really serious&#xA;&gt; &gt; reasons, because that increases effort required for even basic&#xA;&gt; &gt; implementations and increases chance of bugs.&#xA;&gt; &gt; &#xA;&gt; &gt; If there is some authority on the &#39;correctness&#39; of &#39;original&#39; PSBT&#xA;&gt; &gt; (all particpants receive same PSBT at the start), particpants should&#xA;&gt; &gt; check the signature by that authority. That authority might use&#xA;&gt; &gt; the key used only for authentication, and not in the tx signing.&#xA;&gt; &gt; &#xA;&gt; &gt; If particpants send PSBT in chain after adding their signatures, then&#xA;&gt; &gt; each participant can add their signature to say &#39;the contents&#xA;&gt; &gt; of PSBT after my updates should match this hash&#39;.&#xA;&gt; &gt; &#xA;&gt; &gt; The signatures of previous participants in the chain most likely do not&#xA;&gt; &gt; matter because of difficulty of restoring the contents of PSBT as it&#xA;&gt; &gt; was before the previous particpant, if you do not pass _all_ the PSBTs&#xA;&gt; &gt; (which is excessive).&#xA;&gt; &gt; &#xA;&gt; &gt;&gt; 2) In the output section, specifically, the last key/value pair of&#xA;&gt; &gt;&gt; the last output of the transaction, I want to add a similar signature,&#xA;&gt; &gt;&gt; again signed by one of the keys used in the signing process. This&#xA;&gt; &gt;&gt; signature will cover all the bytes of the resulting (signed) PSBT&#xA;&gt; &gt;&gt; up to that point. Because it is the last output of the output&#xA;&gt; &gt;&gt; section, that signature will be the last few bytes of the PSBT file.&#xA;&gt; &gt;&gt; By &#34;appending&#34; the signature in this way, it&#39;s easier to validate&#xA;&gt; &gt;&gt; and create the signature, without blanking the signature area during&#xA;&gt; &gt;&gt; digest step.&#xA;&gt; &gt; &#xA;&gt; &gt; This will introduce unnecessary higher-level structure to PSBT for the&#xA;&gt; &gt; reasons that I do not find strong enough for the amount of complexity&#xA;&gt; &gt; added.&#xA;&gt; &gt; &#xA;&gt; &gt; Also, as I said above, you likely do not need more than one&#xA;&gt; &gt; signature - if this is &#39;fan-out&#39; scheme, then participants need do&#xA;&gt; &gt; check the sig of authority that created PSBT; if this is piggy-back&#xA;&gt; &gt; chain, then only previous particpant&#39;s signature is easily verifiable.&#xA;&gt; &gt; &#xA;&gt; &gt;&gt; ## Next Steps&#xA;&gt; &gt;&gt;&#xA;&gt; &gt;&gt; I&#39;d like to get two officially-assigned BIP-174 key numbers assigned&#xA;&gt; &gt;&gt; for these two signatures, and then I will see that it gets added&#xA;&gt; &gt;&gt; into Coldcard&#39;s firmware immediately. In time, other tools are&#xA;&gt; &gt;&gt; welcome to take advantage of these checks. I will also write a BIP&#xA;&gt; &gt;&gt; for this, and/or make an addition to BIP-174.&#xA;&gt; &gt; &#xA;&gt; &gt; I think you do not need to wait for officially-assigned key numbers,&#xA;&gt; &gt; and can just implement the scheme you envision with proprietary keys,&#xA;&gt; &gt; document and promote it. Then if it shows its usefulness, it will&#xA;&gt; &gt; either become de-facto standard with your proprietary keys (and&#xA;&gt; &gt; everyone will want to support &#39;Coldard PSBT auth&#39; or whatever the name),&#xA;&gt; &gt; or the scheme will have serious grounds to be converted to standard and&#xA;&gt; &gt; have non-proprietary keys assigned.&#xA;&gt; &gt; &#xA;&gt; &gt; // Dmitry.&#xA;&gt; &gt; _______________________________________________&#xA;&gt; &gt; bitcoin-dev mailing list&#xA;&gt; &gt; bitcoin-dev at lists.linuxfoundation.org&#xA;&gt; &gt; https://lists.linuxfoundation.org/mailman/listinfo/bitcoin-dev&#xA;&gt; &gt; &#xA;&gt; &#xA;-------------- next part --------------&#xA;A non-text attachment was scrubbed...&#xA;Name: signature.asc&#xA;Type: application/pgp-signature&#xA;Size: 529 bytes&#xA;Desc: not available&#xA;URL: &lt;http://lists.linuxfoundation.org/pipermail/bitcoin-dev/attachments/20200113/2ad4e27c/attachment-0001.sig&gt;</html></oembed>