utils library

This module exports a selection of commonly used encryption algorithms and tools.

Classes

AccountGenerator
Generator special address such as: 0x0000************************, Support address type: evm Return SpecialAccount
AddressUtils
Provides series of address validation methods, integrated within checkAddressValid.
Base32
Class for encode and decode base32.
Bech32
Bech32 is a dead simple wrapper around a Human Readable Part (HRP) and a bunch of bytes.
Bech32Codec
Class for decode and encode bech32.
Bech32Decoder
This class converts a String to a Bech32 class instance.
Bech32Encoder
Bech32Validations
Generic validations for Bech32 standard.
Blake2b
Class for getting blake2b hex.
EcdaSignature
Provide EcdaSignature sign and verify.
ED25519
Provide ED25519 sign and verify.
HDLedger
HDWallet
Provide various methods to generate a hd wallet. Include bip32, bip39, ED25519_HD_KEY.
NumberUtil
Handle number methods.
Schnorr
Provide Schnorr sign and verify.
SpecialAccount
Include mnemonic and address
SR25519
Provide SR25519 sign and verify.

Enums

AddressType
Supported address types in this repository.
Base32Type
Enum of base32 encoding type.

Constants

bech32 → const Bech32Codec
An instance of the default implementation of the Bech32Codec.
charset → const List<String>
generator → const List<int>
separator → const String

Properties

secp256k1 → ECDomainParameters
final

Functions

asciiStringToByteArray(String text) List<int>
bnToU8a(BigInt number) Uint8List
bufferToInt(Uint8List buf) int
Converts a Uint8List to a int.
checkBase58(String address, {int length = 25}) bool
Check base58 address with checksum, such as btc.
checkBech32(String address, {String prefix = ''}) bool
Check bech32 address with prefix, such as ckb.
checkRFC4648Base32(String address, String prefix) bool
checkStandardBase32(String address) bool
Check base32 address, such as bitcoincash.
complete0xHex(String hex) String
Function for add 0x prefix.
convertBit(Uint8List buff) Uint8List
convertBits(dynamic data, int from, int to, {bool strictMode = false}) List<int>
createChecksum(String hrp, List<int> data, {String encoding = 'bech32'}) List<int>
decodeBigInt(List<int> bytes, {Endian endian = Endian.little}) BigInt
Function for decode Uint8List to BigInt.
dynamicToHex(dynamic value) String
String, List, Uint8List to 0x
dynamicToString(dynamic value) String
String, List, Uint8List to String
dynamicToUint8List(dynamic value) Uint8List
String, List, Uint8List to Uint8List
encodeBigInt(BigInt number, {Endian endian = Endian.little, int? bitLength}) Uint8List
Function for encode BigInt to Uint8List.
encodeBigIntBe(BigInt input, {int length = 0}) Uint8List
encodeInt(int number, int length) Uint8List
Function for encode int.
fromSigned(Uint8List signedInt) BigInt
Interprets a Uint8List as a signed integer and returns a BigInt. Assumes 256-bit numbers.
generateRandomString() String
Function for retrieve a random hexadecimal string.
getAddressType(dynamic network) AddressType
A method to get AddressType by network name(String).
getKeccakDigest(Uint8List hash, [int length = 256]) Uint8List
getRIPEMD160Digest(Uint8List hash) Uint8List
getSha244Digest(Uint8List hash) Uint8List
getSHA256Digest(Uint8List hash) Uint8List
getSHA3Digest(Uint8List hash, [int length = 256]) Uint8List
getTypeName(AddressType network) String
AddressType enum to String
hexToBigInt(String hex) BigInt
Function for convert a hex String to BigInt.
hexToBn(dynamic value, {Endian endian = Endian.big, bool isNegative = false}) BigInt
Function for convert a hex String to BigInt.
hexToBytes(String hexStr) List<int>
Function for hex String to List
intToBytes(BigInt i) Uint8List
isHexPrefixed(String str) bool
isHexString(String value, {int length = 0}) bool
Is the string a hex string.
phraseToInt(String phrase) BigInt
setLength(Uint8List msg, int length, {bool right = false}) Uint8List
setLengthLeft(Uint8List msg, int length, {bool right = false}) Uint8List
Left Pads an Uint8List with leading zeros till it has length bytes. Or it truncates the beginning if it exceeds.
setLengthRight(Uint8List msg, int length) Uint8List
Right Pads an Uint8List with leading zeros till it has length bytes. Or it truncates the beginning if it exceeds.
strip0xHex(String hex) String
Function for delete 0x prefix.
toBytesPadded(BigInt value, int length) List<int>
toEthChecksumAddress(String address) String
Check eth address with checksum.
toUint5Array(dynamic data) List<int>
toUnsigned(BigInt unsignedInt) Uint8List
Converts a BigInt to an unsigned integer and returns it as a Uint8List. Assumes 256-bit numbers.
toWholeHex(String hexString) String
Function for get whole hex.
u8aToBn(Uint8List u8a, {Endian endian = Endian.little, bool isNegative = false}) BigInt
Function for convert a Uint8List to BigInt.
verifyChecksum(String hrp, List<int> dataIncludingChecksum, {String encoding = 'bech32'}) bool
zeros(int bytes) Uint8List
Returns a buffer filled with 0s.