From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id B3F38341F for ; Tue, 29 Jan 2019 22:00:24 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-qk1-f173.google.com (mail-qk1-f173.google.com [209.85.222.173]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 1882485A for ; Tue, 29 Jan 2019 22:00:23 +0000 (UTC) Received: by mail-qk1-f173.google.com with SMTP id w204so12538603qka.2 for ; Tue, 29 Jan 2019 14:00:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=YWGWGgwRqiqsvgvA879uEaH2vi7jmw3msTAySJvFZvA=; b=VxlmJbnVkxIl6osiX30gyosOpYdbiJEkhKqwsiHM8P7/pUBJqT0I0+zJQ79PfE+G8t O2m1QP4eUy0ZkV7dgVh8bhtHBszAyZrWW/g/xVdFQDLoDP+L/KyCTSNXinNAveN4QFC/ zSJEjg4irOc6swIPAHD6pHh5O70EgMFAlRYoXOvuY9MwGn0gHeqwwbYN6+LzLlPPqajl oz15zMIAQgyEmJyPXUrcQcWC05LcWwx953/zTRS58ohCzFf4CbvYDmjddGRB+i8YsHwA Rtf+5YjJxpbxGxUzZhbfy7k4wY1vRI1I9hDnY6vDTlh9Y8v1iotyDud3K+xj3ZQUJtLF N8Nw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=YWGWGgwRqiqsvgvA879uEaH2vi7jmw3msTAySJvFZvA=; b=Ysc47oqgzLd+2LXfluiklQb+ZuOf6+30Q3w/TDuvyZ0/7tmvqCVBg3rbicy0qghm2b tdtPxtIzH+b2pkTa+2lcEESiJHUy55/3ekfn7R86GbIfD3mTMNfKYNjbsUTcLbRX2vMN Sr9wev4vShHkmkyizQWql75kHZNXOZ67qVhPCnWU/Twp11UkhD76KSvBdicgF0kOd60o nFN4KJtw7aL7szBk+tHiEFI6JKOoQQ1dho7XEgWpG7ILVT5BY0YCFIYAisQ+cPGSiP3k ThD+QaEOYwLZbTGtjYkb1hoM7y+7OUFS1ySh4Ndk9/HWN7D/jvAUyvGm3iMcaKV/GEY3 aQJg== X-Gm-Message-State: AJcUukdhx20tEzkatnAuKTolzyyOVo6mZnaG4T7qzCTGGYY8Ag4caDWQ 9hQq0vKsCSoEcPtbIG/0oSOOmjH1OUxzQWxKb1g8gcRU X-Google-Smtp-Source: ALg8bN7Wc9P/9h7Av1Aw2QdAcC3pETWjs7wDEhle/z4D3PBDdmDM2rUwf7XJ5l6ExqEXcgVLJewkPBc+nsksX4eMPSs= X-Received: by 2002:a37:b9c2:: with SMTP id j185mr26054247qkf.333.1548799221819; Tue, 29 Jan 2019 14:00:21 -0800 (PST) MIME-Version: 1.0 From: Steven Roose Date: Tue, 29 Jan 2019 22:03:04 +0000 Message-ID: To: bitcoin-dev@lists.linuxfoundation.org Content-Type: multipart/alternative; boundary="00000000000071f07405809febcd" X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, HTML_MESSAGE, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org X-Mailman-Approved-At: Tue, 29 Jan 2019 22:51:32 +0000 Subject: [bitcoin-dev] [BIP Proposal] Simple Proof-of-Reserves Transactions X-BeenThere: bitcoin-dev@lists.linuxfoundation.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: Bitcoin Protocol Discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 29 Jan 2019 22:00:24 -0000 --00000000000071f07405809febcd Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Been working on a proof-of-reserves tool POC for a while, trying to formalize the formats so that wallets can integrate more easily.
  BIP: ?
  Layer: Applications
  Title: Simple Proof-of-Reserves Transactions
  Author: Steven Roose 
  Comments-Summary: No comments yet.
  Comments-URI: tbd
  Status: Draft
  Type: Standards Track
  Created: 2019-01-28
  License: CC0-1.0
=3D=3DAbstract=3D=3D This BIP describes a simple way to construct proof-of-reserves transactions= . This proposal formalizes a standard format for constructing such proofs, easing their construction with existing wallet infrastructure and enabling general proof-verification software. It relies on existing standards such as regular Bitcoin transaction serialization/validation and the BIP 174 PSBT format. The proposal also includes the description of a PSBT extension for a better user experience. =3D=3DCopyright=3D=3D This BIP is licensed under the Creative Commons CC0 1.0 Universal license. =3D=3DMotivation=3D=3D >From the very early days in the history of Bitcoin, there have been companies managing bitcoins for their users. These users give up control over their coins in return for a certain service. Inevitably, there have been many cases of companies losing their users' bitcoins without timely disclosing such events to the public. Proofs of Reserves are a way for companies managing large amounts of bitcoins to prove ownership over a given amount of funds. The regular proof of control helps to ensure that no significant loss has occurred. While the term proof-of-reserves is not new by any means, the procedure is not very common among high-value custodian companies. One of the reasons for this is that every company that wants to perform a proof-of-reserves has to construct its own way to do so. Accordingly, their users have to understand the construction of the proof in order to be able to verify it. This raises the bar of entry both for custodians and for users. =3D=3D=3DWhat this BIP is not doing=3D=3D=3D The proof-of-reserve construction described in this document has some known shortcomings, mostly with regards to its privacy properties. While there exists research about improved proof-of-reserves mechanisms that have much better privacy propertiesDagher, Gaby G., Benedikt B=C3=BCnz, Joseph Bonneau, Jeremy Clark, and Dan Boneh. "Provisions: Privacy-preserving proofs of solvency fo= r Bitcoin exchanges." (2015)., this BIP intentionally only formalizes the de-facto existing method. =3D=3DSpecification=3D=3D Our specification consists of two parts: # the format for the actual proofs # a file format used to package a set of proofs and relevant metadata The final construction should have the following properties: * flexible proof construction to support complex wallet infrastructures * easy integration with existing wallet solutions (both hardware and software wallets) * support for verification via a standard procedure, regardless of publisher of the proof * proof prevents reuse of proofs by other parties by commiting to a message * allow validating that the issuer had the funds under his control at a certain block, regardless of what happened after that block =3D=3D=3DProof Format=3D=3D=3D To allow for maximal compatibility with existing systems, proofs are formatted as regular Bitcoin transactions. However, one small adaptation to the transaction is made that has two functions: # make the transaction unspendable to avoid putting funds at risk # link the proof to the issuer of the proof to prevent copying proofs from other custodians The resulting construction is a Bitcoin transaction with the following characteristics: * The first input (the "commitment input") ** MUST have the txid part of the previous outpoint set to the SHA-256 hash of the commitment message prefixed with "Proof-of-Reserves: "If the message is "Some Message", the txid part should be SHA-256("Proof-of-Reserves: Some Message") with the string encoded as UTF-8. and index 0. * The remaining inputs ** MUST have signatures that commit to the commitment input (e.g. using SIGHASH_ALL). * 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. The existence of the first input (which is just a commitment hash) ensures that this transaction is invalid and can never be confirmed. =3D=3D=3DProof File Format=3D=3D=3D In theory, the first part of the specification would be sufficient as a minimum viable standard. However, there are a number of motivations to extend the standard with an extra layer of metadata: # constructing and combining multiple proofs #: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. # metadata for verification #: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. # potential future improvements #: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). The proposed proof-file format provides a standard way of combining multipl= e proofs and associated metadata. The specification of the format is in the Protocol Buffershttps://github.com/protocolbuffers/protobuf/ format.
syntax =3D "proto3";
import "google/protobuf/any.proto";

message OutputMeta {
// Identify the outpoint.
bytes txid =3D 1;
uint32 vout =3D 2;

// The block hash of the block where this output was created.
bytes block_hash =3D 3;
}

message FinalProof {
// The proof transaction.  Should be able to be parsed like a regular
// Bitcoin transaction.
bytes proof_tx =3D 1;

// The metadata of the ouputs used in the proof transaction.
repeated OutputMeta output_metadata =3D 2;
}

message ProofOfReserves {
// A version number for this format to enable extending it with
// additional fields.
uint32 version =3D 1;

// The network magic for the network in which the proofs are valid.
// 0xD9B4BEF9 for mainnet, 0x0709110B for testnet
//TODO consider BIP44 coin type ids instead:
// https://github.com/satoshilabs/slips/blob/master/slip-0044.md
uint32 network_magic =3D 2;

// The commitment message for this proof-of-reserves.
// This message is global for all the proofs.
string message =3D 3;

// The block at which this proof is supposed to be validated.
// Verification should take into account unspentness of outputs at this
// block height.
bytes block_hash =3D 4;

// The set of final proof transactions with their output metadata.
repeated FinalProof final_proofs =3D 5;

// Reserved field that can potentially be used by proof-construction tools.
// It can be ignored for verification.
repeated google.protobuf.Any pending_proofs =3D 6;
}
The last field, pending_proofs, leaves open some space in the same file that can be used by proof-construction tools. This allows them to construct different proofs incrementally without having to switch between file formats. =3D=3D=3DPSBT (BIP 174) extension=3D=3D=3D The "commitment input" detailed in the proof format section does not spend an existing UTXO and thus shouldn't be signed (empty scriptSig and witness). This can cause some problems when signing this type of transactions. For example, hardware wallets often require the signer to provide information about all inputs of transactions they are signing, such as the previous output or previous transaction; this data obviously doesn't exist for the commitment inputs. For most existing devices, it's possible to circumvent these requirements b= y providing dummy data or by instructing the device to ignore this specific input. However, there is still a UX problem. Because the hardware wallet device doesn't recognize the transaction as a proof-of-reserves transaction it will think it is signing a regular transaction that is spending all the money in the UTXOs. Most devices will ask for confirmation with a message along the lines of "Are you sure you want to send XXX BTC to address [...]?". This i= s not the best user experience. An addition to the BIP 174 PSBT format could help signing devices to recognize proof-of-reserve transactions. The following field is added to the BIP 174 INPUT map: * Type: Proof-of-reserves commitment PSBT_IN_POR_COMMITMENT =3D 0x09 ** Key: None. The key must only contain the 1 byte type. *** {0x09} ** Value: The UTF-8 encoded commitment message string for the proof-of-reserves. *** {porCommitment} Wallets processing an input that has this field set * 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; * MUST assume the input value to be 0 (without requiring the previous output or transaction to be provided); * SHOULD display the commitment message to ask the user for confirmation before signing any inputs; * SHOULD only provide signatures with a signature hash that commits to this input; * SHOULD accept an empty scriptSig for this input (as if the scriptPubKey was OP_TRUE). =3D=3DImplementations=3D=3D A proof-of-concept implementation of the PSBT extension in the [https://github.com/rust-bitcoin/rust-bitcoin rust-bitcoin] project can be found in the psbt-por branch here: https://github.com/stevenroose/rust-bitcoin/tree/psbt-por A work-in-progress implementation of a tool that produces and verifies proofs in the described format can be found here: https://github.com/stevenroose/reserves =3D=3D Footnotes =3D=3D PR: https://github.com/bitcoin/bips/pull/756 --00000000000071f07405809febcd Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Been working on a proof-of-reserves tool POC for a wh= ile, trying to formalize the formats so that wallets can integrate more easily.
=


<pre>
=C2=A0 BIP: ?<= br>
=C2=A0 Layer: Applications
=C2=A0 Title: Simple= Proof-of-Reserves Transactions
=C2=A0 Author: Steven Roose &= lt;steven@stevenroose.org>
=C2=A0 Comments-Summary= : No comments yet.
=C2=A0 Comments-URI: tbd
=C2= =A0 Status: Draft
=C2=A0 Type: Standards Track
= =C2=A0 Created: 2019-01-28
=C2=A0 License: CC0-1.0
<= div></pre>


=3D=3DAbstract= =3D=3D

This BIP describes a simple way to cons= truct proof-of-reserves transactions.
This proposal formalize= s a standard format for constructing such proofs, easing
thei= r construction with existing wallet infrastructure and enabling general
=
proof-verification software.=C2=A0 It relies on existing standar= ds such as regular
Bitcoin transaction serialization/validati= on and the BIP 174 PSBT format.
The proposal also includes th= e description of a PSBT extension for a better
user experienc= e.

=3D=3DCopyright=3D=3D

This BIP is licensed under the Creative Commons CC0 1.0 Universal l= icense.

=3D=3DMotivation=3D=3D
<= br>
From the very early days in the history of Bitcoin, there hav= e been companies
managing bitcoins for their users.=C2=A0 The= se users give up control over their coins
in return for a cer= tain service.=C2=A0 Inevitably, there have been many cases of
companies losing their users' bitcoins without timely disclosing such = events to
the public.=C2=A0 Proofs of Reserves are a way for = companies managing large amounts
of bitcoins to prove ownersh= ip over a given amount of funds.=C2=A0 The regular proof
of c= ontrol helps to ensure that no significant loss has occurred.

While the term proof-of-reserves is not new by any means, t= he procedure is not
very common among high-value custodian co= mpanies.=C2=A0 One of the reasons for this
is that every comp= any that wants to perform a proof-of-reserves has to construct
its own way to do so.=C2=A0 Accordingly, their users have to understand t= he
construction of the proof in order to be able to verify it= .=C2=A0 This raises the bar
of entry both for custodians and = for users.


=3D=3D=3DWhat this B= IP is not doing=3D=3D=3D

The proof-of-reserve = construction described in this document has some known
shortc= omings, mostly with regards to its privacy properties.=C2=A0 While there ex= ists
research about improved proof-of-reserves mechanisms tha= t have much better
privacy properties<ref>Dagher, Gaby = G., Benedikt B=C3=BCnz, Joseph Bonneau, Jeremy
Clark, and Dan= Boneh. "Provisions: Privacy-preserving proofs of solvency for
Bitcoin exchanges." (2015).</ref>, this BIP intentionally= only formalizes
the de-facto existing method.
=

=3D=3DSpecification=3D=3D

<= /div>
Our specification consists of two parts:
# the form= at for the actual proofs
# a file format used to package a se= t of proofs and relevant metadata

The final co= nstruction should have the following properties:
* flexible p= roof construction to support complex wallet infrastructures
*= easy integration with existing wallet solutions (both hardware and softwar= e wallets)
* support for verification via a standard procedur= e, regardless of publisher of the proof
* proof prevents reus= e of proofs by other parties by commiting to a message
* allow validating that the issuer had the funds under his control at a=20 certain block, regardless of what happened after that block
<= br>
=3D=3D=3DProof Format=3D=3D=3D

T= o allow for maximal compatibility with existing systems, proofs are formatt= ed as regular Bitcoin
transactions.=C2=A0 However, one small = adaptation to the transaction is made that has two functions:
# make the transaction unspendable to avoid putting funds at risk
# link the proof to the issuer of the proof to prevent copying proofs= from other custodians

The resulting construct= ion is a Bitcoin transaction with the following
characteristi= cs:

* The first input (the "commitment in= put")
** MUST have the txid part of the previous outpoint set to the SHA-256=20 hash of the commitment message prefixed with "Proof-of-Reserves:=20 "<ref>If the message is "Some Message", the txid part = should be=20 <tt>SHA-256("Proof-of-Reserves: Some Message")</tt> w= ith the string encoded as UTF-8.</ref> and index 0.
* The rema= ining inputs
** MUST have signatures that commit to the commi= tment input (e.g. using <tt>SIGHASH_ALL</tt>).
* The transaction MUST have a single output that is the exact sum of all=20 the inputs, assuming the commitment input to have 0 value; this means=20 the transaction has no miner fee.

The existenc= e of the first input (which is just a commitment hash) ensures
that this transaction is invalid and can never be confirmed.


=3D=3D=3DProof File Format=3D=3D=3D

In theory, the first part of the specification would = be sufficient as a minimum
viable standard.=C2=A0 However, th= ere are a number of motivations to extend the
standard with a= n extra layer of metadata:

# constructing and = combining multiple proofs
#:Having thousands of UTXOs spread across different offline and online wallets=20 could make it difficult to construct a single proof transaction with all UTXOs.=C2=A0 Allowing multiple proof transactions with the same commitment= =20 message and block number gives extra flexibility to custodians with=20 complex wallet infrastructure without making the combined proof less=20 secure.
# metadata for verification
#:Not=20 all systems that will be used for verification have access to a full=20 index of all transactions.=C2=A0 However, proofs should be easily verifiabl= e=20 even after some of the UTXOs used in the proof are no longer unspent.=C2=A0= =20 Metadata present in the proof allows for relatively efficient=20 verification of proofs even if no transaction index is available.
=
# potential future improvements
#:The extensible metadata format allows for amending the standard in the=20 future.=C2=A0 One potential improvement would be having UTXO set=20 commitments.=C2=A0 These would allow the proofs-of-reserves to come with=20 accompanying proofs-of-inclusion of all used UTXOs in the UTXO set at=20 the block of proof constsruction (making validation even more=20 efficient).

The proposed proof-file format pro= vides a standard way of combining multiple
proofs and associa= ted metadata.=C2=A0 The specification of the format is in the
Protocol Buffers<ref>https://gi= thub.com/protocolbuffers/protobuf/</ref> format.
<pre>
syntax =3D "proto3";
import "google/protobuf/any.proto";

message OutputMeta {
// Identify the outpoint.
bytes txid =3D 1;
uint32 vout =3D 2;
<= br>
// The block hash of the block where this output was created.=
bytes block_hash =3D 3;
}

message FinalProof {
// The proof transaction.=C2=A0= Should be able to be parsed like a regular
// Bitcoin transa= ction.
bytes proof_tx =3D 1;

// = The metadata of the ouputs used in the proof transaction.
rep= eated OutputMeta output_metadata =3D 2;
}

<= /div>
message ProofOfReserves {
// A version number for t= his format to enable extending it with
// additional fields.<= br>
uint32 version =3D 1;

// The net= work magic for the network in which the proofs are valid.
// = 0xD9B4BEF9 for mainnet, 0x0709110B for testnet
//TODO conside= r BIP44 coin type ids instead:
uint32 network_magic =3D 2;
<= br>
// The commitment message for this proof-of-reserves.=C2=A0
// This message is global for all the proofs.
st= ring message =3D 3;

// The block at which this= proof is supposed to be validated.
// Verification should ta= ke into account unspentness of outputs at this
// block heigh= t.
bytes block_hash =3D 4;

// Th= e set of final proof transactions with their output metadata.
repeated FinalProof final_proofs =3D 5;

// Re= served field that can potentially be used by proof-construction tools.
<= /div>
// It can be ignored for verification.
repeated goo= gle.protobuf.Any pending_proofs =3D 6;
}
</p= re>

The last field, <tt>pending_proof= s</tt>, leaves open some space in the same
file that ca= n be used by proof-construction tools.=C2=A0 This allows them to
<= div>construct different proofs incrementally without having to switch betwe= en file
formats.


= =3D=3D=3DPSBT (BIP 174) extension=3D=3D=3D

The= "commitment input" detailed in the proof format section does not= spend an
existing UTXO and thus shouldn't be signed (emp= ty <tt>scriptSig</tt> and
witness).=C2=A0 This ca= n cause some problems when signing this type of transactions.
For example, hardware wallets often require the signer to provide informat= ion
about all inputs of transactions they are signing, such a= s the previous output
or previous transaction; this data obvi= ously doesn't exist for the commitment
inputs.
<= div>
For most existing devices, it's possible to circumve= nt these requirements by
providing dummy data or by instructi= ng the device to ignore this specific
input.=C2=A0 However, t= here is still a UX problem.=C2=A0 Because the hardware wallet
device doesn't recognize the transaction as a proof-of-reserves transa= ction it
will think it is signing a regular transaction that = is spending all the money
in the UTXOs.=C2=A0 Most devices wi= ll ask for confirmation with a message along the
lines of &qu= ot;Are you sure you want to send XXX BTC to address [...]?".=C2=A0 Thi= s is
not the best user experience.

An addition to the BIP 174 PSBT format could help signing devices to rec= ognize proof-of-reserve transactions.
The following field is = added to the BIP 174 <tt>INPUT</tt> map:

* Type: Proof-of-reserves commitment <tt>PSBT_IN_POR_COMMITMEN= T =3D 0x09</tt>
** Key: None. The key must only contain= the 1 byte type.
*** <tt>{0x09}</tt>
** Value: The UTF-8 encoded commitment message string for the proof-of-r= eserves.
*** <tt>{porCommitment}</tt>

Wallets processing an input that has this field set
* MUST make sure the txid of the previous outpoint is set to the SHA-256=20 hash of the prefixed commitment message string, as detailed above;
* MUST assume the input value to be 0 (without requiring the previous= output or transaction to be provided);
* SHOULD display the = commitment message to ask the user for confirmation before signing any inpu= ts;
* SHOULD only provide signatures with a signature hash th= at commits to this input;
* SHOULD accept an empty <tt>scriptSig</tt> for this input=20 (as if the <tt>scriptPubKey</tt> was=20 <tt>OP_TRUE</tt>).


= =3D=3DImplementations=3D=3D

A proof-of-concept= implementation of the PSBT extension in the
[https://github.com/rust-bitcoin/rust-bitcoin rust= -bitcoin] project can be
found in the <tt>psbt-por</= tt> branch here:
https://github.com/stevenroose/rust-bitcoin/tree/psbt-por
<= /div>

A work-in-progress implementation of a tool that p= roduces and verifies proofs
in the described format can be fo= und here:


=3D=3D= Footnotes =3D=3D

--00000000000071f07405809febcd--