Documentation
¶
Index ¶
- func ByteSquasher(input []byte, inputWidth, outputWidth uint32) ([]byte, error)
- func Bytes5to8(input []byte) ([]byte, error)
- func Bytes8to5(input []byte) []byte
- func CreateChecksum(hrp string, data []byte) []byte
- func Decode(adr string) (string, []byte, error)
- func DecodeSquashed(adr string) (string, []byte, error)
- func Encode(hrp string, data []byte) string
- func EncodeSquashed(hrp string, data []byte) string
- func HRPExpand(input string) []byte
- func PolyMod(values []byte) uint32
- func SquashedBytesToString(input []byte) (string, error)
- func StringToSquashedBytes(input string) ([]byte, error)
- func VerifyChecksum(hrp string, data []byte) bool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ByteSquasher ¶
ByteSquasher squashes full-width (8-bit) bytes into "squashed" 5-bit bytes, and vice versa. It can operate on other widths but in this package only goes 5 to 8 and back again. It can return an error if the squashed input you give it isn't actually squashed, or if there is padding (trailing q characters) when going from 5 to 8
func Bytes8to5 ¶
Bytes8to5 extends a byte slice into a longer, padded byte slice of 5-bit elements where the high 3 bits are all 0.
func CreateChecksum ¶
create checksum makes a 6-shortbyte checksum from the HRP and data parts
func Decode ¶
Decode takes a bech32 encoded string and returns the hrp and the full-height data. Can error out for various reasons, mostly problems in the string given.
func DecodeSquashed ¶
DecodeSquashed is the same as Decode, but will return squashed 5-bit high data.
func Encode ¶
Encode takes regular bytes of data, and an hrp prefix, and returns the bech32 encoded string.
func EncodeSquashed ¶
EncodeSquashed takes the hrp prefix, as well as byte data that has already been squashed to 5-bits high, and returns the bech32 encoded string. It does not return an error; if you give it non-squashed data it will return an empty string.
func PolyMod ¶
PolyMod takes a byte slice and returns the 32-bit BCH checksum. Note that the input bytes to PolyMod need to be squashed to 5-bits tall before being used in this function. And this function will not error, but instead return an unusable checksum, if you give it full-height bytes.
func SquashedBytesToString ¶
SquashedBytesToString swaps 5-bit bytes with a string of the corresponding letters
func StringToSquashedBytes ¶
StringToSquashedBytes uses the inverseCharset to switch from the characters back to 5-bit squashed bytes.
func VerifyChecksum ¶
Types ¶
This section is empty.