@mattrglobal/bls12381-key-pair
Advanced tools
Comparing version 0.4.1-unstable.98235ce to 0.4.1-unstable.ad69446
@@ -1,2 +0,2 @@ | ||
## 0.4.1-unstable.98235ce (2020-09-07) | ||
## 0.4.1-unstable.ad69446 (2021-02-24) | ||
@@ -6,7 +6,7 @@ | ||
* add support to convert to and from JWKs ([#25](https://github.com/mattrglobal/bls12381-key-pair/issues/25)) ([98235ce](https://github.com/mattrglobal/bls12381-key-pair/commit/98235ce2e2b0a8bdaa4aec85f3008ad057dbcade)), closes [#12](https://github.com/mattrglobal/bls12381-key-pair/issues/12) | ||
* bump bbs signatures version ([#34](https://github.com/mattrglobal/bls12381-key-pair/issues/34)) ([ad69446](https://github.com/mattrglobal/bls12381-key-pair/commit/ad69446b1941277c0af89911d14bcec6d527da9d)) | ||
## 0.4.1 (2020-09-07) | ||
## 0.4.1 (2021-02-24) | ||
@@ -16,3 +16,3 @@ | ||
* add support to convert to and from JWKs ([#25](https://github.com/mattrglobal/bls12381-key-pair/issues/25)) ([98235ce](https://github.com/mattrglobal/bls12381-key-pair/commit/98235ce2e2b0a8bdaa4aec85f3008ad057dbcade)), closes [#12](https://github.com/mattrglobal/bls12381-key-pair/issues/12) | ||
* bump bbs signatures version ([#34](https://github.com/mattrglobal/bls12381-key-pair/issues/34)) ([ad69446](https://github.com/mattrglobal/bls12381-key-pair/commit/ad69446b1941277c0af89911d14bcec6d527da9d)) | ||
@@ -19,0 +19,0 @@ |
@@ -64,3 +64,3 @@ "use strict"; | ||
if (data instanceof Uint8Array) { | ||
return bbs_signatures_1.blsSign({ | ||
return await bbs_signatures_1.blsSign({ | ||
messages: [data], | ||
@@ -73,3 +73,3 @@ keyPair: { | ||
} | ||
return bbs_signatures_1.blsSign({ | ||
return await bbs_signatures_1.blsSign({ | ||
messages: data, | ||
@@ -106,13 +106,13 @@ keyPair: { | ||
if (data instanceof Uint8Array) { | ||
return bbs_signatures_1.blsVerify({ | ||
return (await bbs_signatures_1.blsVerify({ | ||
messages: [data], | ||
publicKey: new Uint8Array(key.publicKeyBuffer), | ||
signature | ||
}).verified; | ||
})).verified; | ||
} | ||
return bbs_signatures_1.blsVerify({ | ||
return (await bbs_signatures_1.blsVerify({ | ||
messages: data, | ||
publicKey: new Uint8Array(key.publicKeyBuffer), | ||
signature | ||
}).verified; | ||
})).verified; | ||
} | ||
@@ -133,3 +133,23 @@ }; | ||
this.type = "Bls12381G2Key2020"; | ||
//TODO need some assert statements here | ||
/** | ||
* The provided publicKey needs to be 384 bits / 5.85 = 65.6 | ||
* which means the base58 encoded publicKey can be either 65 or 66 chars | ||
* 5.85 = log base 2 (58) which is equivalent to the number of bits | ||
* encoded per character of a base58 encoded string. | ||
* | ||
*/ | ||
if (options.publicKeyBase58.length !== 131 && | ||
options.publicKeyBase58.length !== 132) { | ||
throw new Error(`The size of the public key is incorrect. Expected 131 or 132 chars got: ${options.publicKeyBase58.length}`); | ||
} | ||
/** | ||
* Validates the size of the private key if one is included | ||
* This is done by 256 bits / 5.85 = 43.7 which means | ||
* the base58 encoded privateKey can be either 43 or 44 chars | ||
*/ | ||
if (typeof options.privateKeyBase58 !== "undefined" && | ||
options.privateKeyBase58.length !== 43 && | ||
options.privateKeyBase58.length !== 44) { | ||
throw new Error(`The size of the private key is incorrect. Expected 65 or 66 chars got: ${options.privateKeyBase58.length}`); | ||
} | ||
this.id = options.id; | ||
@@ -151,4 +171,4 @@ this.controller = options.controller; | ||
var _a; | ||
const keyPair = ((_a = options) === null || _a === void 0 ? void 0 : _a.seed) ? bbs_signatures_1.generateBls12381G2KeyPair(options.seed) | ||
: bbs_signatures_1.generateBls12381G2KeyPair(); | ||
const keyPair = ((_a = options) === null || _a === void 0 ? void 0 : _a.seed) ? await bbs_signatures_1.generateBls12381G2KeyPair(options.seed) | ||
: await 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) })); | ||
@@ -174,2 +194,7 @@ } | ||
if (typeof privateKeyJwk !== "undefined" && | ||
/** | ||
* The type casting is verified through the use of this assert function | ||
* However because the returned interface leaves the properties as optional | ||
* they need to be cast to pass to the convert function. | ||
**/ | ||
validators_1.assertBls12381G2PrivateJwk(privateKeyJwk)) { | ||
@@ -176,0 +201,0 @@ return new Bls12381G2KeyPair({ |
@@ -0,2 +1,3 @@ | ||
export { Bls12381G1KeyPair } from "./Bls12381G1KeyPair"; | ||
export { Bls12381G2KeyPair } from "./Bls12381G2KeyPair"; | ||
export { GenerateKeyPairOptions, KeyPairOptions } from "./types"; |
@@ -15,4 +15,6 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var Bls12381G1KeyPair_1 = require("./Bls12381G1KeyPair"); | ||
exports.Bls12381G1KeyPair = Bls12381G1KeyPair_1.Bls12381G1KeyPair; | ||
var Bls12381G2KeyPair_1 = require("./Bls12381G2KeyPair"); | ||
exports.Bls12381G2KeyPair = Bls12381G2KeyPair_1.Bls12381G2KeyPair; | ||
//# sourceMappingURL=index.js.map |
@@ -1,2 +0,2 @@ | ||
export { assertPrivateBlsJwk as assertPrivateJwk, assertPublicBlsJwk as assertPublicJwk } from "./JsonWebKey"; | ||
export { assertBls12381G1PrivateJwk, assertBls12381G1PublicJwk } from "./Bls12381G1Jwk"; | ||
export { assertBls12381G2PrivateJwk, assertBls12381G2PublicJwk } from "./Bls12381G2Jwk"; |
@@ -15,5 +15,5 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var JsonWebKey_1 = require("./JsonWebKey"); | ||
exports.assertPrivateJwk = JsonWebKey_1.assertPrivateBlsJwk; | ||
exports.assertPublicJwk = JsonWebKey_1.assertPublicBlsJwk; | ||
var Bls12381G1Jwk_1 = require("./Bls12381G1Jwk"); | ||
exports.assertBls12381G1PrivateJwk = Bls12381G1Jwk_1.assertBls12381G1PrivateJwk; | ||
exports.assertBls12381G1PublicJwk = Bls12381G1Jwk_1.assertBls12381G1PublicJwk; | ||
var Bls12381G2Jwk_1 = require("./Bls12381G2Jwk"); | ||
@@ -20,0 +20,0 @@ exports.assertBls12381G2PrivateJwk = Bls12381G2Jwk_1.assertBls12381G2PrivateJwk; |
{ | ||
"name": "@mattrglobal/bls12381-key-pair", | ||
"version": "0.4.1-unstable.98235ce", | ||
"version": "0.4.1-unstable.ad69446", | ||
"description": "A library for using BLS 12-381 key pairs with BBS+ signatures", | ||
@@ -68,3 +68,3 @@ "homepage": "https://github.com/mattrglobal/bls12381-key-pair", | ||
"dependencies": { | ||
"@mattrglobal/bbs-signatures": "0.4.0", | ||
"@mattrglobal/bbs-signatures": "0.5.0", | ||
"bs58": "4.0.1", | ||
@@ -71,0 +71,0 @@ "rfc4648": "1.4.0" |
@@ -1,2 +0,2 @@ | ||
![Mattr logo](./docs/assets/mattr-black.svg) | ||
[![MATTR](./docs/assets/mattr-logo-square.svg)](https://github.com/mattrglobal) | ||
@@ -67,1 +67,5 @@ # bls12381-key-pair | ||
Please see our [security policy](./SECURITY.md) for additional details about responsible disclosure of security related issues. | ||
--- | ||
<p align="center"><a href="https://mattr.global" target="_blank"><img height="40px" src ="./docs/assets/mattr-logo-tm.svg"></a></p><p align="center">Copyright © MATTR Limited. <a href="./LICENSE">Some rights reserved.</a><br/>“MATTR” is a trademark of MATTR Limited, registered in New Zealand and other countries.</p> |
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
91539
55
1465
71
+ Added@mattrglobal/bbs-signatures@0.5.0(transitive)
+ Added@mattrglobal/node-bbs-signatures@0.11.0(transitive)
- Removed@mattrglobal/bbs-signatures@0.4.0(transitive)
- Removed@mattrglobal/node-bbs-signatures@0.10.0(transitive)