<oembed><type>rich</type><version>1.0</version><title>Pieter Wuille [ARCHIVE] wrote</title><author_name>Pieter Wuille [ARCHIVE] (npub1tj…jtl6r)</author_name><author_url>https://yabu.me/npub1tjephawh7fdf6358jufuh5eyxwauzrjqa7qn50pglee4tayc2ntqcjtl6r</author_url><provider_name>njump</provider_name><provider_url>https://yabu.me</provider_url><html>📅 Original date posted:2018-06-26&#xA;📝 Original message:On Tue, Jun 26, 2018 at 8:33 AM, matejcik via bitcoin-dev&#xA;&lt;bitcoin-dev at lists.linuxfoundation.org&gt; wrote:&#xA;&gt; I&#39;m still going to argue against the key-value model though.&#xA;&gt;&#xA;&gt; It&#39;s true that this is not significant in terms of space. But I&#39;m more&#xA;&gt; concerned about human readability, i.e., confusing future implementers.&#xA;&gt; At this point, the key-value model is there &#34;for historical reasons&#34;,&#xA;&gt; except these aren&#39;t valid even before finalizing the format. The&#xA;&gt; original rationale for using key-values seems to be gone (no key-based&#xA;&gt; lookups are necessary). As for combining and deduplication, whether key&#xA;&gt; data is present or not is now purely a stand-in for a &#34;repeatable&#34; flag.&#xA;&gt; We could just as easily say, e.g., that the high bit of &#34;type&#34; specifies&#xA;&gt; whether this record can be repeated.&#xA;&#xA;I understand this is a philosophical point, but to me it&#39;s the&#xA;opposite. The file conveys &#34;the script is X&#34;, &#34;the signature for key X&#xA;is Y&#34;, &#34;the derivation for key X is Y&#34; - all extra metadata added to&#xA;inputs of the form &#34;the X is Y&#34;. In a typed record model, you still&#xA;have Xes, but they are restricted to a single number (the record&#xA;type). In cases where that is insufficient, your solution is adding a&#xA;repeatable flag to switch from &#34;the first byte needs to be unique&#34; to&#xA;&#34;the entire record needs to be unique&#34;. Why just those two? It seems&#xA;much more natural to have a length that directly tells you how many of&#xA;the first bytes need to be unique (which brings you back to the&#xA;key-value model).&#xA;&#xA;Since the redundant script hashes were removed by making the scripts&#xA;per-input, I think the most compelling reason (size advantages) for a&#xA;record based model is gone.&#xA;&#xA;&gt; (Moreover, as I wrote previously, the Combiner seems like a weirdly&#xA;&gt; placed role. I still don&#39;t see its significance and why is it important&#xA;&gt; to correctly combine PSBTs by agents that don&#39;t understand them. If you&#xA;&gt; have a usecase in mind, please explain.&#xA;&#xA;Forward compatibility with new script types. A transaction may spend&#xA;inputs from different outputs, with different script types. Perhaps&#xA;some of these are highly specialized things only implemented by some&#xA;software (say HTLCs of a particular structure), in non-overlapping&#xA;ways where no piece of software can handle all scripts involved in a&#xA;single transaction. If Combiners cannot deal with unknown fields, they&#xA;won&#39;t be able to deal with unknown scripts. That would mean that&#xA;combining must be done independently by Combiner implementations for&#xA;each script type involved. As this is easily avoided by adding a&#xA;slight bit of structure (parts of the fields that need to be unique -&#xA;&#34;keys&#34;), this seems the preferable option.&#xA;&#xA;&gt; ISTM a Combiner could just as well combine based on whole-record&#xA;&gt; uniqueness, and leave the duplicate detection to the Finalizer. In case&#xA;&gt; the incoming PSBTs have incompatible unique fields, the Combiner would&#xA;&gt; have to fail anyway, so the Finalizer might as well do it. Perhaps it&#xA;&gt; would be good to leave out the Combiner role entirely?)&#xA;&#xA;No, a Combiner can pick any of the values in case different PSBTs have&#xA;different values for the same key. That&#39;s the point: by having a&#xA;key-value structure the choice of fields can be made such that&#xA;Combiners don&#39;t need to care about the contents. Finalizers do need to&#xA;understand the contents, but they only operate once at the end.&#xA;Combiners may be involved in any PSBT passing from one entity to&#xA;another.&#xA;&#xA;&gt; There&#39;s two remaining types where key data is used: BIP32 derivations&#xA;&gt; and partial signatures. In case of BIP32 derivation, the key data is&#xA;&gt; redundant ( pubkey = derive(value) ), so I&#39;d argue we should leave that&#xA;&gt; out and save space. In case of partial signatures, it&#39;s simple enough to&#xA;&gt; make the pubkey part of the value.&#xA;&#xA;In case of BIP32 derivation, computing the pubkeys is possibly&#xA;expensive. A simple signer can choose to just sign with whatever keys&#xA;are present, but they&#39;re not the only way to implement a signer, and&#xA;even less the only software interacting with this format. Others may&#xA;want to use a matching approach to find keys that are relevant;&#xA;without pubkeys in the format, they&#39;re forced to perform derivations&#xA;for all keys present.&#xA;&#xA;And yes, it&#39;s simple enough to make the key part of the value&#xA;everywhere, but in that case it becomes legal for a PSBT to contain&#xA;multiple signatures for a key, for example, and all software needs to&#xA;deal with that possibility. With a stronger uniqueness constraint,&#xA;only Combiners need to deal with repetitions.&#xA;&#xA;&gt; Thing is: BIP174 *is basically protobuf* (v2) as it stands. If I&#39;m&#xA;&gt; succesful in convincing you to switch to a record set model, it&#39;s going&#xA;&gt; to be &#34;protobuf with different varint&#34;.&#xA;&#xA;If you take the records model, and then additionally drop the&#xA;whole-record uniqueness constraint, yes, though that seems pushing it&#xA;a bit by moving even more guarantees from the file format to&#xA;application level code. I&#39;d like to hear opinions of other people who&#xA;have worked on implementations about changing this.&#xA;&#xA;Cheers,&#xA;&#xA;-- &#xA;Pieter</html></oembed>