1 package bech32
2 3 // ChecksumConst is a type that represents the currently defined bech32
4 // checksum constants.
5 type ChecksumConst int
6 7 const (
8 // Version0Const is the original constant used in the checksum
9 // verification for bech32.
10 Version0Const ChecksumConst = 1
11 // VersionMConst is the new constant used for bech32m checksum
12 // verification.
13 VersionMConst ChecksumConst = 0x2bc830a3
14 )
15 16 // Version defines the current set of bech32 versions.
17 type Version uint8
18 19 const (
20 // Version0 defines the original bech version.
21 Version0 Version = iota
22 // VersionM is the new bech32 version defined in BIP-350, also known as
23 // bech32m.
24 VersionM
25 // VersionUnknown denotes an unknown bech version.
26 VersionUnknown
27 )
28 29 // VersionToConsts maps bech32 versions to the checksum constant to be used
30 // when encoding, and asserting a particular version when decoding.
31 var VersionToConsts = map[Version]ChecksumConst{
32 Version0: Version0Const,
33 VersionM: VersionMConst,
34 }
35 36 // ConstsToVersion maps a bech32 constant to the version it's associated with.
37 var ConstsToVersion = map[ChecksumConst]Version{
38 Version0Const: Version0,
39 VersionMConst: VersionM,
40 }
41