[bitcoin-dev] Bech32m BIP: new checksum, and usage for segwit address

Pieter Wuille bitcoin-dev at wuille.net
Tue Jan 19 17:57:08 UTC 2021


On Sunday, January 17, 2021 9:59 PM, nakagat <nakagat at 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




More information about the bitcoin-dev mailing list