mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-06 07:47:04 +00:00
fix(node): fix ECDH.converKey()
This commit is contained in:
Vendored
+2
-2
@@ -5836,8 +5836,8 @@ declare module "crypto" {
|
||||
export function getCiphers(): string[];
|
||||
export function getCurves(): string[];
|
||||
export function getHashes(): string[];
|
||||
export interface ECDH {
|
||||
convertKey(key: string | Buffer /*| TypedArray*/ | DataView, curve: string, inputEncoding?: string, outputEncoding?: string, format?: string): Buffer | string;
|
||||
export class ECDH {
|
||||
static convertKey(key: string | Buffer /*| TypedArray*/ | DataView, curve: string, inputEncoding?: "latin1" | "hex" | "base64", outputEncoding?: "latin1" | "hex" | "base64", format?: "uncompressed" | "compressed" | "hybrid"): Buffer | string;
|
||||
generateKeys(): Buffer;
|
||||
generateKeys(encoding: HexBase64Latin1Encoding, format?: ECDHKeyFormat): string;
|
||||
computeSecret(other_public_key: Buffer): Buffer;
|
||||
|
||||
@@ -1151,6 +1151,19 @@ namespace crypto_tests {
|
||||
crypto.randomFill(arr, 2, (err: Error, buf: Uint8Array) => void {});
|
||||
crypto.randomFill(arr, 2, 3, (err: Error, buf: Uint8Array) => void {});
|
||||
}
|
||||
|
||||
{
|
||||
let key: string | Buffer = Buffer.from("buf");
|
||||
let curve = "secp256k1";
|
||||
let ret: string | Buffer = crypto.ECDH.convertKey(key, curve);
|
||||
key = "0xfff";
|
||||
ret = crypto.ECDH.convertKey(key, curve);
|
||||
ret = crypto.ECDH.convertKey(key, curve, "hex");
|
||||
ret = crypto.ECDH.convertKey(key, curve, "hex", "hex");
|
||||
ret = crypto.ECDH.convertKey(key, curve, "hex", "hex", "uncompressed");
|
||||
ret = crypto.ECDH.convertKey(key, curve, "hex", "hex", "compressed");
|
||||
ret = crypto.ECDH.convertKey(key, curve, "hex", "hex", "hybrid");
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////
|
||||
|
||||
Reference in New Issue
Block a user