public inbox for bitcoindev@googlegroups.com
 help / color / mirror / Atom feed
From: Pieter Wuille <bitcoin-dev@wuille.net>
To: Ryan Grant <bitcoin-dev@rgrant.org>
Cc: Bitcoin Protocol Discussion <bitcoin-dev@lists.linuxfoundation.org>
Subject: Re: [bitcoin-dev] Progress on bech32 for future Segwit Versions (BIP-173)
Date: Fri, 18 Dec 2020 02:02:04 +0000	[thread overview]
Message-ID: <lSjNGJjlvNIs7NxyAsWiS-HC6D2a4mabZDn_wAS7PvvQC8KePAACZ8BcihgWRfsEwJZqrTXfzzOxVXfZhxDm8SKHzN8lJ9TCVQ7e28to8Ko=@wuille.net> (raw)
In-Reply-To: <CAMnpzfqy-=65gZ_Nj1EjhLV3ExZhnJQ=9o+nAqf11VjxXP3L+Q@mail.gmail.com>

On Tuesday, December 8, 2020 9:39 AM, Ryan Grant <bitcoin-dev@rgrant.org> wrote:

> 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=1 and M=0x2bc830a3.
> -   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 (which 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 bech32, valid as bech32m). No string is ever valid as both, so there is no loss of information here.

The former is a bit cleaner, and also the only real choice if error location hinting is desired. The second is more efficient if decoding twice is a performance concern.

Cheers,

--
Pieter



  reply	other threads:[~2020-12-18  2:02 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-08  0:21 [bitcoin-dev] Progress on bech32 for future Segwit Versions (BIP-173) Rusty Russell
2020-10-08 14:59 ` David A. Harding
2020-10-08 15:21   ` Russell O'Connor
2020-10-15  1:40   ` Rusty Russell
2020-10-16 21:09     ` Pieter Wuille
2020-10-19  0:49       ` Rusty Russell
2020-10-19 22:55         ` Pieter Wuille
2020-10-20  0:42           ` Rusty Russell
2020-10-20  3:31             ` Rusty Russell
2020-10-20  9:21               ` Riccardo Casatta
2020-10-20 10:29             ` David A. Harding
2020-10-20 20:12               ` Pieter Wuille
2020-10-20 23:52                 ` Mike Schmidt
2020-10-21  4:51                   ` Rusty Russell
2020-11-06 19:49                   ` Mike Schmidt
2020-12-05 23:10                     ` Pieter Wuille
2020-12-06 13:04                       ` David A. Harding
2020-12-06 20:43                         ` Pieter Wuille
2020-12-08 17:39                         ` Ryan Grant
2020-12-18  2:02                           ` Pieter Wuille [this message]
2020-10-21  3:05         ` ZmnSCPxj
2020-10-21  4:39           ` Rusty Russell
2020-10-28  0:20 ` Pieter Wuille
2020-12-05 22:59   ` Pieter Wuille

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='lSjNGJjlvNIs7NxyAsWiS-HC6D2a4mabZDn_wAS7PvvQC8KePAACZ8BcihgWRfsEwJZqrTXfzzOxVXfZhxDm8SKHzN8lJ9TCVQ7e28to8Ko=@wuille.net' \
    --to=bitcoin-dev@wuille.net \
    --cc=bitcoin-dev@lists.linuxfoundation.org \
    --cc=bitcoin-dev@rgrant.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox