1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
Return-Path: <bitcoin-dev@wuille.net>
Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137])
by lists.linuxfoundation.org (Postfix) with ESMTP id 5A6F0C0893
for <bitcoin-dev@lists.linuxfoundation.org>;
Fri, 18 Dec 2020 02:02:14 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
by fraxinus.osuosl.org (Postfix) with ESMTP id 4EB81871ED
for <bitcoin-dev@lists.linuxfoundation.org>;
Fri, 18 Dec 2020 02:02:14 +0000 (UTC)
X-Virus-Scanned: amavisd-new at osuosl.org
Received: from fraxinus.osuosl.org ([127.0.0.1])
by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024)
with ESMTP id 3bh4aPWy8bRr
for <bitcoin-dev@lists.linuxfoundation.org>;
Fri, 18 Dec 2020 02:02:12 +0000 (UTC)
X-Greylist: from auto-whitelisted by SQLgrey-1.7.6
Received: from mail1.protonmail.ch (mail1.protonmail.ch [185.70.40.18])
by fraxinus.osuosl.org (Postfix) with ESMTPS id 8B4B6871D8
for <bitcoin-dev@lists.linuxfoundation.org>;
Fri, 18 Dec 2020 02:02:12 +0000 (UTC)
Date: Fri, 18 Dec 2020 02:02:04 +0000
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wuille.net;
s=protonmail2; t=1608256929;
bh=hnhxInQgpvDHJAK5KCKJllkM+tlkGiF+TckdhcVCrQ0=;
h=Date:To:From:Cc:Reply-To:Subject:In-Reply-To:References:From;
b=qDt3CzFfSZNiwUvxA3mfHzLJcDOk+WT8B0NB/GIMvwYBwbE+gjMKJ8Z4E988R6jQS
sEzAOmGWIByAl6Hr3csaXtIEiiManSmmx1vELXlue/MvxDX//2pBdJbtxd5DcR9FO1
fG25NH8oYfuL8gSMy7Lh8u0V8t07wGoH7TODGfi/eu4bM2xjJr5Cv15ppUBKchmyM1
GehTpdB5V6rM4BZ/0/cWSk3/4WbusPAmVZ9XO5X5FKiHkUdWhpKAnmUnRbclwOHwmA
eAjNJWadjLKgQ2b3/FefNFzmYTPPDwU1a9jYXNWTS6FLQpcyOoFAzWxFLG/hSp5fSy
tnvvmKiH33JmA==
To: Ryan Grant <bitcoin-dev@rgrant.org>
From: Pieter Wuille <bitcoin-dev@wuille.net>
Reply-To: Pieter Wuille <bitcoin-dev@wuille.net>
Message-ID: <lSjNGJjlvNIs7NxyAsWiS-HC6D2a4mabZDn_wAS7PvvQC8KePAACZ8BcihgWRfsEwJZqrTXfzzOxVXfZhxDm8SKHzN8lJ9TCVQ7e28to8Ko=@wuille.net>
In-Reply-To: <CAMnpzfqy-=65gZ_Nj1EjhLV3ExZhnJQ=9o+nAqf11VjxXP3L+Q@mail.gmail.com>
References: <87imblmutl.fsf@rustcorp.com.au> <878sc120f5.fsf@rustcorp.com.au>
<20201020102952.4iwpugi5dxawufgo@ganymede>
<Kw_jwhASjriebJpsuUyi0u9EQmIVR1pQ3Jocqd9VeVDlmoH9s36bFAwr3PXu_pJd-Xly-hKun_yenLwbJvVIYWmlAiF5lMxuquLO2pTmlLo=@wuille.net>
<CAMeZzJeG00q9DPQacidto5H16Ryb6ou6tnMDK1jnAuncnVXnsA@mail.gmail.com>
<CAMeZzJdQuS1-0qPvY+0-yqRfVXgZV_2hmHB5hZwykm5WxjUkgg@mail.gmail.com>
<5Zb8Vf0nq7_rg04OTJwVIY565lDZowEfBXX9IBVLIuG7lTa_sIe4BL3YbpBK2NUAZV7QasZTPHVo5J2uJoRgjj3TveBC12QEp9oTdnLis0k=@wuille.net>
<20201206130453.tiu36iigva2jj5qn@ganymede>
<CAMnpzfqy-=65gZ_Nj1EjhLV3ExZhnJQ=9o+nAqf11VjxXP3L+Q@mail.gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
Cc: Bitcoin Protocol Discussion <bitcoin-dev@lists.linuxfoundation.org>
Subject: Re: [bitcoin-dev] Progress on bech32 for future Segwit Versions
(BIP-173)
X-BeenThere: bitcoin-dev@lists.linuxfoundation.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: Bitcoin Protocol Discussion <bitcoin-dev.lists.linuxfoundation.org>
List-Unsubscribe: <https://lists.linuxfoundation.org/mailman/options/bitcoin-dev>,
<mailto:bitcoin-dev-request@lists.linuxfoundation.org?subject=unsubscribe>
List-Archive: <http://lists.linuxfoundation.org/pipermail/bitcoin-dev/>
List-Post: <mailto:bitcoin-dev@lists.linuxfoundation.org>
List-Help: <mailto:bitcoin-dev-request@lists.linuxfoundation.org?subject=help>
List-Subscribe: <https://lists.linuxfoundation.org/mailman/listinfo/bitcoin-dev>,
<mailto:bitcoin-dev-request@lists.linuxfoundation.org?subject=subscribe>
X-List-Received-Date: Fri, 18 Dec 2020 02:02:14 -0000
On Tuesday, December 8, 2020 9:39 AM, Ryan Grant <bitcoin-dev@rgrant.org> w=
rote:
> It looks like a good strategy for a bech32 library that is external to
> Bitcoin Core would be:
>
> - Default to the new M, under the same bech32 brand.
> - Provide an interface to explicitly use both M=3D1 and M=3D0x2bc830a3.
> - If decoding fails, throw an error; but in constructing that error
> inform whether the other M would have succeeded.
>
> - Provide an interface for a BIP173 implementation to peek at the
> witness version byte of the data part, which may also involve
> sanity-checking that byte for errors using a BIP173-specific
> understanding of the appropriate checksum.
I think there are two possible interfaces that make sense:
- Have the caller explicitly specify whether they want bech32 or bech32m (w=
hich someone - I think Rusty? - started using in reference to this new code=
and I'm going to adopt now).
- Have the bech32 decoding function return a tristate (failed, valid as bec=
h32, valid as bech32m). No string is ever valid as both, so there is no los=
s of information here.
The former is a bit cleaner, and also the only real choice if error locatio=
n hinting is desired. The second is more efficient if decoding twice is a p=
erformance concern.
Cheers,
--
Pieter
|