<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-15&#xA;📝 Original message:Hello all,&#xA;&#xA;given some recent work and discussions around BIP 174 (Partially&#xA;Signed Bitcoin Transaction Format) I&#39;d like to bring up a few ideas.&#xA;&#xA;First of all, it&#39;s unclear to me to what extent projects have already&#xA;worked on implementations, and thus to what extent the specification&#xA;is still subject to change. A response of &#34;this is way too late&#34; is&#xA;perfectly fine.&#xA;&#xA;So here goes:&#xA;&#xA;* Key-value map model or set model.&#xA;&#xA;This was suggested in this thread:&#xA;https://twitter.com/matejcik/status/1002618633472892929&#xA;&#xA;The motivation behind using a key-value model rather than a simple&#xA;list of records was that PSBTs can be duplicated (given to multiple&#xA;people for signing, for example), and merged back together after&#xA;signing. With a generic key-value model, any implementation can remove&#xA;the duplication even if they don&#39;t understand fields that may have&#xA;been added in future extensions.&#xA;&#xA;However, almost the same can be accomplished by using the simpler set&#xA;model (the file consists of a set of records, with no duplication&#xA;allowed). This would mean that it would technically be legal to have&#xA;two partial signatures with the same key for the same input, if a&#xA;non-deterministic signer is used.&#xA;&#xA;On the other hand, this means that certain data currently encoded&#xA;inside keys can be dropped, reducing the PSBT size. This is&#xA;particularly true for redeemscripts and witnessscripts, as they can&#xA;just be computed by the client when deserializing. The two types could&#xA;even be merged into just &#34;scripts&#34; records - as they don&#39;t need to be&#xA;separated based on the way they&#39;re looked up (Hash160 for P2SH, SHA256&#xA;for P2WSH). The same could be done for the BIP32 derivation paths,&#xA;though this may be expensive, as the client would need to derive all&#xA;keys before being able to figure out which one(s) it needs.&#xA;&#xA;One exception is the &#34;transaction&#34; record, which needs to be unique.&#xA;That can either be done by adding an exception (&#34;there can only be one&#xA;transaction record&#34;), or by encoding it separately outside the normal&#xA;records (that may also be useful to make it clear that it is always&#xA;required).&#xA;&#xA;* Ability for Combiners to verify two PSBT are for the same transaction&#xA;&#xA;Clearly two PSBTs for incompatible transactions cannot be combined,&#xA;and this should not be allowed.&#xA;&#xA;It may be easier to enforce this if the &#34;transaction&#34; record inside a&#xA;PSBT was required to be in a canonical form, meaning with empty&#xA;scriptSigs and witnesses. In order to do so, there could be per-input&#xA;records for &#34;finalized scriptSig&#34; and &#34;finalized witness&#34;. Actually&#xA;placing those inside the transaction itself would only be allowed when&#xA;all inputs are finalized.&#xA;&#xA;* Optional signing&#xA;&#xA;I think all operation for the Signer responsibility should be&#xA;optional. This will inevitably lead to incompatibilities, but with the&#xA;intent of being forward compatible with future developments, I don&#39;t&#xA;think it is possible to require every implementation to support the&#xA;same set of scripts or contracts. For example, some signers may only&#xA;implement single-key P2PKH, or may only support signing SegWit inputs.&#xA;It&#39;s the user&#39;s responsibility to find compatible signers (which is&#xA;generally not an issue, as the different participants in a setup&#xA;necessarily have this figured out before being able to create an&#xA;address). This does mean that there can&#39;t be an unconditional test&#xA;vector that specifies the produced signature in certain circumstances,&#xA;but there could be &#34;For implementations that choose to implement&#xA;signing for P2PKH inputs using RFC6979, the expected output given&#xA;input X and access to key Y is Z&#34;.&#xA;&#xA;On the other hand, the Combiner and Finalizer roles can probably be&#xA;specified much more accurately than they are now.&#xA;&#xA;* Derivation from xpub or fingerprint&#xA;&#xA;For BIP32 derivation paths, the spec currently only encodes the 32-bit&#xA;fingerprint of the parent or master xpub. When the Signer only has a&#xA;single xprv from which everything is derived, this is obviously&#xA;sufficient. When there are many xprv, or when they&#39;re not available&#xA;indexed by fingerprint, this may be less convenient for the signer.&#xA;Furthermore, it violates the &#34;PSBT contains all information necessary&#xA;for signing, excluding private keys&#34; idea - at least if we don&#39;t treat&#xA;the chaincode as part of the private key.&#xA;&#xA;For that reason I would suggest that the derivation paths include the&#xA;full public key and chaincode of the parent or master things are&#xA;derived from. This does mean that the Creator needs to know the full&#xA;xpub which things are derived from, rather than just its fingerprint.&#xA;&#xA;* Generic key offset derivation&#xA;&#xA;Whenever a BIP32 derivation path does not include any hardened steps,&#xA;the entirety of the derivation can be conveyed as &#34;The private key for&#xA;P is equal to the private key for Q plus x&#34;, with P and Q points and x&#xA;a scalar. This representation is more flexible (it also supports&#xA;pay-to-contract derivations), more efficient, and more compact. The&#xA;downside is that it requires the Signer to support such derivation,&#xA;which I don&#39;t believe any current hardware devices do.&#xA;&#xA;Would it make sense to add this as an additional derivation method?&#xA;&#xA;* Hex encoding?&#xA;&#xA;This is a very minor thing. But presumably there will be some standard&#xA;way to store PSBTs as text for copy-pasting - either prescribed by the&#xA;spec, or de facto. These structures may become pretty large, so&#xA;perhaps it&#39;s worth choosing something more compact than hexadecimal -&#xA;for example Base64 or even Z85 (https://rfc.zeromq.org/spec:32/Z85/).&#xA;&#xA;Cheers,&#xA;&#xA;-- &#xA;Pieter</html></oembed>