import type { DID, Msg, HashAlg, SymmKeyOpts, SymmKey } from './types.js'; import { KeyUse, CharSize } from './types.js'; /** * Using the key type as the record property name (ie. string = key type) * * The magic bytes are the `code` found in {@link https://github.com/multiformats/multicodec/blob/master/table.csv} * encoded as a variable integer (more info about that at {@link https://github.com/multiformats/unsigned-varint)}. * * The key type is also found in that table. * It's the name of the codec minus the `-pub` suffix. * * Example * ------- * Ed25519 public key * Key type: "ed25519" * Magic bytes: [ 0xed, 0x01 ] */ type KeyTypes = Record Promise; }>; export declare const did: { keyTypes: KeyTypes; }; /** * Create a 32 character, DNS-friendly hash of the given DID. * * @param {DID} did String representation of the DID for the device * @returns {string} The 32 character, DNS friendly hash */ export declare function createDeviceName(did: DID): Promise; export declare function sha256(bytes: Uint8Array): Promise; /** * Convert a public key to a DID format string. * * @param {Uint8Array|CryptoKey|CryptoKeyPair} publicKey Public key as Uint8Array * @param {'rsa'} [keyType] 'rsa' only * @returns {DID} A DID format string */ export declare function publicKeyToDid(_publicKey: Uint8Array | CryptoKey, keyType?: string): Promise; export declare const rsaOperations: { verify: (msg: Msg, sig: Msg, publicKey: string | CryptoKey, charSize?: CharSize, hashAlg?: HashAlg) => Promise; sign: (msg: Msg, privateKey: CryptoKey, charSize?: CharSize) => Promise; /** * Encrypt the given AES key *to* a given public key. */ encrypt: (msg: Msg, publicKey: string | CryptoKey | Uint8Array, charSize?: CharSize, hashAlg?: HashAlg) => Promise; /** * Use RSA to decrypt the given data. */ decrypt: (_data: Uint8Array | string | ArrayBuffer, privateKey: CryptoKey | Uint8Array | ArrayBuffer) => Promise; }; export declare function rsaVerify({ message, publicKey, signature }: { message: Uint8Array; publicKey: Uint8Array; signature: Uint8Array; }): Promise; export declare function importPublicKey(base64Key: string | ArrayBuffer, hashAlg: HashAlg, use: KeyUse): Promise; export declare const InvalidKeyUse: Error; export declare const InvalidMaxValue: Error; export declare function checkValidKeyUse(use: KeyUse): void; export declare function base64ToArrBuf(string: string): ArrayBuffer; export declare const normalizeToBuf: (msg: Msg, strConv: (str: string) => ArrayBuffer) => ArrayBuffer; export declare function normalizeBase64ToBuf(msg: Msg): ArrayBuffer; export declare const normalizeUtf8ToBuf: (msg: Msg) => ArrayBuffer; export declare function strToArrBuf(str: string, charSize: CharSize): ArrayBuffer; export declare const normalizeUtf16ToBuf: (msg: Msg) => ArrayBuffer; export declare function normalizeUnicodeToBuf(msg: Msg, charSize: CharSize): ArrayBuffer; export declare function importRsaKey(key: Uint8Array | ArrayBuffer, keyUsages: KeyUsage[]): Promise; export declare function isCryptoKey(val: unknown): val is CryptoKey; export declare function getPublicKeyAsArrayBuffer(keypair: CryptoKeyPair | CryptoKey): Promise; export declare function getPublicKeyAsUint8Array(keypair: CryptoKeyPair | CryptoKey): Promise; export declare function didToPublicKey(did: string): ({ publicKey: Uint8Array; type: 'rsa' | 'ed25519' | 'bls12-381'; }); export declare function toBase64(arr: Uint8Array | ArrayBuffer): string; export declare function fromBase64(str: string): Uint8Array; export declare function importKey(key: string | Uint8Array, opts?: Partial): Promise; export declare function randomBuf(length: number, { max }?: { max: number; }): ArrayBuffer; export declare function joinBufs(fst: ArrayBuffer, snd: ArrayBuffer): ArrayBuffer; export {}; //# sourceMappingURL=util.d.ts.map