Comparing version 0.0.1 to 0.0.2
const bls = require('../') | ||
const nacl = require('tweetnacl') | ||
@@ -13,3 +14,3 @@ bls.onModuleInit(() => { | ||
const start = new Date() | ||
let start = new Date() | ||
const msg = Buffer.from('hello world') | ||
@@ -20,4 +21,4 @@ bls.sign(sig, sec, msg) | ||
const end = new Date() | ||
const time = end.getTime() - start.getTime() | ||
let end = new Date() | ||
let time = end.getTime() - start.getTime() | ||
console.log('finished in', time, 'ms') | ||
@@ -29,2 +30,13 @@ console.log(v) | ||
bls.free(pub) | ||
const keyPair = nacl.sign.keyPair() | ||
start = new Date() | ||
const signedMsg = nacl.sign(msg, keyPair.secretKey) | ||
const rmsg = nacl.sign.open(signedMsg, keyPair.publicKey) | ||
end = new Date() | ||
time = end.getTime() - start.getTime() | ||
console.log('finished in', time, 'ms') | ||
console.log(Buffer.from(rmsg).toString()) | ||
}) |
@@ -14,2 +14,3 @@ <!-- Generated by documentation.js. Update this documentation by updating the source code. --> | ||
- [free](#free) | ||
- [idSetInt](#idsetint) | ||
- [sign](#sign) | ||
@@ -20,2 +21,3 @@ - [verify](#verify) | ||
- [signatureSerialize](#signatureserialize) | ||
- [hashToSecretKey](#hashtosecretkey) | ||
- [secretKeyDeserialize](#secretkeydeserialize) | ||
@@ -32,2 +34,4 @@ - [publicKeyDeserialize](#publickeydeserialize) | ||
[index.js:13-20](https://github.com/wanderer/bls-lib/blob/29702674041ace08d16a5600105230669f208404/index.js#L13-L20 "Source code on GitHub") | ||
takes a callback that is called once the module is setup | ||
@@ -41,2 +45,4 @@ | ||
[index.js:25-25](https://github.com/wanderer/bls-lib/blob/29702674041ace08d16a5600105230669f208404/index.js#L25-L25 "Source code on GitHub") | ||
the FP254BNB curve | ||
@@ -46,2 +52,4 @@ | ||
[index.js:30-30](https://github.com/wanderer/bls-lib/blob/29702674041ace08d16a5600105230669f208404/index.js#L30-L30 "Source code on GitHub") | ||
the FP382_1 curve | ||
@@ -51,2 +59,4 @@ | ||
[index.js:35-35](https://github.com/wanderer/bls-lib/blob/29702674041ace08d16a5600105230669f208404/index.js#L35-L35 "Source code on GitHub") | ||
the FP382_2 curve | ||
@@ -56,2 +66,4 @@ | ||
[index.js:52-54](https://github.com/wanderer/bls-lib/blob/29702674041ace08d16a5600105230669f208404/index.js#L52-L54 "Source code on GitHub") | ||
intailizes the libary to use a given curve | ||
@@ -65,2 +77,4 @@ | ||
[index.js:60-62](https://github.com/wanderer/bls-lib/blob/29702674041ace08d16a5600105230669f208404/index.js#L60-L62 "Source code on GitHub") | ||
allocates a secret key | ||
@@ -72,2 +86,4 @@ | ||
[index.js:68-70](https://github.com/wanderer/bls-lib/blob/29702674041ace08d16a5600105230669f208404/index.js#L68-L70 "Source code on GitHub") | ||
allocates a secret key | ||
@@ -79,2 +95,4 @@ | ||
[index.js:76-78](https://github.com/wanderer/bls-lib/blob/29702674041ace08d16a5600105230669f208404/index.js#L76-L78 "Source code on GitHub") | ||
allocates a signature | ||
@@ -86,2 +104,4 @@ | ||
[index.js:83-85](https://github.com/wanderer/bls-lib/blob/29702674041ace08d16a5600105230669f208404/index.js#L83-L85 "Source code on GitHub") | ||
frees a pointer | ||
@@ -93,4 +113,17 @@ | ||
## idSetInt | ||
[index.js:92-97](https://github.com/wanderer/bls-lib/blob/29702674041ace08d16a5600105230669f208404/index.js#L92-L97 "Source code on GitHub") | ||
creates an ID to use in with threshold groups | ||
**Parameters** | ||
- `sk` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** a pointer to the secret key, secret key stuct is used to hold the id | ||
- `n` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** a int repsenting the ID. n cannot be zero. | ||
## sign | ||
[index.js:105-105](https://github.com/wanderer/bls-lib/blob/29702674041ace08d16a5600105230669f208404/index.js#L105-L105 "Source code on GitHub") | ||
signs a message | ||
@@ -106,2 +139,4 @@ | ||
[index.js:113-113](https://github.com/wanderer/bls-lib/blob/29702674041ace08d16a5600105230669f208404/index.js#L113-L113 "Source code on GitHub") | ||
verifies a signature | ||
@@ -117,2 +152,4 @@ | ||
[index.js:120-120](https://github.com/wanderer/bls-lib/blob/29702674041ace08d16a5600105230669f208404/index.js#L120-L120 "Source code on GitHub") | ||
given a pointer to a public key this returns 64 byte Int8Array containing the key | ||
@@ -128,2 +165,4 @@ | ||
[index.js:127-127](https://github.com/wanderer/bls-lib/blob/29702674041ace08d16a5600105230669f208404/index.js#L127-L127 "Source code on GitHub") | ||
given a pointer to a secret key this returns 32 byte Int8Array containing the key | ||
@@ -139,2 +178,4 @@ | ||
[index.js:134-134](https://github.com/wanderer/bls-lib/blob/29702674041ace08d16a5600105230669f208404/index.js#L134-L134 "Source code on GitHub") | ||
given a pointer to a signature this returns 32 byte Int8Array containing the signature | ||
@@ -148,4 +189,17 @@ | ||
## hashToSecretKey | ||
[index.js:141-141](https://github.com/wanderer/bls-lib/blob/29702674041ace08d16a5600105230669f208404/index.js#L141-L141 "Source code on GitHub") | ||
generates a secret key given a seed phrase. | ||
**Parameters** | ||
- `sk` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** a pointer to a secret key | ||
- `seed` **([String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String) \| [TypedArray](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray))** the seed phrase | ||
## secretKeyDeserialize | ||
[index.js:148-148](https://github.com/wanderer/bls-lib/blob/29702674041ace08d16a5600105230669f208404/index.js#L148-L148 "Source code on GitHub") | ||
write a secretKey to memory | ||
@@ -160,2 +214,4 @@ | ||
[index.js:155-155](https://github.com/wanderer/bls-lib/blob/29702674041ace08d16a5600105230669f208404/index.js#L155-L155 "Source code on GitHub") | ||
write a publicKey to memory | ||
@@ -170,2 +226,4 @@ | ||
[index.js:162-162](https://github.com/wanderer/bls-lib/blob/29702674041ace08d16a5600105230669f208404/index.js#L162-L162 "Source code on GitHub") | ||
write a signature to memory | ||
@@ -180,2 +238,4 @@ | ||
[index.js:170-170](https://github.com/wanderer/bls-lib/blob/29702674041ace08d16a5600105230669f208404/index.js#L170-L170 "Source code on GitHub") | ||
Recovers a secret key for a group given the groups secret keys shares and the groups ids | ||
@@ -191,2 +251,4 @@ | ||
[index.js:178-178](https://github.com/wanderer/bls-lib/blob/29702674041ace08d16a5600105230669f208404/index.js#L178-L178 "Source code on GitHub") | ||
Recovers a public key for a group given the groups public keys shares and the groups ids | ||
@@ -202,2 +264,4 @@ | ||
[index.js:186-186](https://github.com/wanderer/bls-lib/blob/29702674041ace08d16a5600105230669f208404/index.js#L186-L186 "Source code on GitHub") | ||
Recovers a signature for a group given the groups public keys shares and the groups ids | ||
@@ -213,2 +277,4 @@ | ||
[index.js:194-194](https://github.com/wanderer/bls-lib/blob/29702674041ace08d16a5600105230669f208404/index.js#L194-L194 "Source code on GitHub") | ||
Creates a secket key share for a group member given the groups members id (which is a the secret key) and array of master secret keys | ||
@@ -224,2 +290,4 @@ | ||
[index.js:202-202](https://github.com/wanderer/bls-lib/blob/29702674041ace08d16a5600105230669f208404/index.js#L202-L202 "Source code on GitHub") | ||
Creates a public key share for a group member given the groups members id (which is a the secret key) and array of master public keys | ||
@@ -226,0 +294,0 @@ |
@@ -81,4 +81,3 @@ [{ | ||
"name": "blsIdSetInt", | ||
"exportName": "idSetInt", | ||
"returns": "number", | ||
"exportName": "_idSetInt", | ||
"args": ["number", "number"] | ||
@@ -85,0 +84,0 @@ }, { |
17
index.js
@@ -88,2 +88,14 @@ const mod = require('./build/bls_lib.js') | ||
/** | ||
* creates an ID to use in with threshold groups | ||
* @param {number} sk - a pointer to the secret key, secret key stuct is used to hold the id | ||
* @param {number} n - a int repsenting the ID. n cannot be zero. | ||
*/ | ||
exports.idSetInt = function (sk, n) { | ||
if (n === 0) { | ||
throw new Error('id cannot be zero') | ||
} | ||
exports._idSetInt(sk, n) | ||
} | ||
/** | ||
* signs a message | ||
@@ -125,2 +137,7 @@ * @param {number} sig - a pointer to the a signature | ||
/** | ||
* generates a secret key given a seed phrase. | ||
* @param {number} sk - a pointer to a secret key | ||
* @param {String|TypedArray} seed - the seed phrase | ||
*/ | ||
exports.hashToSecretKey = wrapInput(exports._hashToSecretKey, true) | ||
@@ -127,0 +144,0 @@ |
{ | ||
"name": "bls-lib", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "this libary provides primitives for creating and verify BLS threshold signatures", | ||
"main": "index.js", | ||
"scripts": { | ||
"coverage": "istanbul cover ./tests/index.js", | ||
"coveralls": "npm run coverage && coveralls <coverage/lcov.info", | ||
"coveralls": "npm run coverage && nyc report --reporter=text-lcov | coveralls", | ||
"coverage": "nyc npm test", | ||
"lint": "standard", | ||
@@ -14,14 +14,13 @@ "test": "node ./tests/index.js", | ||
"keywords": [ | ||
"" | ||
"bls", | ||
"wasm", | ||
"crypto" | ||
], | ||
"author": "mjbecze <mjbecze@gmail.com>", | ||
"license": "MPL-2.0", | ||
"dependencies": { | ||
"defined": "^1.0.0" | ||
}, | ||
"devDependencies": { | ||
"array-shuffle": "^1.0.1", | ||
"coveralls": "^2.11.4", | ||
"documentation": "^5.2.0", | ||
"istanbul": "^0.4.1", | ||
"nyc": "^11.2.1", | ||
"standard": "^10.0.0", | ||
@@ -28,0 +27,0 @@ "tape": "^4.0.3" |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 13 instances in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
0
3
6
26
30549509
54
8507
- Removeddefined@^1.0.0
- Removeddefined@1.0.1(transitive)