UNPKG

curve-p256

Version:

The secp256r1 (p-256) elliptic curve for ECDH & ECDSA

33 lines (32 loc) 1.4 kB
/** * @see https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray */ type TypedArray = Int8Array | Uint8ClampedArray | Uint8Array | Uint16Array | Int16Array | Uint32Array | Int32Array; type RandomBytesCallback = (err: Error | null, buf: Uint8Array) => void; /** * Web Crypto API 中的 Crypto 实例方法 + Node.js 中的 crypto.randomBytes() 方法 * @see https://developer.mozilla.org/docs/Web/API/Crypto */ export interface CryptoMethods { getRandomValues<T extends TypedArray>(array: T): T; randomUUID(): string; /** Node.js 中的 crypto.randomBytes() 方法 */ randomBytes(size: number): Uint8Array; randomBytes(size: number, callback: RandomBytesCallback): Promise<Uint8Array>; } /** * crypto.getRandomValues() 方法实现 * @see https://developer.mozilla.org/docs/Web/API/Crypto/getRandomValues */ export declare function getRandomValues<T extends TypedArray>(array: T): T; /** * Node.js 中的 crypto.randomBytes() 方法实现 * @see https://nodejs.cn/api/crypto.html#crypto_crypto_randombytes_size_callback */ export declare function randomBytes<T extends Uint8Array | Promise<Uint8Array> = Uint8Array>(size: number, callback?: RandomBytesCallback): T; /** * crypto.randomUUID() 方法实现 * @see https://developer.mozilla.org/docs/Web/API/Crypto/randomUUID */ export declare function randomUUID(): string; export {};