From 19d3b9dc829ca52133dd71497f0768118d7462d2 Mon Sep 17 00:00:00 2001 From: Andrew Chow Date: Mon, 13 May 2019 22:00:26 -0400 Subject: bip174: add global xpub field --- bip-0174.mediawiki | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'bip-0174.mediawiki') diff --git a/bip-0174.mediawiki b/bip-0174.mediawiki index f197728..8c9443e 100644 --- a/bip-0174.mediawiki +++ b/bip-0174.mediawiki @@ -118,6 +118,12 @@ The currently defined global types are as follows: *** {transaction} ** Note: Every PSBT must have a field with this type. +* Type: Extended Public Key PSBT_GLOBAL_XPUB = 0x01 +** Key: The type followed by the 78 byte serialized extended public key as defined by BIP 32. Extended public keys are those that can be used to derive public keys used in the inputs and outputs of this transaction. It should be the public key at the highest hardened derivation index so that the unhardened child keys used in the transaction can be derived. +*** {0x01}|{xpub} +** Value: The master key fingerprint as defined by BIP 32 concatenated with the derivation path of the public key. The derivation path is represented as 32 bit unsigned integer indexes concatenated with each other. The number of 32 bit unsigned integer indexes must match the depth provided in the extended public key. +*** {master key fingerprint}|{32-bit int}|...|{32-bit int} + The currently defined per-input types are defined as follows: * Type: Non-Witness UTXO PSBT_IN_NON_WITNESS_UTXO = 0x00 -- cgit v1.2.3 From e1f770e23617ddb5d9d78597c7377fd6f956f67d Mon Sep 17 00:00:00 2001 From: Andrew Chow Date: Sun, 9 Jun 2019 10:44:32 +0200 Subject: bip174: add section describing change detection --- bip-0174.mediawiki | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'bip-0174.mediawiki') diff --git a/bip-0174.mediawiki b/bip-0174.mediawiki index 8c9443e..1dc3b47 100644 --- a/bip-0174.mediawiki +++ b/bip-0174.mediawiki @@ -364,6 +364,23 @@ for input,i in enumerate(psbt.inputs): assert False +====Change Detection==== + +Signers may wish to display the inputs and outputs to users for extra verification. +In such displays, signers may wish to identify which outputs are change outputs in order to omit them to avoid additional user confusion. +In order to detect change, a signer can use the BIP 32 derivation paths provided in inputs and outputs as well as the extended public keys provided globally. + +For a single key output, a signer can observe whether the master fingerprint for the public key for that output belongs to itself. +If it does, it can then derive the public key at the specified derivation path and check whether that key is the one present in that output. + +For outputs involving multiple keys, a signer can first examine the inputs that it is signing. +It should determine the general pattern of the script and internally produce a representation of the policy that the script represents. +Such a policy can include things like how many keys are present, what order they are in, how many signers are necessary, which signers are required, etc. +The signer can then use the BIP 32 derivation paths for each of the pubkeys to find which global extended public key is the one that can derive that particular public key. +To do so, the signer would extract the derivation path to the highest hardened index and use that to lookup the public key with that index and master fingerprint. +The signer would construct this script policy with extended public keys for all of the inputs and outputs. +Change outputs would then be identified as being the outputs which have the same script policy as the inputs that are being signed. + ===Combiner=== The Combiner can accept 1 or many PSBTs. -- cgit v1.2.3 From 7ab9ef95c67051dcf6418ecd4310e63b036bc6f0 Mon Sep 17 00:00:00 2001 From: Luke Childs Date: Wed, 26 Jun 2019 16:47:04 +0700 Subject: [bip174] Fix typo in signer pseudo code --- bip-0174.mediawiki | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bip-0174.mediawiki') diff --git a/bip-0174.mediawiki b/bip-0174.mediawiki index f197728..cc165a5 100644 --- a/bip-0174.mediawiki +++ b/bip-0174.mediawiki @@ -337,7 +337,7 @@ sign_non_witness(script_code, i): for input,i in enumerate(psbt.inputs): if non_witness_utxo.exists: - assert(sha256d(non_witness_utxo) == psbt.tx.innput[i].prevout.hash) + assert(sha256d(non_witness_utxo) == psbt.tx.input[i].prevout.hash) if redeemScript.exists: assert(non_witness_utxo.vout[psbt.tx.input[i].prevout.n].scriptPubKey == P2SH(redeemScript)) sign_non_witness(redeemScript) -- cgit v1.2.3 From 97447f981fb9e2b0c4c0c8c095464c4dbd91da29 Mon Sep 17 00:00:00 2001 From: Jonathan Underwood Date: Wed, 10 Jul 2019 08:30:23 +0900 Subject: BIP174: Include suggested sighash check --- bip-0174.mediawiki | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'bip-0174.mediawiki') diff --git a/bip-0174.mediawiki b/bip-0174.mediawiki index f197728..b352c3b 100644 --- a/bip-0174.mediawiki +++ b/bip-0174.mediawiki @@ -319,6 +319,8 @@ For a Signer to only produce valid signatures for what it expects to sign, it mu * If a witness UTXO is provided, no non-witness signature may be created * If a redeemScript is provided, the scriptPubKey must be for that redeemScript * If a witnessScript is provided, the scriptPubKey or the redeemScript must be for that witnessScript +* If a sighash type is provided, the signer must check that the sighash is acceptable. If unacceptable, they must fail. +* If a sighash type is not provided, the signer should sign using SIGHASH_ALL, but may use any sighash type they wish. =====Simple Signer Algorithm===== @@ -326,13 +328,17 @@ A simple signer can use the following algorithm to determine what and how to sig
 sign_witness(script_code, i):
-    for key in psbt.inputs[i].keys:
-        if IsMine(key):
+    for key, sighash_type in psbt.inputs[i].items:
+        if sighash_type == None:
+            sighash_type = SIGHASH_ALL
+        if IsMine(key) and IsAcceptable(sighash_type):
             sign(witness_sighash(script_code, i, input))
 
 sign_non_witness(script_code, i):
