I'm trying 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 interpret 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?