# README
bech32
Package bech32 provides a Go implementation of the bech32 format specified in BIP 173.
Test vectors from BIP 173 are added to ensure compatibility with the BIP.
Installation and Updating
$ go get -u github.com/bitweb-project/bted/bteutil/bech32
Examples
- Bech32 decode Example Demonstrates how to decode a bech32 encoded string.
- Bech32 encode Example Demonstrates how to encode data into a bech32 string.
License
Package bech32 is licensed under the copyfree ISC License.
# Functions
ConvertBits converts a byte slice where each byte is encoding fromBits bits, to a byte slice where each byte is encoding toBits bits.
Decode decodes a bech32 encoded string, returning the human-readable part and the data part excluding the checksum.
DecodeGeneric is identical to the existing Decode method, but will also return bech32 version that matches the decoded checksum.
DecodeNoLimit decodes a bech32 encoded string, returning the human-readable part and the data part excluding the checksum.
DecodeToBase256 decodes a bech32-encoded string into its associated human-readable part (HRP) and base32-encoded data, converts that data to a base256-encoded byte slice and returns it along with the lowercase HRP.
Encode encodes a byte slice into a bech32 string with the given human-readable part (HRP).
EncodeFromBase256 converts a base256-encoded byte slice into a base32-encoded byte slice and then encodes it into a bech32 string with the given human-readable part (HRP).
EncodeM is the exactly same as the Encode method, but it uses the new bech32m constant instead of the original one.
# Constants
Version0 defines the original bech version.
Version0Const is the original constant used in the checksum verification for bech32.
VersionM is the new bech32 version defined in BIP-350, also known as bech32m.
VersionMConst is the new constant used for bech32m checksum verification.
VersionUnknown denotes an unknown bech version.
# Variables
ConstsToVersion maps a bech32 constant to the version it's associated with.
VersionToConsts maps bech32 versions to the checksum constant to be used when encoding, and asserting a particular version when decoding.
# Structs
ErrInvalidBitGroups is returned when conversion is attempted between byte slices using bit-per-element of unsupported value.
ErrInvalidChecksum is returned when the extracted checksum of the string is different than what was expected.
ErrInvalidIncompleteGroup is returned when then byte slice used as input has data of wrong length.
ErrMixedCase is returned when the bech32 string has both lower and uppercase characters.
# Type aliases
ChecksumConst is a type that represents the currently defined bech32 checksum constants.
ErrInvalidCharacter is returned when the bech32 string has a character outside the range of the supported charset.
ErrInvalidDataByte is returned when a byte outside the range required for conversion into a string was found.
ErrInvalidLength is returned when the bech32 string has an invalid length given the BIP-173 defined restrictions.
ErrInvalidSeparatorIndex is returned when the separator character '1' is in an invalid position in the bech32 string.
ErrNonCharsetChar is returned when a character outside of the specific bech32 charset is used in the string.
Version defines the current set of bech32 versions.