@mattrglobal/bls12381-key-pair
Advanced tools
Comparing version 0.3.1-unstable.dc79d57 to 0.3.1-unstable.e7b615a
@@ -1,9 +0,19 @@ | ||
## 0.3.1-unstable.dc79d57 (2020-06-22) | ||
## 0.3.1-unstable.e7b615a (2020-08-27) | ||
### Features | ||
## 0.3.1 (2020-06-22) | ||
* update sign and verify apis to use Uint8Arrays ([#22](https://github.com/mattrglobal/bls12381-key-pair/issues/22)) ([e7b615a](https://github.com/mattrglobal/bls12381-key-pair/commit/e7b615adf9c16a850575ac7f8469ba77da1ca6d3)) | ||
## 0.3.1 (2020-08-27) | ||
### Features | ||
* update sign and verify apis to use Uint8Arrays ([#22](https://github.com/mattrglobal/bls12381-key-pair/issues/22)) ([e7b615a](https://github.com/mattrglobal/bls12381-key-pair/commit/e7b615adf9c16a850575ac7f8469ba77da1ca6d3)) | ||
# [0.3.0](https://github.com/mattrglobal/bls12381-key-pair/compare/v0.2.0...v0.3.0) (2020-05-25) | ||
@@ -10,0 +20,0 @@ |
@@ -20,3 +20,3 @@ "use strict"; | ||
const bs58_1 = __importDefault(require("bs58")); | ||
const node_bbs_signatures_1 = require("@mattrglobal/node-bbs-signatures"); | ||
const bbs_signatures_1 = require("@mattrglobal/bbs-signatures"); | ||
/** | ||
@@ -59,5 +59,5 @@ * z represents the multibase encoding scheme of base58 encoding | ||
async sign({ data }) { | ||
//TODO assert data runtime string | string[] | ||
if (typeof data === "string") { | ||
return Buffer.from(node_bbs_signatures_1.blsSign({ | ||
//TODO assert data runtime Uint8Array | Uint8Array[] | ||
if (data instanceof Uint8Array) { | ||
return bbs_signatures_1.blsSign({ | ||
messages: [data], | ||
@@ -68,5 +68,5 @@ keyPair: { | ||
} | ||
})).toString("base64"); | ||
}); | ||
} | ||
return Buffer.from(node_bbs_signatures_1.blsSign({ | ||
return bbs_signatures_1.blsSign({ | ||
messages: data, | ||
@@ -77,3 +77,3 @@ keyPair: { | ||
} | ||
})).toString("base64"); | ||
}); | ||
} | ||
@@ -102,14 +102,14 @@ }; | ||
async verify({ data, signature }) { | ||
//TODO assert data | ||
if (typeof data === "string") { | ||
return node_bbs_signatures_1.blsVerify({ | ||
//TODO assert data instance of Uint8Array | Uint8Array[] | ||
if (data instanceof Uint8Array) { | ||
return bbs_signatures_1.blsVerify({ | ||
messages: [data], | ||
publicKey: new Uint8Array(key.publicKeyBuffer), | ||
signature: new Uint8Array(Buffer.from(signature, "base64")) | ||
signature | ||
}).verified; | ||
} | ||
return node_bbs_signatures_1.blsVerify({ | ||
return bbs_signatures_1.blsVerify({ | ||
messages: data, | ||
publicKey: new Uint8Array(key.publicKeyBuffer), | ||
signature: new Uint8Array(Buffer.from(signature, "base64")) | ||
signature | ||
}).verified; | ||
@@ -148,4 +148,4 @@ } | ||
var _a; | ||
const keyPair = ((_a = options) === null || _a === void 0 ? void 0 : _a.seed) ? node_bbs_signatures_1.generateBls12381KeyPair(options.seed) | ||
: node_bbs_signatures_1.generateBls12381KeyPair(); | ||
const keyPair = ((_a = options) === null || _a === void 0 ? void 0 : _a.seed) ? bbs_signatures_1.generateBls12381G2KeyPair(options.seed) | ||
: bbs_signatures_1.generateBls12381G2KeyPair(); | ||
return new Bls12381G2KeyPair(Object.assign(Object.assign({}, options), { privateKeyBase58: bs58_1.default.encode(keyPair.secretKey), publicKeyBase58: bs58_1.default.encode(keyPair.publicKey) })); | ||
@@ -177,4 +177,4 @@ } | ||
const buffer = bs58_1.default.decode(fingerprint.substr(1)); | ||
if (buffer.length !== node_bbs_signatures_1.DEFAULT_BLS12381_PUBLIC_KEY_LENGTH + 2) { | ||
throw new Error(`Unsupported public key length: expected \`${node_bbs_signatures_1.DEFAULT_BLS12381_PUBLIC_KEY_LENGTH}\` received \`${buffer.length - | ||
if (buffer.length !== bbs_signatures_1.DEFAULT_BLS12381_G2_PUBLIC_KEY_LENGTH + 2) { | ||
throw new Error(`Unsupported public key length: expected \`${bbs_signatures_1.DEFAULT_BLS12381_G2_PUBLIC_KEY_LENGTH}\` received \`${buffer.length - | ||
2}\``); | ||
@@ -181,0 +181,0 @@ } |
@@ -8,3 +8,3 @@ /** | ||
*/ | ||
readonly sign: (options: KeyPairSignerOptions) => Promise<string>; | ||
readonly sign: (options: KeyPairSignerOptions) => Promise<Uint8Array>; | ||
} | ||
@@ -15,3 +15,3 @@ /** | ||
export interface KeyPairSignerOptions { | ||
readonly data: string | string[]; | ||
readonly data: Uint8Array | Uint8Array[]; | ||
} |
@@ -14,4 +14,4 @@ /** | ||
export interface KeyPairVerifierOptions { | ||
readonly data: string | string[]; | ||
readonly signature: string; | ||
readonly data: Uint8Array | Uint8Array[]; | ||
readonly signature: Uint8Array; | ||
} |
{ | ||
"name": "@mattrglobal/bls12381-key-pair", | ||
"version": "0.3.1-unstable.dc79d57", | ||
"version": "0.3.1-unstable.e7b615a", | ||
"description": "A library for using BLS 12-381 key pairs with BBS+ signatures", | ||
@@ -32,3 +32,3 @@ "homepage": "https://github.com/mattrglobal/bls12381-key-pair", | ||
"scripts": { | ||
"test": "jest", | ||
"test": "NODE_OPTIONS='--max-old-space-size=8192' jest", | ||
"build": "tsc --pretty", | ||
@@ -69,3 +69,3 @@ "clean": "rm -rf lib/", | ||
"dependencies": { | ||
"@mattrglobal/node-bbs-signatures": "0.8.0", | ||
"@mattrglobal/bbs-signatures": "0.3.1-unstable.92238cf", | ||
"bs58": "4.0.1" | ||
@@ -72,0 +72,0 @@ }, |
@@ -63,1 +63,5 @@  | ||
``` | ||
## Security Policy | ||
Please see our [security policy](./SECURITY.md) for additional details about responsible disclosure of security related issues. |
Sorry, the diff of this file is not supported yet
44192
67
+ Added@mattrglobal/bbs-signatures@0.3.1-unstable.92238cf(transitive)
+ Added@mattrglobal/node-bbs-signatures@0.9.1-unstable.4cb57b7(transitive)
- Removed@mattrglobal/node-bbs-signatures@0.8.0(transitive)