<div dir="ltr"><div>Been working on a proof-of-reserves tool POC for a while, trying to
 formalize the formats so that wallets can integrate more easily.<br></div><div><br></div><div><br></div><div>&lt;pre&gt;<br></div><div>  BIP: ?<br></div><div>  Layer: Applications<br></div><div>  Title: Simple Proof-of-Reserves Transactions<br></div><div>  Author: Steven Roose &lt;<a href="mailto:steven@stevenroose.org" rel="noreferrer nofollow noopener">steven@stevenroose.org</a>&gt;<br></div><div>  Comments-Summary: No comments yet.<br></div><div>  Comments-URI: tbd<br></div><div>  Status: Draft<br></div><div>  Type: Standards Track<br></div><div>  Created: 2019-01-28<br></div><div>  License: CC0-1.0<br></div><div>&lt;/pre&gt;<br></div><div><br></div><div><br></div><div>==Abstract==<br></div><div><br></div><div>This BIP describes a simple way to construct proof-of-reserves transactions.<br></div><div>This proposal formalizes a standard format for constructing such proofs, easing<br></div><div>their construction with existing wallet infrastructure and enabling general<br></div><div>proof-verification software.  It relies on existing standards such as regular<br></div><div>Bitcoin transaction serialization/validation and the BIP 174 PSBT format.<br></div><div>The proposal also includes the description of a PSBT extension for a better<br></div><div>user experience.<br></div><div><br></div><div>==Copyright==<br></div><div><br></div><div>This BIP is licensed under the Creative Commons CC0 1.0 Universal license.<br></div><div><br></div><div>==Motivation==<br></div><div><br></div><div>From the very early days in the history of Bitcoin, there have been companies<br></div><div>managing bitcoins for their users.  These users give up control over their coins<br></div><div>in return for a certain service.  Inevitably, there have been many cases of<br></div><div>companies losing their users&#39; bitcoins without timely disclosing such events to<br></div><div>the public.  Proofs of Reserves are a way for companies managing large amounts<br></div><div>of bitcoins to prove ownership over a given amount of funds.  The regular proof<br></div><div>of control helps to ensure that no significant loss has occurred.<br></div><div><br></div><div>While the term proof-of-reserves is not new by any means, the procedure is not<br></div><div>very common among high-value custodian companies.  One of the reasons for this<br></div><div>is that every company that wants to perform a proof-of-reserves has to construct<br></div><div>its own way to do so.  Accordingly, their users have to understand the<br></div><div>construction of the proof in order to be able to verify it.  This raises the bar<br></div><div>of entry both for custodians and for users.<br></div><div><br></div><div><br></div><div>===What this BIP is not doing===<br></div><div><br></div><div>The proof-of-reserve construction described in this document has some known<br></div><div>shortcomings, mostly with regards to its privacy properties.  While there exists<br></div><div>research about improved proof-of-reserves mechanisms that have much better<br></div><div>privacy properties&lt;ref&gt;Dagher, Gaby G., Benedikt Bünz, Joseph Bonneau, Jeremy<br></div><div>Clark, and Dan Boneh. &quot;Provisions: Privacy-preserving proofs of solvency for<br></div><div>Bitcoin exchanges.&quot; (2015).&lt;/ref&gt;, this BIP intentionally only formalizes<br></div><div>the de-facto existing method.<br></div><div><br></div><div><br></div><div>==Specification==<br></div><div><br></div><div>Our specification consists of two parts:<br></div><div># the format for the actual proofs<br></div><div># a file format used to package a set of proofs and relevant metadata<br></div><div><br></div><div>The final construction should have the following properties:<br></div><div>* flexible proof construction to support complex wallet infrastructures<br></div><div>* easy integration with existing wallet solutions (both hardware and software wallets)<br></div><div>* support for verification via a standard procedure, regardless of publisher of the proof<br></div><div>* proof prevents reuse of proofs by other parties by commiting to a message<br></div><div>*
 allow validating that the issuer had the funds under his control at a 
certain block, regardless of what happened after that block<br></div><div><br></div><div>===Proof Format===<br></div><div><br></div><div>To allow for maximal compatibility with existing systems, proofs are formatted as regular Bitcoin<br></div><div>transactions.  However, one small adaptation to the transaction is made that has two functions:<br></div><div># make the transaction unspendable to avoid putting funds at risk<br></div><div># link the proof to the issuer of the proof to prevent copying proofs from other custodians<br></div><div><br></div><div>The resulting construction is a Bitcoin transaction with the following<br></div><div>characteristics:<br></div><div><br></div><div>* The first input (the &quot;commitment input&quot;)<br></div><div>**
 MUST have the txid part of the previous outpoint set to the SHA-256 