-    for key in psbt.inputs[i].keys:
-        if IsMine(key):
+    for key, sighash_type in psbt.inputs[i].items:
+        if sighash_type == None:
+            sighash_type = SIGHASH_ALL
+        if IsMine(key) and IsAcceptable(sighash_type):
             sign(non_witness_sighash(script_code, i, input))
 
 for input,i in enumerate(psbt.inputs):
-- 
cgit v1.2.3


From 6a36d8e1b4e763bf42c8403f598e0bf07048408f Mon Sep 17 00:00:00 2001
From: Andrew Chow 
Date: Thu, 25 Jul 2019 13:37:06 -0400
Subject: BIP 174: global xpubs serialization test vector

---
 bip-0174.mediawiki | 4 ++++
 1 file changed, 4 insertions(+)

(limited to 'bip-0174.mediawiki')

diff --git a/bip-0174.mediawiki b/bip-0174.mediawiki
index b4a6407..c0fb559 100644
--- a/bip-0174.mediawiki
+++ b/bip-0174.mediawiki
@@ -546,6 +546,10 @@ The following are valid PSBTs:
 ** Bytes in Hex: 
70736274ff0100550200000001279a2323a5dfb51fc45f220fa58b0fc13e1e3342792a85d7e36cd6333b5cbc390000000000ffffffff01a05aea0b000000001976a914ffe9c0061097cc3b636f2cb0460fa4fc427d2b4588ac0000000000010120955eea0b0000000017a9146345200f68d189e1adc0df1c4d16ea8f14c0dbeb87220203b1341ccba7683b6af4f1238cd6e97e7167d569fac47f1e48d47541844355bd4646304302200424b58effaaa694e1559ea5c93bbfd4a89064224055cdf070b6771469442d07021f5c8eb0fea6516d60b8acb33ad64ede60e8785bfb3aa94b99bdf86151db9a9a010104220020771fd18ad459666dd49f3d564e3dbc42f4c84774e360ada16816a8ed488d5681010547522103b1341ccba7683b6af4f1238cd6e97e7167d569fac47f1e48d47541844355bd462103de55d1e1dac805e3f8a58c1fbf9b94c02f3dbaafe127fefca4995f26f82083bd52ae220603b1341ccba7683b6af4f1238cd6e97e7167d569fac47f1e48d47541844355bd4610b4a6ba67000000800000008004000080220603de55d1e1dac805e3f8a58c1fbf9b94c02f3dbaafe127fefca4995f26f82083bd10b4a6ba670000008000000080050000800000
** Base64 String:
cHNidP8BAFUCAAAAASeaIyOl37UfxF8iD6WLD8E+HjNCeSqF1+Ns1jM7XLw5AAAAAAD/////AaBa6gsAAAAAGXapFP/pwAYQl8w7Y28ssEYPpPxCfStFiKwAAAAAAAEBIJVe6gsAAAAAF6kUY0UgD2jRieGtwN8cTRbqjxTA2+uHIgIDsTQcy6doO2r08SOM1ul+cWfVafrEfx5I1HVBhENVvUZGMEMCIAQktY7/qqaU4VWepck7v9SokGQiQFXN8HC2dxRpRC0HAh9cjrD+plFtYLisszrWTt5g6Hhb+zqpS5m9+GFR25qaAQEEIgAgdx/RitRZZm3Unz1WTj28QvTIR3TjYK2haBao7UiNVoEBBUdSIQOxNBzLp2g7avTxI4zW6X5xZ9Vp+sR/HkjUdUGEQ1W9RiED3lXR4drIBeP4pYwfv5uUwC89uq/hJ/78pJlfJvggg71SriIGA7E0HMunaDtq9PEjjNbpfnFn1Wn6xH8eSNR1QYRDVb1GELSmumcAAACAAAAAgAQAAIAiBgPeVdHh2sgF4/iljB+/m5TALz26r+En/vykmV8m+CCDvRC0prpnAAAAgAAAAIAFAACAAAA=
+* Case: PSBT with one P2WSH input of a 2-of-2 multisig. witnessScript, keypaths, and global xpubs are available. Contains no signatures. Outputs filled. +** Bytes in Hex:
70736274ff01005202000000019dfc6628c26c5899fe1bd3dc338665bfd55d7ada10f6220973df2d386dec12760100000000ffffffff01f03dcd1d000000001600147b3a00bfdc14d27795c2b74901d09da6ef133579000000004f01043587cf02da3fd0088000000097048b1ad0445b1ec8275517727c87b4e4ebc18a203ffa0f94c01566bd38e9000351b743887ee1d40dc32a6043724f2d6459b3b5a4d73daec8fbae0472f3bc43e20cd90c6a4fae000080000000804f01043587cf02da3fd00880000001b90452427139cd78c2cff2444be353cd58605e3e513285e528b407fae3f6173503d30a5e97c8adbc557dac2ad9a7e39c1722ebac69e668b6f2667cc1d671c83cab0cd90c6a4fae000080010000800001012b0065cd1d000000002200202c5486126c4978079a814e13715d65f36459e4d6ccaded266d0508645bafa6320105475221029da12cdb5b235692b91536afefe5c91c3ab9473d8e43b533836ab456299c88712103372b34234ed7cf9c1fea5d05d441557927be9542b162eb02e1ab2ce80224c00b52ae2206029da12cdb5b235692b91536afefe5c91c3ab9473d8e43b533836ab456299c887110d90c6a4fae0000800000008000000000220603372b34234ed7cf9c1fea5d05d441557927be9542b162eb02e1ab2ce80224c00b10d90c6a4fae0000800100008000000000002202039eff1f547a1d5f92dfa2ba7af6ac971a4bd03ba4a734b03156a256b8ad3a1ef910ede45cc500000080000000800100008000
+** Base64 String:
cHNidP8BAFICAAAAAZ38ZijCbFiZ/hvT3DOGZb/VXXraEPYiCXPfLTht7BJ2AQAAAAD/////AfA9zR0AAAAAFgAUezoAv9wU0neVwrdJAdCdpu8TNXkAAAAATwEENYfPAto/0AiAAAAAlwSLGtBEWx7IJ1UXcnyHtOTrwYogP/oPlMAVZr046QADUbdDiH7h1A3DKmBDck8tZFmztaTXPa7I+64EcvO8Q+IM2QxqT64AAIAAAACATwEENYfPAto/0AiAAAABuQRSQnE5zXjCz/JES+NTzVhgXj5RMoXlKLQH+uP2FzUD0wpel8itvFV9rCrZp+OcFyLrrGnmaLbyZnzB1nHIPKsM2QxqT64AAIABAACAAAEBKwBlzR0AAAAAIgAgLFSGEmxJeAeagU4TcV1l82RZ5NbMre0mbQUIZFuvpjIBBUdSIQKdoSzbWyNWkrkVNq/v5ckcOrlHPY5DtTODarRWKZyIcSEDNys0I07Xz5wf6l0F1EFVeSe+lUKxYusC4ass6AIkwAtSriIGAp2hLNtbI1aSuRU2r+/lyRw6uUc9jkO1M4NqtFYpnIhxENkMak+uAACAAAAAgAAAAAAiBgM3KzQjTtfPnB/qXQXUQVV5J76VQrFi6wLhqyzoAiTACxDZDGpPrgAAgAEAAIAAAAAAACICA57/H1R6HV+S36K6evaslxpL0DukpzSwMVaiVritOh75EO3kXMUAAACAAAAAgAEAAIAA
+ * Case: PSBT with unknown types in the inputs. ** Bytes in Hex:
70736274ff01003f0200000001ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000000000ffffffff010000000000000000036a010000000000000a0f0102030405060708090f0102030405060708090a0b0c0d0e0f0000
** Base64 String:
cHNidP8BAD8CAAAAAf//////////////////////////////////////////AAAAAAD/////AQAAAAAAAAAAA2oBAAAAAAAACg8BAgMEBQYHCAkPAQIDBAUGBwgJCgsMDQ4PAAA=
-- cgit v1.2.3 From d832c51e82a321e4721cb9e8cc3e69e8e20aa57f Mon Sep 17 00:00:00 2001 From: "nicolas.dorier" Date: Thu, 25 Jul 2019 23:00:16 +0900 Subject: bip174: Add test vector for global xpub --- bip-0174.mediawiki | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'bip-0174.mediawiki') diff --git a/bip-0174.mediawiki b/bip-0174.mediawiki index b4a6407..3999b52 100644 --- a/bip-0174.mediawiki +++ b/bip-0174.mediawiki @@ -550,6 +550,10 @@ The following are valid PSBTs: ** Bytes in Hex:
70736274ff01003f0200000001ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000000000ffffffff010000000000000000036a010000000000000a0f0102030405060708090f0102030405060708090a0b0c0d0e0f0000
** Base64 String:
cHNidP8BAD8CAAAAAf//////////////////////////////////////////AAAAAAD/////AQAAAAAAAAAAA2oBAAAAAAAACg8BAgMEBQYHCAkPAQIDBAUGBwgJCgsMDQ4PAAA=
+* Case: PSBT with `PSBT_GLOBAL_XPUB`. +** Bytes in Hex:
70736274ff01009d0100000002710ea76ab45c5cb6438e607e59cc037626981805ae9e0dfd9089012abb0be5350100000000ffffffff190994d6a8b3c8c82ccbcfb2fba4106aa06639b872a8d447465c0d42588d6d670000000000ffffffff0200e1f505000000001976a914b6bc2c0ee5655a843d79afedd0ccc3f7dd64340988ac605af405000000001600141188ef8e4ce0449eaac8fb141cbf5a1176e6a088000000004f010488b21e039e530cac800000003dbc8a5c9769f031b17e77fea1518603221a18fd18f2b9a54c6c8c1ac75cbc3502f230584b155d1c7f1cd45120a653c48d650b431b67c5b2c13f27d7142037c1691027569c503100008000000080000000800001011f00e1f5050000000016001433b982f91b28f160c920b4ab95e58ce50dda3a4a220203309680f33c7de38ea6a47cd4ecd66f1f5a49747c6ffb8808ed09039243e3ad5c47304402202d704ced830c56a909344bd742b6852dccd103e963bae92d38e75254d2bb424502202d86c437195df46c0ceda084f2a291c3da2d64070f76bf9b90b195e7ef28f77201220603309680f33c7de38ea6a47cd4ecd66f1f5a49747c6ffb8808ed09039243e3ad5c1827569c5031000080000000800000008000000000010000000001011f00e1f50500000000160014388fb944307eb77ef45197d0b0b245e079f011de220202c777161f73d0b7c72b9ee7bde650293d13f095bc7656ad1f525da5fd2e10b11047304402204cb1fb5f869c942e0e26100576125439179ae88dca8a9dc3ba08f7953988faa60220521f49ca791c27d70e273c9b14616985909361e25be274ea200d7e08827e514d01220602c777161f73d0b7c72b9ee7bde650293d13f095bc7656ad1f525da5fd2e10b1101827569c5031000080000000800000008000000000000000000000220202d20ca502ee289686d21815bd43a80637b0698e1fbcdbe4caed445f6c1a0a90ef1827569c50310000800000008000000080000000000400000000
+** Base64 String:
cHNidP8BAJ0BAAAAAnEOp2q0XFy2Q45gflnMA3YmmBgFrp4N/ZCJASq7C+U1AQAAAAD/////GQmU1qizyMgsy8+y+6QQaqBmObhyqNRHRlwNQliNbWcAAAAAAP////8CAOH1BQAAAAAZdqkUtrwsDuVlWoQ9ea/t0MzD991kNAmIrGBa9AUAAAAAFgAUEYjvjkzgRJ6qyPsUHL9aEXbmoIgAAAAATwEEiLIeA55TDKyAAAAAPbyKXJdp8DGxfnf+oVGGAyIaGP0Y8rmlTGyMGsdcvDUC8jBYSxVdHH8c1FEgplPEjWULQxtnxbLBPyfXFCA3wWkQJ1acUDEAAIAAAACAAAAAgAABAR8A4fUFAAAAABYAFDO5gvkbKPFgySC0q5XljOUN2jpKIgIDMJaA8zx9446mpHzU7NZvH1pJdHxv+4gI7QkDkkPjrVxHMEQCIC1wTO2DDFapCTRL10K2hS3M0QPpY7rpLTjnUlTSu0JFAiAthsQ3GV30bAztoITyopHD2i1kBw92v5uQsZXn7yj3cgEiBgMwloDzPH3jjqakfNTs1m8fWkl0fG/7iAjtCQOSQ+OtXBgnVpxQMQAAgAAAAIAAAACAAAAAAAEAAAAAAQEfAOH1BQAAAAAWABQ4j7lEMH63fvRRl9CwskXgefAR3iICAsd3Fh9z0LfHK57nveZQKT0T8JW8dlatH1Jdpf0uELEQRzBEAiBMsftfhpyULg4mEAV2ElQ5F5rojcqKncO6CPeVOYj6pgIgUh9JynkcJ9cOJzybFGFphZCTYeJb4nTqIA1+CIJ+UU0BIgYCx3cWH3PQt8crnue95lApPRPwlbx2Vq0fUl2l/S4QsRAYJ1acUDEAAIAAAACAAAAAgAAAAAAAAAAAAAAiAgLSDKUC7iiWhtIYFb1DqAY3sGmOH7zb5MrtRF9sGgqQ7xgnVpxQMQAAgAAAAIAAAACAAAAAAAQAAAAA
+ Fails Signer checks * Case: A Witness UTXO is provided for a non-witness input -- cgit v1.2.3 From 503f35a9a066a51be29d9c81e73f72f54a403b76 Mon Sep 17 00:00:00 2001 From: Andrew Chow Date: Thu, 1 Aug 2019 14:28:37 -0400 Subject: Add Version type --- bip-0174.mediawiki | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'bip-0174.mediawiki') diff --git a/bip-0174.mediawiki b/bip-0174.mediawiki index b4a6407..bbc0fc6 100644 --- a/bip-0174.mediawiki +++ b/bip-0174.mediawiki @@ -124,6 +124,12 @@ The currently defined global types are as follows: ** Value: The master key fingerprint as defined by BIP 32 concatenated with the derivation path of the public key. The derivation path is represented as 32 bit unsigned integer indexes concatenated with each other. The number of 32 bit unsigned integer indexes must match the depth provided in the extended public key. *** {master key fingerprint}|{32-bit int}|...|{32-bit int} +* Type: Version Number PSBT_GLOBAL_VERSION = 0xFB +** Key: None. The key must only contain the 1 byte type. +*** {0xFB} +** Value: The 32-bit little endian unsigned integer representing the version number of this PSBT. If ommitted, the version number is 0. +*** {32-bit int} + The currently defined per-input types are defined as follows: * Type: Non-Witness UTXO PSBT_IN_NON_WITNESS_UTXO = 0x00 @@ -432,6 +438,17 @@ types will be ignored and passed-through by signers which do not know about them If one byte type fields were to ever run out, new extensions can still be added by defining multi-byte types where the first byte signals that the next byte indicates the type and so on. +===Version Numbers=== + +The Version number field exists only as a safeguard in the event that a backwards incompatible change is introduced to PSBT. +If a parser encounters a version number it does not recognize, it should exit immediately as this indicates that the PSBT will contain types that it does not know about and cannot be ignored. +Current PSBTs are Version 0. Any PSBT that does not have the version field is version 0. +It is not expected that any backwards incompatible change will be introduced to PSBT, so it is not expected that the version field will ever actually be seen. + +Updaters and combiners that need to add a version number to a PSBT should use the highest version number required. +For example, if a combiner sees two PSBTs for the same transaction, one with version 0, and the other with version 1, then it should combine them and produce a PSBT with version 1. +If an updater is updating a PSBT and needs to add a field that is only available in version 1, then it should set the PSBT version number to 1 unless a version higher than that is already specified. + ==Compatibility== This transaction format is designed so that it is unable to be properly unserialized -- cgit v1.2.3 From 20fdf77a2bcb04886b2b1d4d1b20b0135388ac4b Mon Sep 17 00:00:00 2001 From: Andrew Chow Date: Thu, 1 Aug 2019 14:36:25 -0400 Subject: Specify that types are compact size unsigned ints to allow for multi-byte types --- bip-0174.mediawiki | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'bip-0174.mediawiki') diff --git a/bip-0174.mediawiki b/bip-0174.mediawiki index bbc0fc6..d30b05d 100644 --- a/bip-0174.mediawiki +++ b/bip-0174.mediawiki @@ -106,8 +106,10 @@ The format of each key-value map is as follows: | Must be 0x00. |} -The first byte of each key specifies the type of the key-value pair. There are global types, -per-input types, and per-output types. +At the beginning of each key is a compact size unsigned integer representing the type. +This compact size unsigned integer must be minimally encoded, i.e. if the value can be represented using one byte, it must be represented as one byte. +For convenience, this BIP will specify types using their full serialization, so a multi-byte type will have it's full prefix and zero padding as necessary. +There are global types, per-input types, and per-output types. The currently defined global types are as follows: @@ -436,8 +438,6 @@ The Partially Signed Transaction format can be extended in the future by adding new types for key-value pairs. Backwards compatibilty will still be maintained as those new types will be ignored and passed-through by signers which do not know about them. -If one byte type fields were to ever run out, new extensions can still be added by defining multi-byte types where the first byte signals that the next byte indicates the type and so on. - ===Version Numbers=== The Version number field exists only as a safeguard in the event that a backwards incompatible change is introduced to PSBT. -- cgit v1.2.3 From b4e6b0fac257b773afd370d23f243ae22f8ab142 Mon Sep 17 00:00:00 2001 From: darosior Date: Mon, 16 Sep 2019 13:16:11 +0200 Subject: bip-0174: remove duplicated 'only' (typo) --- bip-0174.mediawiki | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bip-0174.mediawiki') diff --git a/bip-0174.mediawiki b/bip-0174.mediawiki index b4a6407..2a73053 100644 --- a/bip-0174.mediawiki +++ b/bip-0174.mediawiki @@ -313,7 +313,7 @@ If a Signer cannot sign a transaction, it must not add a Partial Signature. The Signer can additionally compute the addresses and values being sent, and the transaction fee, optionally showing this data to the user as a confirmation of intent and the consequences of signing the PSBT. -Signers do not need to sign for all possible input types. For example, a signer may choose to only sign only Segwit inputs. +Signers do not need to sign for all possible input types. For example, a signer may choose to only sign Segwit inputs. A single entity is likely to be both a Signer and an Updater as it can update a PSBT with necessary information prior to signing it. -- cgit v1.2.3 From f1aff33f46a8787d54813b25b6792d3d16902934 Mon Sep 17 00:00:00 2001 From: Kalle Rosenbaum Date: Fri, 20 Sep 2019 18:57:17 +0200 Subject: BIP174: Remove misleading sentence The sentence seems to suggest that the "master key fingerprint" can be the fingerprint of any intermediate node on the derivation path, which isn't true. --- bip-0174.mediawiki | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bip-0174.mediawiki') diff --git a/bip-0174.mediawiki b/bip-0174.mediawiki index 75a4df9..7deb0b1 100644 --- a/bip-0174.mediawiki +++ b/bip-0174.mediawiki @@ -205,7 +205,7 @@ determine which outputs are change outputs and verify that the change is returni * Type: BIP 32 Derivation Path PSBT_OUT_BIP32_DERIVATION = 0x02 ** Key: The public key *** {0x02}|{public key} -** Value: The master key fingerprint concatenated with the derivation path of the public key. The derivation path is represented as 32 bit unsigned integer indexes concatenated with each other. This must omit the index of the master key. Public keys are those needed to spend this output. +** Value: The master key fingerprint concatenated with the derivation path of the public key. The derivation path is represented as 32 bit unsigned integer indexes concatenated with each other. Public keys are those needed to spend this output. *** {master key fingerprint}|{32-bit int}|...|{32-bit int} The transaction format is specified as follows: -- cgit v1.2.3 From bc3a81e69819364af5c76f73762da2c95d6069ab Mon Sep 17 00:00:00 2001 From: Andrew Chow Date: Wed, 2 Oct 2019 15:09:51 -0400 Subject: Specify proprietary use type --- bip-0174.mediawiki | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'bip-0174.mediawiki') diff --git a/bip-0174.mediawiki b/bip-0174.mediawiki index d30b05d..8c9f010 100644 --- a/bip-0174.mediawiki +++ b/bip-0174.mediawiki @@ -132,6 +132,12 @@ The currently defined global types are as follows: ** Value: The 32-bit little endian unsigned integer representing the version number of this PSBT. If ommitted, the version number is 0. *** {32-bit int} +* Type: Version Number PSBT_GLOBAL_PROPRIETARY = 0xFC +** Key: Variable length identifier prefix, followed by a subtype, followed by the key data itself. +*** {0xFC}||{subtype}|{key data} +** Value: Any value data as defined by the proprietary type user. +*** + The currently defined per-input types are defined as follows: * Type: Non-Witness UTXO PSBT_IN_NON_WITNESS_UTXO = 0x00 @@ -194,6 +200,12 @@ The currently defined per-input types are defined as follows: ** Value: The UTF-8 encoded commitment message string for the proof-of-reserves. See [[bip-0127.mediawiki|BIP 127]] for more information. *** {porCommitment} +* Type: Version Number PSBT_INPUT_PROPRIETARY = 0xFC +** Key: Variable length identifier prefix, followed by a subtype, followed by the key data itself. +*** {0xFC}||{subtype}|{key data} +** Value: Any value data as defined by the proprietary type user. +*** + The currently defined per-output '''Why do we need per-output data?''' Per-output data allows signers to verify that the outputs are going to the intended recipient. The output data can also be use by signers to determine which outputs are change outputs and verify that the change is returning to the correct place. types are defined as follows: @@ -216,6 +228,12 @@ determine which outputs are change outputs and verify that the change is returni ** Value: The master key fingerprint concatenated with the derivation path of the public key. The derivation path is represented as 32 bit unsigned integer indexes concatenated with each other. This must omit the index of the master key. Public keys are those needed to spend this output. *** {master key fingerprint}|{32-bit int}|...|{32-bit int} +* Type: Version Number PSBT_OUTPUT_PROPRIETARY = 0xFC +** Key: Variable length identifier prefix, followed by a subtype, followed by the key data itself. +*** {0xFC}||{subtype}|{key data} +** Value: Any value data as defined by the proprietary type user. +*** + The transaction format is specified as follows: @@ -291,6 +309,23 @@ whichever value it wishes.'''Why can the values be arbitrarily chosen?''' W valid or invalid. If the values are invalid, a signer would simply produce an invalid signature and the final transaction itself would be invalid. If the values are valid, then it does not matter which is chosen as either way the transaction is still valid. +===Proprietary Use Type=== + +For all global, per-input, and per-output maps, the types 0xFC is reserved for proprietary use. +The proprietary use type requires keys that follow the type with a variable length string identifer, then a subtype. + +The identifier can be any variable length string that software can use to identify whether the particular data in the proprietary type can be used by it. +It can also be the empty string and just be a single 0x00 byte although this is not recommended. + +The subtype is defined by the proprietary type user and can mean whatever they want it to mean. +The subtype must also be a compact size unsigned integer in the same form as the normal types. +The key data and value data are defined by the proprietary type user. + +The proprietary use types is for private use by individuals and organizations who wish to use PSBT in their processes. +It is useful when there are additional data that they need attached to a PSBT but such data are not useful or available for the general public. +The proprietary use type is not to be used by any public specification and there is no expectation that any publicly available software be able to understand any specific meanings of it and the subtypes. +This type must be used for internal processes only. + ==Responsibilities== Using the transaction format involves many different responsibilities. Multiple responsibilities can be handled by a single entity, but each responsibility is specialized in what it should be capable of doing. -- cgit v1.2.3 From 87a85402ae23f087496883c757a066f4857b13f8 Mon Sep 17 00:00:00 2001 From: azuchi Date: Thu, 14 Nov 2019 11:53:05 +0900 Subject: BIP174: Fix wrong description about Proprietary Use Type --- bip-0174.mediawiki | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'bip-0174.mediawiki') diff --git a/bip-0174.mediawiki b/bip-0174.mediawiki index 49bc060..e47c0af 100644 --- a/bip-0174.mediawiki +++ b/bip-0174.mediawiki @@ -132,7 +132,7 @@ The currently defined global types are as follows: ** Value: The 32-bit little endian unsigned integer representing the version number of this PSBT. If ommitted, the version number is 0. *** {32-bit int} -* Type: Version Number PSBT_GLOBAL_PROPRIETARY = 0xFC +* Type: Proprietary Use Type PSBT_GLOBAL_PROPRIETARY = 0xFC ** Key: Variable length identifier prefix, followed by a subtype, followed by the key data itself. *** {0xFC}||{subtype}|{key data} ** Value: Any value data as defined by the proprietary type user. @@ -200,7 +200,7 @@ The currently defined per-input types are defined as follows: ** Value: The UTF-8 encoded commitment message string for the proof-of-reserves. See [[bip-0127.mediawiki|BIP 127]] for more information. *** {porCommitment} -* Type: Version Number PSBT_INPUT_PROPRIETARY = 0xFC +* Type: Proprietary Use Type PSBT_INPUT_PROPRIETARY = 0xFC ** Key: Variable length identifier prefix, followed by a subtype, followed by the key data itself. *** {0xFC}||{subtype}|{key data} ** Value: Any value data as defined by the proprietary type user. @@ -228,7 +228,7 @@ determine which outputs are change outputs and verify that the change is returni ** Value: The master key fingerprint concatenated with the derivation path of the public key. The derivation path is represented as 32 bit unsigned integer indexes concatenated with each other. Public keys are those needed to spend this output. *** {master key fingerprint}|{32-bit int}|...|{32-bit int} -* Type: Version Number PSBT_OUTPUT_PROPRIETARY = 0xFC +* Type: Proprietary Use Type PSBT_OUTPUT_PROPRIETARY = 0xFC ** Key: Variable length identifier prefix, followed by a subtype, followed by the key data itself. *** {0xFC}||{subtype}|{key data} ** Value: Any value data as defined by the proprietary type user. -- cgit v1.2.3 From 267c02a4b5c5550309b84bd60b6f72d9989ffb9b Mon Sep 17 00:00:00 2001 From: Dmitry Petukhov Date: Mon, 9 Dec 2019 12:21:09 +0500 Subject: BIP174: remove 'first byte is the type' comment for key data As the key type is now defined as compact size integer, `At the beginning of each key is a compact size unsigned integer representing the type`, the comment in the first table in the document, about first byte of the key being the key type is no longer accurate. As the structure of the key data is described further in the text after the table, and the comment that it starts with the compact size integer seems a bit long to be in that table, I think it is better to just remove the comment about the key data structure from the table, and leave the explanation to the text after the table. --- bip-0174.mediawiki | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bip-0174.mediawiki') diff --git a/bip-0174.mediawiki b/bip-0174.mediawiki index 49bc060..b964c81 100644 --- a/bip-0174.mediawiki +++ b/bip-0174.mediawiki @@ -69,7 +69,7 @@ the length of that data. {..} indicates the raw data itself. |- | Key | byte[] -| The key itself with the first byte being the type of the key-value pair +| The Key itself |- | Value Length | Compact Size Unsigned Integer -- cgit v1.2.3 From c7191c935e253506d6710d73b3d721f7b66ae371 Mon Sep 17 00:00:00 2001 From: Ben Carman Date: Mon, 9 Dec 2019 01:44:43 -0600 Subject: Specify 32 bit itns as unsigned and their endianess --- bip-0174.mediawiki | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'bip-0174.mediawiki') diff --git a/bip-0174.mediawiki b/bip-0174.mediawiki index 49bc060..c5c069b 100644 --- a/bip-0174.mediawiki +++ b/bip-0174.mediawiki @@ -123,14 +123,14 @@ The currently defined global types are as follows: * Type: Extended Public Key PSBT_GLOBAL_XPUB = 0x01 ** Key: The type followed by the 78 byte serialized extended public key as defined by BIP 32. Extended public keys are those that can be used to derive public keys used in the inputs and outputs of this transaction. It should be the public key at the highest hardened derivation index so that the unhardened child keys used in the transaction can be derived. *** {0x01}|{xpub} -** Value: The master key fingerprint as defined by BIP 32 concatenated with the derivation path of the public key. The derivation path is represented as 32 bit unsigned integer indexes concatenated with each other. The number of 32 bit unsigned integer indexes must match the depth provided in the extended public key. -*** {master key fingerprint}|{32-bit int}|...|{32-bit int} +** Value: The master key fingerprint as defined by BIP 32 concatenated with the derivation path of the public key. The derivation path is represented as 32-bit little endian unsigned integer indexes concatenated with each other. The number of 32 bit unsigned integer indexes must match the depth provided in the extended public key. +*** {master key fingerprint}|{32-bit uint}|...|{32-bit uint} * Type: Version Number PSBT_GLOBAL_VERSION = 0xFB ** Key: None. The key must only contain the 1 byte type. *** {0xFB} ** Value: The 32-bit little endian unsigned integer representing the version number of this PSBT. If ommitted, the version number is 0. -*** {32-bit int} +*** {32-bit uint} * Type: Version Number PSBT_GLOBAL_PROPRIETARY = 0xFC ** Key: Variable length identifier prefix, followed by a subtype, followed by the key data itself. @@ -180,7 +180,7 @@ The currently defined per-input types are defined as follows: ** Key: The public key *** {0x06}|{public key} ** Value: The master key fingerprint as defined by BIP 32 concatenated with the derivation path of the public key. The derivation path is represented as 32 bit unsigned integer indexes concatenated with each other. Public keys are those that will be needed to sign this input. -*** {master key fingerprint}|{32-bit int}|...|{32-bit int} +*** {master key fingerprint}|{32-bit uint}|...|{32-bit uint} * Type: Finalized scriptSig PSBT_IN_FINAL_SCRIPTSIG = 0x07 ** Key: None. The key must only contain the 1 byte type. @@ -225,8 +225,8 @@ determine which outputs are change outputs and verify that the change is returni * Type: BIP 32 Derivation Path PSBT_OUT_BIP32_DERIVATION = 0x02 ** Key: The public key *** {0x02}|{public key} -** Value: The master key fingerprint concatenated with the derivation path of the public key. The derivation path is represented as 32 bit unsigned integer indexes concatenated with each other. Public keys are those needed to spend this output. -*** {master key fingerprint}|{32-bit int}|...|{32-bit int} +** Value: The master key fingerprint concatenated with the derivation path of the public key. The derivation path is represented as 32-bit little endian unsigned integer indexes concatenated with each other. Public keys are those needed to spend this output. +*** {master key fingerprint}|{32-bit uint}|...|{32-bit uint} * Type: Version Number PSBT_OUTPUT_PROPRIETARY = 0xFC ** Key: Variable length identifier prefix, followed by a subtype, followed by the key data itself. -- cgit v1.2.3 From 65f0b3dd62ecc55e43436173c5f84e893809d0fa Mon Sep 17 00:00:00 2001 From: Dmitry Petukhov Date: Mon, 9 Dec 2019 17:30:47 +0500 Subject: BIP-174: test data: fix value length In the test case "Case: PSBT With invalid output witnessScript typed key", after PSBT_OUT_WITNESS_SCRIPT key with garbage data (which ends with `...478ef51309d`, follows value `2b` which would denote the length of the data value of the key. But the length of actual remaining data is only 7 bytes. Thus, an implementation that reads key-value pairs and checks for validity of the key data after it has read the current key-value pair, will not be able to hit the exact condition intended for this test case: extra data within the key itself. This is because such implementation will hit serialization error when it will try to read the data of the value and will get the short read. Reading full key-value pair and then checking key format afterwards is fairly normal thing to do, as the format of the keys with all their meaning is an abstraction of higher level than just the simple key-value serialization format. The proposed change is to replace byte `2b` after the key data to `06` and thus make the value length in the key-value pair valid (not going beyond the end of the data). base64 encoding has been changed accordingly. --- bip-0174.mediawiki | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'bip-0174.mediawiki') diff --git a/bip-0174.mediawiki b/bip-0174.mediawiki index 49bc060..56d7eb2 100644 --- a/bip-0174.mediawiki +++ b/bip-0174.mediawiki @@ -573,8 +573,8 @@ The following are invalid PSBTs: ** Base64 String:
cHNidP8BAHMCAAAAATAa6YblFqHsisW0vGVz0y+DtGXiOtdhZ9aLOOcwtNvbAAAAAAD/////AnR7AQAAAAAAF6kUA6oXrogrXQ1Usl1jEE5P/s57nqKHYEOZOwAAAAAXqRS5IbG6b3IuS/qDtlV6MTmYakLsg4cAAAAAAAEBHwDKmjsAAAAAFgAU0tlLZK4IWH7vyO6xh8YB6Tn5A3wAAgAAFgAUYunpgv/zTdgjlhAxawkM0qO3R8sAAQAiACCHa62DLx0WgBXtQSMqnqZaGBXZ7xPA74dZ9ktbKyeKZQEBJVEhA7fOI6AcW0vwCmQlN836uzFbZoMyhnR471EwnSvVf4qHUa4A
* Case: PSBT With invalid output witnessScript typed key -** Bytes in Hex:
70736274ff0100730200000001301ae986e516a1ec8ac5b4bc6573d32f83b465e23ad76167d68b38e730b4dbdb0000000000ffffffff02747b01000000000017a91403aa17ae882b5d0d54b25d63104e4ffece7b9ea2876043993b0000000017a914b921b1ba6f722e4bfa83b6557a3139986a42ec8387000000000001011f00ca9a3b00000000160014d2d94b64ae08587eefc8eeb187c601e939f9037c00010016001462e9e982fff34dd8239610316b090cd2a3b747cb000100220020876bad832f1d168015ed41232a9ea65a1815d9ef13c0ef8759f64b5b2b278a6521010025512103b7ce23a01c5b4bf00a642537cdfabb315b668332867478ef51309d2bd57f8a8751ae00
-** Base64 String:
cHNidP8BAHMCAAAAATAa6YblFqHsisW0vGVz0y+DtGXiOtdhZ9aLOOcwtNvbAAAAAAD/////AnR7AQAAAAAAF6kUA6oXrogrXQ1Usl1jEE5P/s57nqKHYEOZOwAAAAAXqRS5IbG6b3IuS/qDtlV6MTmYakLsg4cAAAAAAAEBHwDKmjsAAAAAFgAU0tlLZK4IWH7vyO6xh8YB6Tn5A3wAAQAWABRi6emC//NN2COWEDFrCQzSo7dHywABACIAIIdrrYMvHRaAFe1BIyqeploYFdnvE8Dvh1n2S1srJ4plIQEAJVEhA7fOI6AcW0vwCmQlN836uzFbZoMyhnR471EwnSvVf4qHUa4A
+** Bytes in Hex:
70736274ff0100730200000001301ae986e516a1ec8ac5b4bc6573d32f83b465e23ad76167d68b38e730b4dbdb0000000000ffffffff02747b01000000000017a91403aa17ae882b5d0d54b25d63104e4ffece7b9ea2876043993b0000000017a914b921b1ba6f722e4bfa83b6557a3139986a42ec8387000000000001011f00ca9a3b00000000160014d2d94b64ae08587eefc8eeb187c601e939f9037c00010016001462e9e982fff34dd8239610316b090cd2a3b747cb000100220020876bad832f1d168015ed41232a9ea65a1815d9ef13c0ef8759f64b5b2b278a6521010025512103b7ce23a01c5b4bf00a642537cdfabb315b668332867478ef51309d06d57f8a8751ae00
+** Base64 String:
cHNidP8BAHMCAAAAATAa6YblFqHsisW0vGVz0y+DtGXiOtdhZ9aLOOcwtNvbAAAAAAD/////AnR7AQAAAAAAF6kUA6oXrogrXQ1Usl1jEE5P/s57nqKHYEOZOwAAAAAXqRS5IbG6b3IuS/qDtlV6MTmYakLsg4cAAAAAAAEBHwDKmjsAAAAAFgAU0tlLZK4IWH7vyO6xh8YB6Tn5A3wAAQAWABRi6emC//NN2COWEDFrCQzSo7dHywABACIAIIdrrYMvHRaAFe1BIyqeploYFdnvE8Dvh1n2S1srJ4plIQEAJVEhA7fOI6AcW0vwCmQlN836uzFbZoMyhnR471EwnQbVf4qHUa4A
The following are valid PSBTs: -- cgit v1.2.3 From e097b1d38adc8643a8e0b1bb00e94a97b175314e Mon Sep 17 00:00:00 2001 From: Ben Carman Date: Wed, 11 Dec 2019 15:53:06 -0600 Subject: BIP 174: Specify that separator only appears at end of the map --- bip-0174.mediawiki | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bip-0174.mediawiki') diff --git a/bip-0174.mediawiki b/bip-0174.mediawiki index 49bc060..b14efe2 100644 --- a/bip-0174.mediawiki +++ b/bip-0174.mediawiki @@ -103,7 +103,7 @@ The format of each key-value map is as follows: | separator | char | 0x00 -| Must be 0x00. +| Must be 0x00 at the end of the map. |} At the beginning of each key is a compact size unsigned integer representing the type. -- cgit v1.2.3 From 8faf97e720f0800953e71cf156c899b1446ff455 Mon Sep 17 00:00:00 2001 From: Dmitry Petukhov Date: Sat, 14 Dec 2019 20:39:40 +0500 Subject: BIP-174: add missing types to Appendix A; fix proprietary type names PSBT_INPUT_PROPRIETARY -> PSBT_IN_PROPRIETARY PSBT_OUTPUT_PROPRIETARY -> PSBT_OUT_PROPRIETARY to be consistent with other in/out type names that use shortened `IN` and `OUT` --- bip-0174.mediawiki | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) (limited to 'bip-0174.mediawiki') diff --git a/bip-0174.mediawiki b/bip-0174.mediawiki index d95b119..3121012 100644 --- a/bip-0174.mediawiki +++ b/bip-0174.mediawiki @@ -200,7 +200,7 @@ The currently defined per-input types are defined as follows: ** Value: The UTF-8 encoded commitment message string for the proof-of-reserves. See [[bip-0127.mediawiki|BIP 127]] for more information. *** {porCommitment} -* Type: Proprietary Use Type PSBT_INPUT_PROPRIETARY = 0xFC +* Type: Proprietary Use Type PSBT_IN_PROPRIETARY = 0xFC ** Key: Variable length identifier prefix, followed by a subtype, followed by the key data itself. *** {0xFC}||{subtype}|{key data} ** Value: Any value data as defined by the proprietary type user. @@ -228,7 +228,7 @@ determine which outputs are change outputs and verify that the change is returni ** Value: The master key fingerprint concatenated with the derivation path of the public key. The derivation path is represented as 32-bit little endian unsigned integer indexes concatenated with each other. Public keys are those needed to spend this output. *** {master key fingerprint}|{32-bit uint}|...|{32-bit uint} -* Type: Proprietary Use Type PSBT_OUTPUT_PROPRIETARY = 0xFC +* Type: Proprietary Use Type PSBT_OUT_PROPRIETARY = 0xFC ** Key: Variable length identifier prefix, followed by a subtype, followed by the key data itself. *** {0xFC}||{subtype}|{key data} ** Value: Any value data as defined by the proprietary type user. @@ -748,6 +748,21 @@ Any data types, their associated scope and BIP number must be defined here | PSBT_GLOBAL_UNSIGNED_TX | BIP 174 |- +| Global +| 1 +| PSBT_GLOBAL_XPUB +| BIP 174 +|- +| Global +| 251 +| PSBT_GLOBAL_VERSION +| BIP 174 +|- +| Global +| 252 +| PSBT_GLOBAL_PROPRIETARY +| BIP 174 +|- | Input | 0 | PSBT_IN_NON_WITNESS_UTXO @@ -798,6 +813,11 @@ Any data types, their associated scope and BIP number must be defined here | PSBT_IN_POR_COMMITMENT | [[bip-0127.mediawiki|BIP 127]] |- +| Input +| 252 +| PSBT_IN_PROPRIETARY +| BIP 174 +|- | Output | 0 | PSBT_OUT_REDEEM_SCRIPT @@ -812,4 +832,9 @@ Any data types, their associated scope and BIP number must be defined here | 2 | PSBT_OUT_BIP32_DERIVATION | BIP 174 +|- +| Output +| 252 +| PSBT_OUT_PROPRIETARY +| BIP 174 |} -- cgit v1.2.3