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 A9F6F11C0 for ; Mon, 26 Mar 2018 08:53:25 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-ot0-f174.google.com (mail-ot0-f174.google.com [74.125.82.174]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id C91F55D7 for ; Mon, 26 Mar 2018 08:53:24 +0000 (UTC) Received: by mail-ot0-f174.google.com with SMTP id m7-v6so19795381otd.1 for ; Mon, 26 Mar 2018 01:53:24 -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; bh=YAEHCH95I8GECMpPeDvIroo2vN3sYJjA9jdtLe9lvjk=; b=BQaEyk3zGJX2pwPcahA2unzGsWeBusom+401ME4UTveL1ggBDE/cu/wo/qJxtWNtNE xHgUmuzc5AMutEapfl9aKOY059FA+GgjH1xK4Vm2MNbbZM39VznWZQ8G8Emaq+kXylvA AGofU4i/7lm4yoxdI+2SNaisFsfB0wPcn4ZSLcfFVYMjYmbRDrHZWIESXN5MoAOneJ8V kJQcVHkZnCIxQ8aGlMSZg7Hkq9DIxnAG9upmKbgSXSBLxcOPw3c3vJg7ujZ52EmQU1sp On8h6OrEh7Ut+6CrUSAhtiV2ha4U2aCtQGGDnFwXkDUIWfx9tJoypf/USfeiKn73sRC7 EmlQ== 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; bh=YAEHCH95I8GECMpPeDvIroo2vN3sYJjA9jdtLe9lvjk=; b=BoHndj6JISl9YSirWoCXoHTohz+8iGw7e6pwNBuMhbtk2pTQEWJIdEoybUTgiIMQTE xXjSeZANr16ABAUa8m1ND+gm/tNbHMAZb7p0M08doYI+03C3BGjKw2JCS3qwOCXuNP4t 6rZMl9PySXg8E2CJPnu2WHwZmoyh8odEm6BEf5IewOXg1gzVQp7owikhbCztCdk88uE1 xWnAfo1PrOx3RU4PqDmmpCdq0tOGd3M9dy4R1Q0zwTJ7J8d9a9w66NUOOo5Hwk3kHfCp 5c7jWEUU+QrpOhKqlZYReFh6ytl3jaKR+G6ZmmRzMtfrMWVPnWu9bF+C0OEsnNSkSObH 3Wbg== X-Gm-Message-State: AElRT7Gws4c9RXT1YaW5JZbwhIKBcmZSGaRWFU4VsscW06/dl+OgDDYN sweuzTJRzC9juiUGgfFNXHLpJE+74A7U5HoyyhQ= X-Google-Smtp-Source: AIpwx49mOtFO4pshAgUIb6yRJLi2CoSjSFllKus6D8JumxpM6ZT/y0omZaGrgQOuJ7xyeF/0+Eblf44QWUNtIjW8eMw= X-Received: by 2002:a9d:550b:: with SMTP id l11-v6mr5953282oth.356.1522054403848; Mon, 26 Mar 2018 01:53:23 -0700 (PDT) MIME-Version: 1.0 Received: by 10.74.106.135 with HTTP; Mon, 26 Mar 2018 01:53:23 -0700 (PDT) In-Reply-To: References: From: Pieter Wuille Date: Mon, 26 Mar 2018 01:53:23 -0700 Message-ID: To: Karl Johan Alm , Bitcoin Protocol Discussion Content-Type: multipart/alternative; boundary="0000000000001201bd05684ce8f6" 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 Subject: Re: [bitcoin-dev] {sign|verify}message replacement 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, 26 Mar 2018 08:53:25 -0000 --0000000000001201bd05684ce8f6 Content-Type: text/plain; charset="UTF-8" Hello, Thanks for starting a discussion about this idea. A few comments inline: On Wed, Mar 14, 2018 at 1:09 AM, Karl Johan Alm via bitcoin-dev < bitcoin-dev@lists.linuxfoundation.org> wrote: > Hello, > > I am considering writing a replacement for the message signing tools > that are currently broken for all but the legacy 1xx addresses. The > approach (suggested by Pieter Wuille) is to do a script based > approach. This does not seem to require a lot of effort for > implementing in Bitcoin Core*. Below is my proposal for this system: > > A new structure SignatureProof is added, which is a simple scriptSig & > witnessProgram container that can be serialized. This is passed out > from/into the signer/verifier. > You need a bit more logic to deal with softforks and compatibility. The question is which script validation flags you verify with: * If you make them fixed, it means signatures can't evolve with new address types being introduced that rely on new features. * If you make it just consensus flags (following mainnet), it means that people with old software will see future invalid signatures as always valid; this is probably not acceptable. * If you make it standardness flags, you will get future valid signatures that fail to verify. One solution is to include a version number in the signature, which explicitly corresponds to a set of validation flags. When the version number is something a verifier doesn't know, it can be reported as inconclusive (it's relying on features you don't know about). An solution is to verify twice; once with all consensus rules you know about, and once with standardness rules. If they're both valid, the signature is valid. If they're both invalid, the signature is invalid. If they're different (consensus valid but standardness invalid), you report the signature validation as inconclusive (it's relying on features you don't know about). This approach works as long as new features only use previous standardness-invalid scripts, but perhaps a version number is still needed to indicate the standardness flags. RPC commands: > > sign
[=false] > Why not extend the existing signmessage/verifymessage RPC? For legacy addresses it can fall back to the existing signature algorithm, while using the script-based approach for all others. > > Generates a signature proof for using the same method that > would be used to spend coins sent to
.** > > verify
[=false] > > Deserializes and executes the proof using a custom signature checker > whose sighash is derived from . Returns true if the check > succeeds, and false otherwise. The scriptPubKey is derived directly > from
.** > > Feedback welcome. > > -Kalle. > > (**) If is true, is the sighash, otherwise > sighash=sha256d(message). > That's very dangerous I'm afraid. It could be used to trick someone into signing off on an actual transaction, if you get them to sign a "random looking" prehashed message. Even if you have a prehashed message, there is no problem with treating it as hex input to a second hashing step, so I think the prehashed option isn't needed. It's why the existing message signing functionality always forcibly prefixes "Bitcoin signed message:", to avoid signing something that unintentionally corresponds to a message intended for another goal. Cheers, -- Pieter --0000000000001201bd05684ce8f6 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hello,

Thanks for starting a discussion about this = idea.

A few comments inline:

On Wed, Mar 14, 2018 at 1:09 AM,= Karl Johan Alm via bitcoin-dev <bitcoin-dev@lists.lin= uxfoundation.org> wrote:
Hello,

I am considering writing a replacement for the message signing tools
that are currently broken for all but the legacy 1xx addresses. The
approach (suggested by Pieter Wuille) is to do a script based
approach. This does not seem to require a lot of effort for
implementing in Bitcoin Core*. Below is my proposal for this system:

A new structure SignatureProof is added, which is a simple scriptSig &<= br> witnessProgram container that can be serialized. This is passed out
from/into the signer/verifier.

You need= a bit more logic to deal with softforks and compatibility. The question is= which script validation flags you verify with:
* If you make= them fixed, it means signatures can't evolve with new address types be= ing introduced that rely on new features.
* If you make it ju= st consensus flags (following mainnet), it means that people with old softw= are will see future invalid signatures as always valid; this is probably no= t acceptable.
* If you make it standardness flags, you will g= et future valid signatures that fail to verify.

One solut= ion is to include a version number in the signature, which explicitly corre= sponds to a set of validation flags. When the version number is something a= verifier doesn't know, it can be reported as inconclusive (it's re= lying on features you don't know about).

An solution= is to verify twice; once with all consensus rules you know about, and once= with standardness rules. If they're both valid, the signature is valid= . If they're both invalid, the signature is invalid. If they're dif= ferent (consensus valid but standardness invalid), you report the signature= validation as inconclusive (it's relying on features you don't kno= w about). This approach works as long as new features only use previous sta= ndardness-invalid scripts, but perhaps a version number is still needed to = indicate the standardness flags.
=
RPC commands:

sign <address> <message> [<prehashed>=3Dfalse]

Why not extend the existing signmessage/verifymes= sage RPC? For legacy addresses it can fall back to the existing signature a= lgorithm, while using the script-based approach for all others.
=C2=A0

Generates a signature proof for <message> using the same method that<= br> would be used to spend coins sent to <address>.**

verify <address> <message> <proof> [<prehashed>=3Df= alse]

Deserializes and executes the proof using a custom signature checker
whose sighash is derived from <message>. Returns true if the check succeeds, and false otherwise. The scriptPubKey is derived directly
from <address>.**

Feedback welcome.

-Kalle.
=C2=A0
(**) If <prehashed> is true, <message> is the sighash, otherwis= e
sighash=3Dsha256d(message).

That's = very dangerous I'm afraid. It could be used to trick someone into signi= ng off on an actual transaction, if you get them to sign a "random loo= king" prehashed message. Even if you have a prehashed message, there i= s no problem with treating it as hex input to a second hashing step, so I t= hink the prehashed option isn't needed. It's why the existing messa= ge signing functionality always forcibly prefixes "Bitcoin signed mess= age:", to avoid signing something that unintentionally corresponds to = a message intended for another goal.

Cheers,

--
Pieter
=C2=A0
--0000000000001201bd05684ce8f6--