wiki

Abstract

BIP 173 proposed a checksummed base32 format, Bech32 and a standard for native segregated witness output addresses using it to replace BIP 142. This format is not required for using segwit, but is more efficient, flexible and nicer to use.

Bech32

A Bech32 string is at most 90 characters long and consists of:

  • The human-readable part(hrp), which is intended to convey the type of data, or anything else that is relevant to the reader.

  • The separator which is always “1”. In case “1” is allowed inside the hrp, the last one in the string is the separator.

  • The data part, which is at least 6 characters long and only consists of alphanumeric characters excluding “1”, “b”, “i”, “o”.

Checksum

The last six characters of the data part form a chechsum and contain no information.

Segwit address format

A segwit address is a Bech32 encoding of:

  • The human-readable part “bc” for mainnet and the “tb” for testnet.

  • The data-part values:

    • 1 byte: the witness version

    • A convention of the 2-to-40-byte witness program to base32:

      • Start with the bits of the witness program, most significant bit per btye first.

      • Re-arrange those bits into groups of 5, and pad with zeros at the end if needed.

      • Translate those bits to characters.