export interface IEncoder { bytes: Uint8Array; idEncoder: IdEncoder; } export declare class IdGenerator { bitLength: number; /** * Creates a new IdGenerator instance. * * An IdGenerator generates an array of id bytes. * * @param {object} [options] - The options to use. * @param {number} [options.bitLength=128] - Number of bits to generate. * * @returns {IdGenerator} - New IdGenerator. */ constructor({ bitLength }?: { bitLength?: number; }); /** * Generate random id bytes. * * @returns {Uint8Array} - Array of random id bytes. */ generate(): Promise; } export interface IIdEncoder { encoding?: string; fixedLength?: boolean; fixedBitLength?: number; bitLength?: number; multibase?: boolean; multihash?: boolean; } export declare class IdEncoder { encoder: ({ bytes, idEncoder }: IEncoder) => string; encoding: string; multibasePrefix: string; fixedLength: boolean; fixedBitLength?: number; multibase: boolean; multihash: boolean; /** * Creates a new IdEncoder instance. * * An IdEncoder encodes an array of id bytes into a specific encoding. * * @param {object} [options] - The options to use. * @param {string} [options.encoding='base58'] - Encoding format. * @param {boolean} [options.fixedLength=false] - `true` to ensure fixed * output length. * @param {number} [options.fixedBitLength] - Fixed output bit length or 0 to * base on input byte size. * @param {boolean} [options.multibase=true] - Use multibase encoding. * @param {boolean} [options.multihash=false] - Use multihash encoding. * * @returns {IdEncoder} - New IdEncoder. */ constructor({ encoding, fixedLength, fixedBitLength, multibase, multihash }?: IIdEncoder); /** * Encode id bytes into a string. * * @param {Uint8Array} bytes - Bytes to encode. * * @returns {string} - Encoded string. */ encode(bytes: Uint8Array): string; } export interface IIdDecoder { encoding?: string; fixedBitLength?: number; multibase?: boolean; multihash?: boolean; expectedSize?: number; } export declare class IdDecoder { encoding: string; fixedBitLength?: number; multibase: boolean; multihash: boolean; expectedSize: number; /** * Creates a new IdDecoder instance. * * An IdDecoder decodes an id string into a byte array. It is recommended to * use the fixedBitLength option to avoid padding ids resulting in a larger * than expected byte length. * * @param {object} [options] - The options to use. * @param {string} [options.encoding='base58'] - Encoding format. Ignored if * multibase is true. * @param {number} [options.fixedBitLength] - Fixed output bit length. Values * with leading non-zero data will error. * @param {boolean} [options.multibase=true] - Use multibase encoding to * detect the id format. * @param {boolean} [options.multihash=false] - Use multihash encoding to * detect the id format. * @param {number} [options.expectedSize=32] - Optional expected identifier * size in bytes (only for multihash encoding). Use `0` to disable size * check. * @returns {IdDecoder} - New IdDecoder. */ constructor({ encoding, fixedBitLength, multibase, multihash, expectedSize }?: IIdDecoder); /** * Decode id string into bytes. * * @param {string} id - Id to decode. * * @returns {Uint8Array} - Array of decoded id bytes. */ decode(id: string): Uint8Array; } /** * Generates an encoded id string from random bits. * * @param {object} [options] - The options to use. See `IdEncoder` and * `IdGenerator` for available options. * * @returns {string} - Encoded string id. */ export declare function generateId(options: IIdEncoder): Promise; /** * Decodes an encoded id string to an array of bytes. * * @param {object} options - The options to use. See `IdDecoder` for available * options. * @param {string} options.id - Id to decode. * * @returns {Uint8Array} - Decoded array of id bytes. */ export declare function decodeId(options: IIdDecoder & { id: string; }): Uint8Array; /** * Minimum number of bytes needed to encode an id of a given bit length. * * @param {object} options - The options to use. * @param {string} [options.encoding='base58'] - Encoding format. * @param {number} [options.bitLength=128] - Number of id bits. * @param {boolean} [options.multibase=true] - Account for multibase encoding. * * @returns {number} - The minimum number of encoded bytes. */ export declare function minEncodedIdBytes({ encoding, bitLength, multibase }?: IIdEncoder): number; /** * Maximum number of bytes needed to encode an id of a given bit length. * * @param {object} options - The options to use. * @param {string} [options.encoding='base58'] - Encoding format. * @param {number} [options.bitLength=128] - Number of id bits. * @param {boolean} [options.multibase=true] - Account for multibase encoding. * * @returns {number} - The maximum number of encoded bytes. */ export declare function maxEncodedIdBytes({ encoding, bitLength, multibase }?: IIdEncoder): number; /** * Generates a secret key seed encoded as a string that can be stored and later * used to generate a key pair. The public key from the key pair can be used as * an identifier. The key seed (both raw and encoded form) MUST be kept secret. * * @param {object} [options] - The options to use. * @param {string} [options.encoding='base58'] - Encoding format. * @param {number} [options.bitLength=32 * 8] - Number of bits to generate. * @param {boolean} [options.multibase=true] - Use multibase encoding. * @param {boolean} [options.multihash=true] - Use multihash encoding. * @returns {string} - Secret key seed encoded as a string. */ export declare function generateSecretKeySeed({ bitLength, encoding, multibase, multihash }?: IIdEncoder): Promise; /** * Decodes an encoded secret key seed into an array of secret key seed bytes. * The key seed bytes MUST be kept secret. * * @param {object} options - The options to use. * @param {boolean} [options.multibase=true] - Use multibase encoding to detect * the id format. * @param {boolean} [options.multihash=true] - Use multihash encoding to detect * the id format. * @param {number} [options.expectedSize] - Optional expected identifier size * in bytes (only for multihash encoding). Use `0` to disable size check. * @param {string} options.secretKeySeed - The secret key seed to be decoded. * * @returns {Uint8Array} - An array of secret key seed bytes (default size: * 32 bytes). */ export declare function decodeSecretKeySeed({ multibase, multihash, expectedSize, secretKeySeed }: { multibase?: boolean; multihash?: boolean; expectedSize?: number; secretKeySeed: string; }): Uint8Array; //# sourceMappingURL=index.d.ts.map