Add tweetnacl

This commit is contained in:
Jaco Greeff 2018-06-21 16:02:16 +02:00
parent ad92cf7166
commit 490677baf1
5 changed files with 76 additions and 0 deletions

View File

@ -29,3 +29,4 @@ This following libraries are currently included. Where possible add the relevant
- [peer-info](https://github.com/libp2p/js-peer-info)
- [pull-pushable](https://github.com/pull-stream/pull-pushable)
- [pull-stream](https://github.com/pull-stream/pull-stream)
- [tweetnacl](https://github.com/dchest/tweetnacl-js)

58
tweetnacl/index.d.ts vendored Normal file
View File

@ -0,0 +1,58 @@
// Type definitions for tweetnacl 1.0.0
// Project: https://github.com/dchest/tweetnacl-js
// Definitions by: Jaco Greeff <https://github.com/jacogr>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="node"/>
type KeypairType = {
publicKey: Uint8Array,
secretKey: Uint8Array
};
type Hash = {
(message: Uint8Array): Uint8Array,
hashLength: number
};
type SecretBox = {
(message: Uint8Array, nonce: Uint8Array, secret: Uint8Array): Uint8Array,
open: (encrypted: Uint8Array, nonce: Uint8Array, secret: Uint8Array) => Uint8Array | null
};
type SignDetached = {
(message: Uint8Array, secretKey: Uint8Array): Uint8Array,
verify: (message: Uint8Array, signature: Uint8Array, publicKey: Uint8Array) => boolean
};
type SignKeypair = {
(): KeypairType,
fromSecretKey: (secretKey: Uint8Array) => KeypairType,
fromSeed: (seed: Uint8Array) => KeypairType,
};
type Sign = {
(message: Uint8Array, secretKey: Uint8Array): Uint8Array,
detached: SignDetached,
open: (signedMsg: Uint8Array, publicKey: Uint8Array) => Uint8Array,
keyPair: SignKeypair,
publicKeyLength: number,
secretKeyLength: number,
seedLength: number,
signatureLength: number,
};
type TweetNacl = {
randomBytes: (length: number) => Uint8Array,
hash: Hash,
secretbox: SecretBox,
sign: Sign
};
export = TweetNacl;

16
tweetnacl/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
tweetnacl/tslint.json Normal file
View File

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

View File