public inbox for bitcoindev@googlegroups.com
 help / color / mirror / Atom feed
From: Pieter Wuille <bitcoin-dev@wuille.net>
To: nakagat <nakagat@gmail.com>
Cc: Bitcoin Protocol Discussion <bitcoin-dev@lists.linuxfoundation.org>
Subject: Re: [bitcoin-dev] Bech32m BIP: new checksum, and usage for segwit address
Date: Tue, 19 Jan 2021 17:57:08 +0000	[thread overview]
Message-ID: <ER4Y1yqunl3NMmLFDYpDeXsw-MhtS3KBmSTnDQib7yVXas_HGoD7GgOPcQ6v0lSr9BG2ntXoYW4kEKiZ0VdDgecwxJOLMAvuIpUzbCpM6WI=@wuille.net> (raw)
In-Reply-To: <CAHk9a9egxmTQqSLs9PUuH1L8q_c7hp_oo4jT1+BP0ga=aFCPhQ@mail.gmail.com>

On Sunday, January 17, 2021 9:59 PM, nakagat <nakagat@gmail.com> wrote:

> I thought that BECH32M_CONST could be created from hrp and data
> instead of constants.
>
> I thought that the error position would be the same as bech32 by
> recalculating the value created from hrp and data.

So, bech32 can be written as:

* checksum = polymod(expand(hrp) + data) xor 1

Bech32m changes that to:

* checksum = polymod(expand(hrp) + data) xor 0x2bc830a3

I believe that your idea is:

* checksum = polymod(expand(hrp) + data) xor hash(hrp, data)

That has exactly the same error detecting capabilities as:

* checksum = hash(hrp, data)

The hashing makes all types of errors uniform, and it doesn't matter what other things are added to the checksum. Once you hash the data, the checksum is uniformly random, and you can't make it "less random" anymore.

In this case, we *want* non-uniformity. The polymod function as a checksum detects some kinds of errors much better than others, and this is what we want.

Does that clarify things?

Cheers,

--
Pieter




  reply	other threads:[~2021-01-19 17:57 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-05  0:14 [bitcoin-dev] Bech32m BIP: new checksum, and usage for segwit address Pieter Wuille
2021-01-05  1:25 ` Pieter Wuille
2021-01-09  5:00   ` Rusty Russell
2021-01-15  8:01 ` nakagat
2021-01-18  4:15   ` Pieter Wuille
2021-01-18  5:59     ` nakagat
2021-01-19 17:57       ` Pieter Wuille [this message]
     [not found]         ` <CAHk9a9crrQJFUZ5EcBUfz5QCdxHzgTiN1b9_ocfMgf4Qhx98Pw@mail.gmail.com>
2021-01-20  0:29           ` 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='ER4Y1yqunl3NMmLFDYpDeXsw-MhtS3KBmSTnDQib7yVXas_HGoD7GgOPcQ6v0lSr9BG2ntXoYW4kEKiZ0VdDgecwxJOLMAvuIpUzbCpM6WI=@wuille.net' \
    --to=bitcoin-dev@wuille.net \
    --cc=bitcoin-dev@lists.linuxfoundation.org \
    --cc=nakagat@gmail.com \
    /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