hash of the commitment message prefixed with &quot;Proof-of-Reserves: 
&quot;&lt;ref&gt;If the message is &quot;Some Message&quot;, the txid part should be 
&lt;tt&gt;SHA-256(&quot;Proof-of-Reserves: Some Message&quot;)&lt;/tt&gt; with the
 string encoded as UTF-8.&lt;/ref&gt; and index 0.<br></div><div>* The remaining inputs<br></div><div>** MUST have signatures that commit to the commitment input (e.g. using &lt;tt&gt;SIGHASH_ALL&lt;/tt&gt;).<br></div><div>*
 The transaction MUST have a single output that is the exact sum of all 
the inputs, assuming the commitment input to have 0 value; this means 
the transaction has no miner fee.<br></div><div><br></div><div>The existence of the first input (which is just a commitment hash) ensures<br></div><div>that this transaction is invalid and can never be confirmed.<br></div><div><br></div><div><br></div><div>===Proof File Format===<br></div><div><br></div><div>In theory, the first part of the specification would be sufficient as a minimum<br></div><div>viable standard.  However, there are a number of motivations to extend the<br></div><div>standard with an extra layer of metadata:<br></div><div><br></div><div># constructing and combining multiple proofs<br></div><div>#:Having
 thousands of UTXOs spread across different offline and online wallets 
could make it difficult to construct a single proof transaction with all
 UTXOs.  Allowing multiple proof transactions with the same commitment 
message and block number gives extra flexibility to custodians with 
complex wallet infrastructure without making the combined proof less 
secure.<br></div><div># metadata for verification<br></div><div>#:Not 
all systems that will be used for verification have access to a full 
index of all transactions.  However, proofs should be easily verifiable 
even after some of the UTXOs used in the proof are no longer unspent.  
Metadata present in the proof allows for relatively efficient 
verification of proofs even if no transaction index is available.<br></div><div># potential future improvements<br></div><div>#:The
 extensible metadata format allows for amending the standard in the 
future.  One potential improvement would be having UTXO set 
commitments.  These would allow the proofs-of-reserves to come with 
accompanying proofs-of-inclusion of all used UTXOs in the UTXO set at 
the block of proof constsruction (making validation even more 
efficient).<br></div><div><br></div><div>The proposed proof-file format provides a standard way of combining multiple<br></div><div>proofs and associated metadata.  The specification of the format is in the<br></div><div>Protocol Buffers&lt;ref&gt;<a href="https://github.com/protocolbuffers/protobuf/" target="_blank" rel="noreferrer nofollow noopener">https://github.com/protocolbuffers/protobuf/</a>&lt;/ref&gt; format.<br></div><div><br></div><div>&lt;pre&gt;<br></div><div>syntax = &quot;proto3&quot;;<br></div><div>import &quot;google/protobuf/any.proto&quot;;<br></div><div><br></div><div>message OutputMeta {<br></div><div>// Identify the outpoint.<br></div><div>bytes txid = 1;<br></div><div>uint32 vout = 2;<br></div><div><br></div><div>// The block hash of the block where this output was created.<br></div><div>bytes block_hash = 3;<br></div><div>}<br></div><div><br></div><div>message FinalProof {<br></div><div>// The proof transaction.  Should be able to be parsed like a regular<br></div><div>// Bitcoin transaction.<br></div><div>bytes proof_tx = 1;<br></div><div><br></div><div>// The metadata of the ouputs used in the proof transaction.<br></div><div>repeated OutputMeta output_metadata = 2;<br></div><div>}<br></div><div><br></div><div>message ProofOfReserves {<br></div><div>// A version number for this format to enable extending it with<br></div><div>// additional fields.<br></div><div>uint32 version = 1;<br></div><div><br></div><div>// The network magic for the network in which the proofs are valid.<br></div><div>// 0xD9B4BEF9 for mainnet, 0x0709110B for testnet<br></div><div>//TODO consider BIP44 coin type ids instead:<br></div><div>// <a href="https://github.com/satoshilabs/slips/blob/master/slip-0044.md" target="_blank" rel="noreferrer nofollow noopener">https://github.com/satoshilabs/slips/blob/master/slip-0044.md</a><br></div><div>uint32 network_magic = 2;<br></div><div><br></div><div>// The commitment message for this proof-of-reserves. <br></div><div>// This message is global for all the proofs.<br></div><div>string message = 3;<br></div><div><br></div><div>// The block at which this proof is supposed to be validated.<br></div><div>// Verification should take into account unspentness of outputs at this<br></div><div>// block height.<br></div><div>bytes block_hash = 4;<br></div><div><br></div><div>// The set of final proof transactions with their output metadata.<br></div><div>repeated FinalProof final_proofs = 5;<br></div><div><br></div><div>// Reserved field that can potentially be used by proof-construction tools.<br></div><div>// It can be ignored for verification.<br></div><div>repeated google.protobuf.Any pending_proofs = 6;<br></div><div>}<br></div><div>&lt;/pre&gt;<br></div><div><br></div><div>The last field, &lt;tt&gt;pending_proofs&lt;/tt&gt;, leaves open some space in the same<br></div><div>file that can be used by proof-construction tools.  This allows them to<br></div><div>construct different proofs incrementally without having to switch between file<br></div><div>formats.<br></div><div><br></div><div><br></div><div>===PSBT (BIP 174) extension===<br></div><div><br></div><div>The &quot;commitment input&quot; detailed in the proof format section does not spend an<br></div><div>existing UTXO and thus shouldn&#39;t be signed (empty &lt;tt&gt;scriptSig&lt;/tt&gt; and<br></div><div>witness).  This can cause some problems when signing this type of transactions.<br></div><div>For example, hardware wallets often require the signer to provide information<br></div><div>about all inputs of transactions they are signing, such as the previous output<br></div><div>or previous transaction; this data obviously doesn&#39;t exist for the commitment<br></div><div>inputs.<br></div><div><br></div><div>For most existing devices, it&#39;s possible to circumvent these requirements by<br></div><div>providing dummy data or by instructing the device to ignore this specific<br></div><div>input.  However, there is still a UX problem.  Because the hardware wallet<br></div><div>device doesn&#39;t recognize the transaction as a proof-of-reserves transaction it<br></div><div>will think it is signing a regular transaction that is spending all the money<br></div><div>in the UTXOs.  Most devices will ask for confirmation with a message along the<br></div><div>lines of &quot;Are you sure you want to send XXX BTC to address [...]?&quot;.  This is<br></div><div>not the best user experience.<br></div><div><br></div><div>An addition to the BIP 174 PSBT format could help signing devices to recognize proof-of-reserve transactions.<br></div><div>The following field is added to the BIP 174 &lt;tt&gt;INPUT&lt;/tt&gt; map:<br></div><div><br></div><div>* Type: Proof-of-reserves commitment &lt;tt&gt;PSBT_IN_POR_COMMITMENT = 0x09&lt;/tt&gt;<br></div><div>** Key: None. The key must only contain the 1 byte type.<br></div><div>*** &lt;tt&gt;{0x09}&lt;/tt&gt;<br></div><div>** Value: The UTF-8 encoded commitment message string for the proof-of-reserves.<br></div><div>*** &lt;tt&gt;{porCommitment}&lt;/tt&gt;<br></div><div><br></div><div>Wallets processing an input that has this field set<br></div><div>*
 MUST make sure the txid of the previous outpoint is set to the SHA-256 
hash of the prefixed commitment message string, as detailed above;<br></div><div>* MUST assume the input value to be 0 (without requiring the previous output or transaction to be provided);<br></div><div>* SHOULD display the commitment message to ask the user for confirmation before signing any inputs;<br></div><div>* SHOULD only provide signatures with a signature hash that commits to this input;<br></div><div>*
 SHOULD accept an empty &lt;tt&gt;scriptSig&lt;/tt&gt; for this input 
(as if the &lt;tt&gt;scriptPubKey&lt;/tt&gt; was 
&lt;tt&gt;OP_TRUE&lt;/tt&gt;).<br></div><div><br></div><div><br></div><div>==Implementations==<br></div><div><br></div><div>A proof-of-concept implementation of the PSBT extension in the<br></div><div>[<a href="https://github.com/rust-bitcoin/rust-bitcoin" target="_blank" rel="noreferrer nofollow noopener">https://github.com/rust-bitcoin/rust-bitcoin</a> rust-bitcoin] project can be<br></div><div>found in the &lt;tt&gt;psbt-por&lt;/tt&gt; branch here:<br></div><div><a href="https://github.com/stevenroose/rust-bitcoin/tree/psbt-por" target="_blank" rel="noreferrer nofollow noopener">https://github.com/stevenroose/rust-bitcoin/tree/psbt-por</a><br></div><div><br></div><div>A work-in-progress implementation of a tool that produces and verifies proofs<br></div><div>in the described format can be found here:<br></div><div><a href="https://github.com/stevenroose/reserves" target="_blank" rel="noreferrer nofollow noopener">https://github.com/stevenroose/reserves</a><br></div><div><br></div><div><br></div><div>== Footnotes ==<br></div><div><br></div><div>&lt;references /&gt;<br></div><div><br></div><div>PR: <a href="https://github.com/bitcoin/bips/pull/756" target="_blank" rel="noreferrer nofollow noopener">https://github.com/bitcoin/bips/pull/756</a></div></div>