import type libsodium from 'libsodium-wrappers'; import type { KeyAlgorithm, Msg, JSONValue, LockKey, DID } from './types.js'; import { CharSize } from './types.js'; export declare const normalizeToBuf: (msg: Msg, strConv: (str: string) => ArrayBuffer) => ArrayBuffer; /** * Export the public key from the given keypair as a Uint8Array. * @param {CryptoKeyPair} keys The keypair to export. * @returns {Promise} The public key as Uint8Array. */ export declare function exportKey(keys: CryptoKeyPair): Promise; export declare function normalizeBase64ToBuf(msg: Msg): ArrayBuffer; export declare const normalizeUtf8ToBuf: (msg: Msg) => ArrayBuffer; export declare const normalizeUtf16ToBuf: (msg: Msg) => ArrayBuffer; export declare function normalizeUnicodeToBuf(msg: Msg, charSize?: CharSize): ArrayBuffer; export declare function strToArrBuf(str: string, charSize?: CharSize): ArrayBuffer; export declare function generateEntropy(sodium: typeof libsodium, size?: number): Uint8Array; export declare function randomBuf(length: number, { max }?: { max: number; }): Uint8Array; export declare function joinBufs(fst: ArrayBuffer | Uint8Array, snd: ArrayBuffer | Uint8Array): Uint8Array; export declare function arrBufToBase64(buf: ArrayBuffer): string; /** * Convert Uint8Arrays to `base64pad` encoded strings. * * @param {Uint8Array} arr Input `Uint8Array` * @returns {string} `base64pad` encoded string */ export declare function toString(arr: Uint8Array): string; /** * Convert a given string to an `ArrayBuffer`. * * @param {string} str input string * @returns {ArrayBuffer} Array buffer */ export declare function base64ToArrBuf(str: string): ArrayBuffer; export declare function sha256(bytes: string | Uint8Array, opts?: { output: 'string'; }): Promise; export declare function sha256(bytes: string | Uint8Array, opts: { output: 'bytes'; }): Promise; export declare function isCryptoKeyPair(val: unknown): val is CryptoKeyPair; export declare function isCryptoKey(val: unknown): val is CryptoKey; export declare function hasProp(data: unknown, prop: K): data is Record; export declare function arrBufToStr(buf: ArrayBuffer, charSize?: CharSize): string; export declare function publicExponent(): Uint8Array; /** * Create a `Uint8Array` from a given `base64pad` encoded string. * * @param str `base64pad` encoded string * @returns {Uint8Array} */ export declare function fromString(str: string): Uint8Array; /** * Parse magic bytes on prefixed key-buffer to determine the * cryptosystem & the unprefixed key-buffer. */ export declare function parseMagicBytes(prefixedKey: ArrayBuffer): { keyBuffer: ArrayBuffer; type: "rsa"; } | { keyBuffer: ArrayBuffer; type: "ed25519"; } | { keyBuffer: ArrayBuffer; type: "bls12-381"; }; export declare function arrayBuffersEqual(aBuf: ArrayBuffer, bBuf: ArrayBuffer): boolean; export declare function buffersEqual(a: Uint8Array, b: Uint8Array): boolean; export declare function asBufferOrString(data: Uint8Array | ArrayBuffer | string | JSONValue): Uint8Array | string; export declare function isByteArray(val: unknown): boolean; export declare function stringify(keys: LockKey): string; export declare const magicBytes: Record; export declare const publicKeyToDid: { ecc: (publicKey: Uint8Array) => DID; rsa: (publicKey: Uint8Array) => DID; }; export declare function didToPublicKey(did: DID): ({ publicKey: Uint8Array; type: 'rsa' | 'ed25519' | 'bls12-381'; }); //# sourceMappingURL=util.d.ts.map