1
1
I try to understand the code from the BIP173. I read the BIP, the links to RFC3548 or z-base-32, the base32 proposal by Mark Friedenbach, and some posts here.
Q1: how to interprete script handling?
I thought to understand, that bech32 is a representation of an address (encoding a hash of a public key), and has nothing to do with scripting. I got confused, in the example section it says:
All examples use public key 0279BE66... The P2WSH examples use
<key OP_CHECKSIG>as script.
In a std tx I would have the sigscript with the signature and e.g. a pubkey. So for the spending tx, it is checked, that the pubkey matches to the signature. Is the same true for a bech32 address (besides being in the witness section)? Is there an example with a multisig tx with only bech32 addresses?
Q2: what is the "GEN = [0x3b6a57b2 ..." line?
In the Specification/Checksum section it says:
def bech32_polymod(values):
GEN = [0x3b6a57b2, 0x26508e6d, 0x1ea119fa, 0x3d4233dd, 0x2a1462b3]
...
I am wondering, what these values do, where do they come from? I also looked into the C code, but there is no further explanation. Where can I find it's meaning?
1
The choice of values is much better described in the bitcoin implementation of bech32 here, worth reading:https://github.com/bitcoin/bitcoin/blob/master/src/bech32.cpp
– MeshCollider – 2018-02-21T18:16:29.117I'm answering the first question below. I think the second question is unrelated, and should probably move to a separate thread. – Pieter Wuille – 2018-02-21T20:15:00.820
thx, 2nd question is currently answered with your (?) comments in the cpp file, linked by MeshCollider. If required, I'll raise another one. Now reading through the below :-) – pebwindkraft – 2018-02-21T21:10:20.510