Return-Path: Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id A686F8E2 for ; Mon, 21 Aug 2017 18:13:09 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-wr0-f178.google.com (mail-wr0-f178.google.com [209.85.128.178]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 428C542B for ; Mon, 21 Aug 2017 18:13:09 +0000 (UTC) Received: by mail-wr0-f178.google.com with SMTP id k46so31106693wre.2 for ; Mon, 21 Aug 2017 11:13:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=eHR1celKo7KRWJAYYgV3fxaxjo337fJSmZx6Ecx36y4=; b=s2z9Lco3D8LfHJ55w1bONXkRjaKYGSxz4B4h0C4HiAWPm+BvoMLscuosU73FngQhhU FX8D1RXB3nkAj9pJm+Uk4ux/9RwrOPQ3choKnYKffygKhDwmqn1rgDXCcp+VOuL7joGG qQUpVchTzD1bgzW+Y5oZG3NDho9XBiliqTwaFInmW29u1Fw0cysWIXxJX9az14Ex9qnN nfqKTDQz/eBH9wr3pyjE0h4Z0Lg/lGK3A9iKHVG/AQxlwOZSaGPkK7LEdxTZ0t0HLTGm 0UCXe8/SDMrYNJ6q93zSjIwYSJtNa+laO/p4krBSxoXxqpCfFzH0zZObzvXHAeHdxAWt +G0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=eHR1celKo7KRWJAYYgV3fxaxjo337fJSmZx6Ecx36y4=; b=ab5LcJIgpCJ89pRIq4HcCjKRICD/dqxeh0O1JDAGNAS+cYtrbj5ipmuQ+fzaGReg9f r/2GPlg7R0sdTBmp+BPlrwCQInUSPTQVs9MKd1rL+swiUckbwnLC4rsmvfcTfli0kJYL oq7gqW5n0k8Xg/p/UtCv1vrvK6bvoRpAU5/bn95VgURN235tMZ9xgyrhIHRTNaazaZmQ EQexWYkhd0GmwhNx/vTwveB6LLQUwdHN+dLmyXq4/S9dhJaHSy7p44JFn2A6hQZUr9wi W0xA/hmOhNwAaQg87UGWQeIJUT2bUA0cfEtfc8IYAgdwY3ZT8tN1HVgi5xzkkH6YGx3i qj6w== X-Gm-Message-State: AHYfb5iW0IrMoLSW1t5UqLGs2zSZgwOFqq7vs15S94rSV5hWAWXIlzup qdsOtp5RqBoTLBcdAK+h8NwvPZhU4eHt9CQ= X-Received: by 10.80.134.131 with SMTP id r3mr8080859eda.29.1503339187746; Mon, 21 Aug 2017 11:13:07 -0700 (PDT) MIME-Version: 1.0 Received: by 10.80.129.163 with HTTP; Mon, 21 Aug 2017 11:12:47 -0700 (PDT) In-Reply-To: References: From: Greg Sanders Date: Mon, 21 Aug 2017 11:12:47 -0700 Message-ID: To: Bryan Bishop , Bitcoin Protocol Discussion Content-Type: multipart/alternative; boundary="f403045c0ac8433b3e0557476e7f" Subject: Re: [bitcoin-dev] [BIP Proposal] Partially Signed Bitcoin Transaction (PSBT) format 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: Mon, 21 Aug 2017 18:13:09 -0000 --f403045c0ac8433b3e0557476e7f Content-Type: text/plain; charset="UTF-8" Some related thoughts and suggestion for an extension that kanzure suggested I post here: Hardware Wallet attacks by input ownership omission and fix ---------------------------------------------------------------------------------- So a while back I realized that to have HW wallets do safe automated coinjoins(without any user interaction be sure there are no fee dumps or handing money to others) you have to protect yourself from the case of signing one set of inputs while the other owned set is hidden from the device, then repeating the same action with the two sets reversed. Note that there is no support for such a mode in HW wallets today, but could possibly greatly increase liquidity of JoinMarket like systems. First signing pass: 1 BTC (yours, host tells ledger about it) -------- > 1.5 BTC 1 BTC (yours, host fails to tell ledger about it)- Second signing pass: 1 BTC (yours, host fails to tell ledger) --------- > 1.5 BTC 1 BTC (yours, host tells ledger about it)--------- In this scenario, you sign the first input, thinking "great I'm getting 0.5 BTC for running coinjoin" when in reality this will simply be re-played again later with the inputs switched, *costing* you 0.5 BTC. (Ledger doesn't support "negative fees", but imagine more more inputs are included that aren't yours.) More recently I noticed a more common issue along the same lines: With Segwit inputs, the entire transaction referred to in the prevout is generally no longer included for HW wallet signing API. This greatly speeds up signing since potentially multiple MBs of transactions are no longer passed into the device, but comes with a cost: An attacker can claim certain inputs' value is much lower than it actually is. In the first pass, the host reports the first input's value properly, and the second as lower. The signature on the first input will go through fine(value included in the sighash is only for that input), then attacker prompts a restart of signing, reporting the 2nd value properly, and first value improperly low, which allows the attacker to report the same fee twice on the device. Both signatures over each input are correct, but the user was prompted with an invalid fee amount(too low). To fix this I consulted with andytoshi and got something we think works for both cases: 1) When a signing device receives a partially signed transaction, all inputs must come with a ownership proof: - For the input at address A, a signature over H(A || x) using the key for A. 'x' is some private fixed key that only the signing device knows(most likely some privkey along some unique bip32 path). - For each input ownership proof, the HW wallet validates each signature over the hashed message, then attempts to "decode" the hash by applying its own 'x'. If the hash doesn't match, it cannot be its own input. - Sign for every input that is yours This at a minimum makes sure that the wallet's total "balance" will not go down more than the reported fee. Benefits: - Still small memory footprint compared to legacy signing - Allows user-interactionless coinjoins without putting funds at risk - These proofs can be created at any time, collected at the front of any CoinJoin like protocol. - These proofs can be passed around as additional fields for Partially Signed Bitcoin Transactions: https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2017-August/014838.html On Sun, Aug 20, 2017 at 5:00 PM, Bryan Bishop via bitcoin-dev < bitcoin-dev@lists.linuxfoundation.org> wrote: > On Fri, Aug 18, 2017 at 5:11 PM, Andrew Chow via bitcoin-dev < > bitcoin-dev@lists.linuxfoundation.org> wrote: >> >> I would like to propose a standard format for unsigned and partially >> signed transactions. >> > > Just a quick note but perhaps you and other readers would find this thread > (on hardware wallet BIP drafting) to be tangentially related and useful: > https://lists.linuxfoundation.org/pipermail/bitcoin-dev/ > 2016-August/013008.html > > - Bryan > http://heybryan.org/ > 1 512 203 0507 <(512)%20203-0507> > > _______________________________________________ > bitcoin-dev mailing list > bitcoin-dev@lists.linuxfoundation.org > https://lists.linuxfoundation.org/mailman/listinfo/bitcoin-dev > > --f403045c0ac8433b3e0557476e7f Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Some related thoughts and suggestion for an extension that= kanzure suggested I post here:

