version.mx raw

   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  func VersionToConsts() map[Version]ChecksumConst {
  30  	return map[Version]ChecksumConst{
  31  		Version0: Version0Const,
  32  		VersionM: VersionMConst,
  33  	}
  34  }
  35  
  36  func ConstsToVersion() map[ChecksumConst]Version {
  37  	return map[ChecksumConst]Version{
  38  		Version0Const: Version0,
  39  		VersionMConst: VersionM,
  40  	}
  41  }
  42