Documentation ¶
Overview ¶
ref; https://github.com/cosmos/btcutil/blob/master/bech32/bech32.go
Copyright (c) 2019 The Decred developers Use of this source code is governed by an ISC license that can be found in the LICENSE file. https://github.com/cosmos/btcutil/blob/master/bech32/error.go
Index ¶
- Constants
- func ConvertAndEncode(hrp string, data []byte) (string, error)
- func ConvertBits(data []byte, fromBits, toBits uint8, pad bool) ([]byte, error)
- func Decode(bech string, limit int) (string, []byte, error)
- func DecodeAndConvert(bech string) (string, []byte, error)
- func DecodeExtendCommitInfo(bz []byte) (cometabci.ExtendedCommitInfo, error)
- func DecodeNoLimit(bech string) (string, []byte, error)
- func DecodePrices(decodedBz []byte) (int, error)
- func DecodeToBase256(bech string) (string, []byte, error)
- func DecodeUnsafe(bech string) (string, []byte, []byte, error)
- func DecodingVoteExtensionTx(veTx string) ([]types.VoteExtension, error)
- func Encode(hrp string, data []byte) (string, error)
- func EncodeFromBase256(hrp string, data []byte) (string, error)
- func ExportBech32ValconsPrefix(bech32ValoperPrefix string) (string, error)
- func IsProposerAddress(str string) bool
- func MakeBLSPubkey(cometbftPubKey string) (string, error)
- func MakeProposerAddress(keyType string, decodedPubkey []byte) (string, error)
- func MakeValconsAddressFromPubeky(pubkey string, hrp string) (string, error)
- func MustDecompress(bz []byte) ([]byte, error)
- func Normalize(bech *string) (bool, error)
- func ProposerAddressFromPublicKey(pubKey string) (string, error)
- func VerifyChecksum(hrp string, values []byte, checksum []byte) bool
- type ErrInvalidBitGroups
- type ErrInvalidCharacter
- type ErrInvalidChecksum
- type ErrInvalidDataByte
- type ErrInvalidIncompleteGroup
- type ErrInvalidLength
- type ErrInvalidSeparatorIndex
- type ErrMixedCase
- type ErrNonCharsetChar
Constants ¶
const Bn254 = "/cosmos.crypto.bn254.PubKey"
const Ed25519 = "/cosmos.crypto.ed25519.PubKey"
const MaxLengthBIP173 = 90
MaxLengthBIP173 is the maximum length of bech32-encoded address defined by BIP-173.
const Secp256k1 = "/cosmos.crypto.secp256k1.PubKey"
const TendermintSecp256k1 = "tendermint/PubKeySecp256k1"
const VECommitFlag = tmtypes.BlockIDFlagCommit
Variables ¶
This section is empty.
Functions ¶
func ConvertAndEncode ¶
ConvertAndEncode converts from a base64 encoded byte string to base32 encoded byte string and then to bech32.
func ConvertBits ¶
ConvertBits converts a byte slice where each byte is encoding fromBits bits, to a byte slice where each byte is encoding toBits bits.
func Decode ¶
Decode decodes a bech32 encoded string, returning the human-readable part and the data part excluding the checksum.
Note that the returned data is 5-bit (base32) encoded and the human-readable part will be lowercase.
func DecodeAndConvert ¶
DecodeAndConvert decodes a bech32 encoded string and converts to base64 encoded bytes.
func DecodeExtendCommitInfo ¶
func DecodeExtendCommitInfo(bz []byte) (cometabci.ExtendedCommitInfo, error)
ref; https://github.com/skip-mev/connect/blob/main/abci/strategies/codec/codec.go
func DecodeNoLimit ¶
DecodeNoLimit decodes a bech32 encoded string, returning the human-readable part and the data part excluding the checksum. This function does NOT validate against the BIP-173 maximum length allowed for bech32 strings and is meant for use in custom applications (such as lightning network payment requests), NOT on-chain addresses.
Note that the returned data is 5-bit (base32) encoded and the human-readable part will be lowercase.
func DecodePrices ¶
for this feature, we should add dependency about connect; vetypes "github.com/skip-mev/slinky/abci/ve/types" NOTE: UNUSED FUNCTION
func DecodeToBase256 ¶
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.
func DecodeUnsafe ¶
DecodeUnsafe decodes a bech32 encoded string, returning the human-readable part, the data part (excluding the checksum) and the checksum. This function does NOT validate against the BIP-173 maximum length allowed for bech32 strings and is meant for use in custom applications (such as lightning network payment requests), NOT on-chain addresses. This function assumes the given string includes lowercase letters only, so if not, you should call Normalize first.
Note that the returned data is 5-bit (base32) encoded and the human-readable part will be lowercase.
func DecodingVoteExtensionTx ¶
func DecodingVoteExtensionTx(veTx string) ([]types.VoteExtension, error)
func Encode ¶
Encode encodes a byte slice into a bech32 string with the given human-readable part (HRP). The HRP will be converted to lowercase if needed since mixed cased encodings are not permitted and lowercase is used for checksum purposes. Note that the bytes must each encode 5 bits (base32).
func EncodeFromBase256 ¶
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). The HRP will be converted to lowercase if needed since mixed cased encodings are not permitted and lowercase is used for checksum purposes.
func ExportBech32ValconsPrefix ¶
NOTE: this is not cosmos-sdk native. so, I placed this function into uptime package parse valcons prefix with valoper address
func IsProposerAddress ¶
func MakeBLSPubkey ¶
func MakeProposerAddress ¶
func MakeValconsAddressFromPubeky ¶
NOTE: only support ed25519 key type for ICS
func MustDecompress ¶
func Normalize ¶
Normalize converts the uppercase letters to lowercase in string, because Bech32 standard uses only the lowercase for of string for checksum calculation. If conversion occurs during function call, `true` will be returned.
Mixed case is NOT allowed.
func VerifyChecksum ¶
VerifyChecksum verifies whether the bech32 string specified by the provided hrp and payload data (encoded as 5 bits per element byte slice) are validated by the given checksum.
For more details on the checksum verification, please refer to BIP 173.
Types ¶
type ErrInvalidBitGroups ¶
type ErrInvalidBitGroups struct{}
ErrInvalidBitGroups is returned when conversion is attempted between byte slices using bit-per-element of unsupported value.
func (ErrInvalidBitGroups) Error ¶
func (e ErrInvalidBitGroups) Error() string
type ErrInvalidCharacter ¶
type ErrInvalidCharacter rune
ErrInvalidCharacter is returned when the bech32 string has a character outside the range of the supported charset.
func (ErrInvalidCharacter) Error ¶
func (e ErrInvalidCharacter) Error() string
type ErrInvalidChecksum ¶
ErrInvalidChecksum is returned when the extracted checksum of the string is different than what was expected.
func (ErrInvalidChecksum) Error ¶
func (e ErrInvalidChecksum) Error() string
type ErrInvalidDataByte ¶
type ErrInvalidDataByte byte
ErrInvalidDataByte is returned when a byte outside the range required for conversion into a string was found.
func (ErrInvalidDataByte) Error ¶
func (e ErrInvalidDataByte) Error() string
type ErrInvalidIncompleteGroup ¶
type ErrInvalidIncompleteGroup struct{}
ErrInvalidIncompleteGroup is returned when then byte slice used as input has data of wrong length.
func (ErrInvalidIncompleteGroup) Error ¶
func (e ErrInvalidIncompleteGroup) Error() string
type ErrInvalidLength ¶
type ErrInvalidLength int
ErrInvalidLength is returned when the bech32 string has an invalid length given the BIP-173 defined restrictions.
func (ErrInvalidLength) Error ¶
func (e ErrInvalidLength) Error() string
type ErrInvalidSeparatorIndex ¶
type ErrInvalidSeparatorIndex int
ErrInvalidSeparatorIndex is returned when the separator character '1' is in an invalid position in the bech32 string.
func (ErrInvalidSeparatorIndex) Error ¶
func (e ErrInvalidSeparatorIndex) Error() string
type ErrMixedCase ¶
type ErrMixedCase struct{}
ErrMixedCase is returned when the bech32 string has both lower and uppercase characters.
func (ErrMixedCase) Error ¶
func (e ErrMixedCase) Error() string
type ErrNonCharsetChar ¶
type ErrNonCharsetChar rune
ErrNonCharsetChar is returned when a character outside of the specific bech32 charset is used in the string.
func (ErrNonCharsetChar) Error ¶
func (e ErrNonCharsetChar) Error() string