import { Immutable } from '../format/format'; /** * The list of 32 symbols used in Bech32 encoding. */ export declare const bech32CharacterSet = "qpzry9x8gf2tvdw0s3jn54khce6mua7l"; /** * An object mapping each of the 32 symbols used in Bech32 encoding to their respective index in the character set. */ export declare const bech32CharacterSetIndex: { readonly q: 0; readonly p: 1; readonly z: 2; readonly r: 3; readonly y: 4; readonly 9: 5; readonly x: 6; readonly 8: 7; readonly g: 8; readonly f: 9; readonly 2: 10; readonly t: 11; readonly v: 12; readonly d: 13; readonly w: 14; readonly 0: 15; readonly s: 16; readonly 3: 17; readonly j: 18; readonly n: 19; readonly 5: 20; readonly 4: 21; readonly k: 22; readonly h: 23; readonly c: 24; readonly e: 25; readonly 6: 26; readonly m: 27; readonly u: 28; readonly a: 29; readonly 7: 30; readonly l: 31; }; export declare enum BitRegroupingError { integerOutOfRange = "An integer provided in the source array is out of the range of the specified source word length.", hasDisallowedPadding = "Encountered padding when padding was disallowed.", requiresDisallowedPadding = "Encoding requires padding while padding is disallowed." } /** * Given an array of integers, regroup bits from `sourceWordLength` to * `resultWordLength`, returning a new array of integers between 0 and * toWordLength^2. * * Note, if `bin` is within the range of `sourceWordLength` and `padding` is * `true`, this method will never error. * * A.K.A. `convertbits` * * @param bin - an array of numbers representing the bits to regroup. Each item * must be a number within the range of `sourceWordLength` * @param sourceWordLength - the bit-length of each number in `bin`, e.g. to * regroup bits from a `Uint8Array`, use `8` (must be a positive integer) * @param resultWordLength - the bit-length of each number in the desired result * array, e.g. to regroup bits into 4-bit numbers, use `4` (must be a positive * integer) * @param allowPadding - whether to allow the use of padding for `bin` values * where the provided number of bits cannot be directly mapped to an equivalent * result array (remaining bits are filled with `0`), defaults to `true` * @privateRemarks * Derived from: https://github.com/sipa/bech32 */ export declare const regroupBits: ({ bin, sourceWordLength, resultWordLength, allowPadding, }: { bin: Immutable | readonly number[]; sourceWordLength: number; resultWordLength: number; allowPadding?: boolean | undefined; }) => number[] | BitRegroupingError; /** * Encode an array of numbers as a base32 string using the Bech32 character set. * * Note, this method always completes. For a valid result, all items in * `base32IntegerArray` must be between `0` and `32`. * * @param base32IntegerArray - the array of 5-bit integers to encode */ export declare const encodeBech32: (base32IntegerArray: readonly number[]) => string; /** * Decode a Bech32-encoded string into an array of 5-bit integers. * * Note, this method always completes. If `validBech32` is not valid bech32, * an incorrect result will be returned. If `validBech32` is potentially * malformed, check it with `isBech32` before calling this method. * * @param validBech32 - the bech32-encoded string to decode */ export declare const decodeBech32: (validBech32: string) => (0 | 1 | 2 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 16 | 15 | 18 | 12 | 31 | 20 | 11 | 13 | 14 | 17 | 19 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30)[]; /** * Validate that a string uses only characters from the bech32 character set. * * @param maybeBech32 - a string to test for valid Bech32 encoding */ export declare const isBech32CharacterSet: (maybeBech32: string) => boolean; export declare enum Bech32DecodingError { notBech32CharacterSet = "Bech32 decoding error: input contains characters outside of the Bech32 character set." } /** * Convert a padded bech32-encoded string (without checksum) to a Uint8Array, * removing the padding. If the string is not valid Bech32, or if the array of * 5-bit integers would require padding to be regrouped into 8-bit bytes, this * method returns an error message. * * This method is the reverse of `binToBech32Padded`. * * @param bech32Padded - the padded bech32-encoded string to decode */ export declare const bech32PaddedToBin: (bech32Padded: string) => Uint8Array | BitRegroupingError | Bech32DecodingError.notBech32CharacterSet; /** * Convert a Uint8Array to a padded bech32-encoded string (without a checksum), * adding padding bits as necessary to convert all bytes to 5-bit integers. * * This method is the reverse of `bech32PaddedToBin`. * * @param bytes - the Uint8Array to bech32 encode */ export declare const binToBech32Padded: (bytes: Immutable) => string; //# sourceMappingURL=bech32.d.ts.map