Add keccak

This commit is contained in:
Jaco Greeff 2018-06-21 11:31:52 +02:00
parent 26cc286262
commit dd1ba18e71
5 changed files with 45 additions and 0 deletions

View File

@ -10,3 +10,4 @@ This following libraries are currently included. Where possible add the relevant
- [blakejs](https://github.com/dcposch/blakejs)
- [bn.js](https://github.com/indutny/bn.js/) [@types PR #26717](https://github.com/DefinitelyTyped/DefinitelyTyped/pull/26717)
- [keccak](https://github.com/cryptocoinjs/keccak)

20
keccak/index.d.ts vendored Normal file
View File

@ -0,0 +1,20 @@
// Type definitions for keccak 1.4.0
// Project: https://github.com/cryptocoinjs/keccak
// Definitions by: Jaco Greeff <https://github.com/jacogr>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="node"/>
interface KeccakHasher {
digest(): Buffer;
update(message: string | Buffer): KeccakHasher;
_resetState(): void,
_clone(): KeccakHasher
}
type KeccakTypes = 'keccak224' | 'keccak256' | 'keccak384' | 'keccak512' | 'sha3-224' | 'sha3-256' | 'sha3-384' | 'sha3-512' | 'shake128' | 'shake256';
type keccak = (type: KeccakTypes) => KeccakHasher;
export = keccak;

7
keccak/keccak-tests.ts Normal file
View File

@ -0,0 +1,7 @@
import createKeccak = require('keccak');
const context = createKeccak('keccak256');
context.update(Buffer.from([1, 2, 3, 4, 5]));
context.update('hello world');
context.digest();

16
keccak/tsconfig.json Normal file
View File

@ -0,0 +1,16 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": ["es6"],
"noImplicitAny": true,
"noImplicitThis": true,
"strictFunctionTypes": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": ["../"],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": ["index.d.ts", "bn.js-tests.ts"]
}

1
keccak/tslint.json Normal file
View File

@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }