UNPKG

react-native-quick-crypto

Version:

A fast implementation of Node's `crypto` module written in C/C++ JSI

47 lines 2.69 kB
import { Buffer } from '@craftzdog/react-native-buffer'; import { CryptoKey } from './keys'; import type { EdKeyPair } from './specs/edKeyPair.nitro'; import type { BinaryLike, CFRGKeyPairType, CryptoKeyPair, DiffieHellmanCallback, DiffieHellmanOptions, GenerateKeyPairCallback, GenerateKeyPairReturn, Hex, KeyPairGenConfig, KeyUsage, SubtleAlgorithm } from './utils'; export declare class Ed { type: CFRGKeyPairType; config: KeyPairGenConfig; native: EdKeyPair; constructor(type: CFRGKeyPairType, config: KeyPairGenConfig); /** * Computes the Diffie-Hellman secret based on a privateKey and a publicKey. * Both keys must have the same asymmetricKeyType, which must be one of 'dh' * (for Diffie-Hellman), 'ec', 'x448', or 'x25519' (for ECDH). * * @api nodejs/node * * @param options `{ privateKey, publicKey }`, both of which are `KeyObject`s * @param callback optional `(err, secret) => void` * @returns `Buffer` if no callback, or `void` if callback is provided */ diffieHellman(options: DiffieHellmanOptions, callback?: DiffieHellmanCallback): Buffer | void; generateKeyPair(): Promise<void>; generateKeyPairSync(): void; getPublicKey(): ArrayBuffer; getPrivateKey(): ArrayBuffer; /** * Computes the Diffie-Hellman shared secret based on a privateKey and a * publicKey for key exchange * * @api \@paulmillr/noble-curves/ed25519 * * @param privateKey * @param publicKey * @returns shared secret key */ getSharedSecret(privateKey: Hex, publicKey: Hex): ArrayBuffer; sign(message: BinaryLike, key?: BinaryLike): Promise<ArrayBuffer>; signSync(message: BinaryLike, key?: BinaryLike): ArrayBuffer; verify(signature: BinaryLike, message: BinaryLike, key?: BinaryLike): Promise<boolean>; verifySync(signature: BinaryLike, message: BinaryLike, key?: BinaryLike): boolean; } export declare function diffieHellman(options: DiffieHellmanOptions, callback?: DiffieHellmanCallback): Buffer | void; export declare function ed_generateKeyPair(isAsync: boolean, type: CFRGKeyPairType, encoding: KeyPairGenConfig, callback: GenerateKeyPairCallback | undefined): GenerateKeyPairReturn | void; export declare function ed_generateKeyPairWebCrypto(type: 'ed25519' | 'ed448', extractable: boolean, keyUsages: KeyUsage[]): Promise<CryptoKeyPair>; export declare function x_generateKeyPairWebCrypto(type: 'x25519' | 'x448', extractable: boolean, keyUsages: KeyUsage[]): Promise<CryptoKeyPair>; export declare function xDeriveBits(algorithm: SubtleAlgorithm, baseKey: CryptoKey, length: number | null): ArrayBuffer; //# sourceMappingURL=ed.d.ts.map