mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 10:56:53 +00:00
Add types for diffie-hellman
This commit is contained in:
parent
2bc9203ec0
commit
0197262395
48
types/diffie-hellman/diffie-hellman-tests.ts
Normal file
48
types/diffie-hellman/diffie-hellman-tests.ts
Normal file
@ -0,0 +1,48 @@
|
||||
import * as dh from 'diffie-hellman';
|
||||
|
||||
const dh1 = dh.getDiffieHellman('modp1');
|
||||
// $ExpectType DiffieHellman
|
||||
dh1;
|
||||
// $ExpectType Buffer
|
||||
dh1.generateKeys();
|
||||
// $ExpectType string
|
||||
dh1.generateKeys('hex');
|
||||
// $ExpectType Buffer
|
||||
dh1.getPrime();
|
||||
// $ExpectType string
|
||||
dh1.getPrime('hex');
|
||||
// $ExpectType Buffer
|
||||
dh1.getGenerator();
|
||||
// $ExpectType string
|
||||
dh1.getGenerator('hex');
|
||||
const pk = dh1.getPublicKey();
|
||||
// $ExpectType Buffer
|
||||
pk;
|
||||
// $ExpectType string
|
||||
dh1.getPublicKey('hex');
|
||||
// $ExpectType Buffer
|
||||
dh1.getPrivateKey();
|
||||
// $ExpectType string
|
||||
dh1.getPrivateKey('hex');
|
||||
// $ExpectType Buffer
|
||||
dh1.computeSecret(pk);
|
||||
// $ExpectType Buffer
|
||||
dh1.computeSecret(pk.toString('hex'), 'hex');
|
||||
// $ExpectType string
|
||||
dh1.computeSecret(pk.toString('hex'), 'hex', 'hex');
|
||||
|
||||
const dh2 = dh.createDiffieHellman(new Buffer([5]));
|
||||
// $ExpectType DiffieHellman
|
||||
dh2;
|
||||
dh.createDiffieHellman('prime', 'hex');
|
||||
dh.createDiffieHellman('prime', 'hex', new Buffer([5]));
|
||||
dh.createDiffieHellman('prime', 'hex', 5);
|
||||
dh.createDiffieHellman('prime', 'hex', 'generator', 'hex');
|
||||
dh.createDiffieHellman(1);
|
||||
dh.createDiffieHellman(1, 1);
|
||||
dh.createDiffieHellman(1, new Buffer([5]));
|
||||
|
||||
dh2.setPublicKey(pk);
|
||||
dh2.setPublicKey(pk.toString('hex'), 'hex');
|
||||
dh2.setPrivateKey(pk);
|
||||
dh2.setPrivateKey(pk.toString('hex'), 'hex');
|
||||
8
types/diffie-hellman/index.d.ts
vendored
Normal file
8
types/diffie-hellman/index.d.ts
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
// Type definitions for diffie-hellman 5.0
|
||||
// Project: https://github.com/crypto-browserify/diffie-hellman
|
||||
// Definitions by: BendingBender <https://github.com/BendingBender>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference types="node" />
|
||||
|
||||
export { createDiffieHellman, getDiffieHellman, DiffieHellman } from 'crypto';
|
||||
23
types/diffie-hellman/tsconfig.json
Normal file
23
types/diffie-hellman/tsconfig.json
Normal file
@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"diffie-hellman-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/diffie-hellman/tslint.json
Normal file
1
types/diffie-hellman/tslint.json
Normal file
@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Loading…
Reference in New Issue
Block a user