Hardware Wallet att= acks by input ownership omission and fix
------------------------= ----------------------------------------------------------
So a w= hile back I realized that to have HW wallets do safe automated coinjoins(wi= thout any user interaction be sure there are no fee dumps or handing money = to others) you have to protect yourself from the case of signing one set of= inputs while the other owned set is hidden from the device, then repeating= the same action with the two sets reversed.

Note = that there is no support for such a mode in HW wallets today, but could pos= sibly greatly increase liquidity of JoinMarket like systems.

=
First signing pass:
1 BTC (yours, host tells ledger ab= out it) --------
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 > =C2=A0 1.5 BTC
1 BTC (yours, host fails to tell ledger about it)-

Second signing pass:

1 BTC (yours, host fails to= tell ledger) ---------
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 > =C2=A0 1.5 BTC
1 BTC (yours, host tells ledger about it)---------

In this scenario, you sign the first input, thinking "great I= 'm getting 0.5 BTC for running coinjoin" when in reality this will= simply be re-played again later with the inputs switched, *costing* you 0.= 5 BTC. (Ledger doesn't support "negative fees", but imagine m= ore more inputs are included that aren't yours.)

More recently I noticed a more common issue along the same lines:
<= div>
With Segwit inputs, the entire transaction referred to i= n the prevout is generally no longer included for HW wallet signing API. Th= is greatly speeds up signing since potentially multiple MBs of transactions= are no longer passed into the device, but comes with a cost: An attacker c= an claim certain inputs' value is much lower than it actually is. In th= e first pass, the host reports the first input's value properly, and th= e second as lower. The signature on the first input will go through fine(va= lue included in the sighash is only for that input), then attacker prompts = a restart of signing, reporting the 2nd value properly, and first value imp= roperly low, which allows the attacker to report the same fee twice on the = device. Both signatures over each input are correct, but the user was promp= ted with an invalid fee amount(too low).

To fix th= is I consulted with andytoshi and got something we think works for both cas= es:

1) When a signing device receives a partially = signed transaction, all inputs must come with a ownership proof:
= - For the input at address A, a signature over H(A || x) using the key for = A. 'x' is some private fixed key that only the signing device knows= (most likely some privkey along some unique bip32 path).
- For ea= ch input ownership proof, the HW wallet validates each signature over the h= ashed message, then attempts to "decode" the hash by applying its= own 'x'. If the hash doesn't match, it cannot be its own input= .
- Sign for every input that is yours

T= his at a minimum makes sure that the wallet's total "balance"= will not go down more than the reported fee.

Bene= fits:
- Still small memory footprint compared to legacy signing
- Allows user-interactionless coinjoins without putting funds at r= isk
- These proofs can be created at any time, collected at the f= ront of any CoinJoin like protocol.
- These proofs can be passed = around as additional fields for Partially Signed Bitcoin Transactions: https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2017-A= ugust/014838.html

On Sun, Aug 20, 2017 at 5:00 PM, Bryan Bishop via bit= coin-dev <bitcoin-dev@lists.linuxfoundation.org>= ; wrote:
On Fri, Aug = 18, 2017 at 5:11 PM, Andrew Chow via bitcoin-dev <bitc= oin-dev@lists.linuxfoundation.org> wrote:
I would like to pr= opose a standard format for unsigned and partially signed transactions.=C2= =A0

Just a quick note but perhaps y= ou and other readers would find this thread (on hardware wallet BIP draftin= g) to be tangentially related and useful:
https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2016= -August/013008.html


_______________________________________________
bitcoin-dev mailing list
bitcoin-dev@lists.= linuxfoundation.org
https://lists.linuxfoundation.org= /mailman/listinfo/bitcoin-dev


--f403045c0ac8433b3e0557476e7f--