@mainsail/crypto-signature-bls12-381 0.0.1-alpha.9 → 0.0.1-evm.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/distribution/index.d.ts +1 -2
- package/distribution/index.d.ts.map +1 -1
- package/distribution/index.js +7 -28
- package/distribution/index.js.map +1 -1
- package/distribution/signature.d.ts +1 -1
- package/distribution/signature.d.ts.map +1 -1
- package/distribution/signature.js +11 -11
- package/distribution/signature.js.map +1 -1
- package/package.json +10 -8
package/distribution/index.d.ts
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
import { Providers } from "@mainsail/kernel";
|
2
|
-
export * from "./signature";
|
2
|
+
export * from "./signature.js";
|
3
3
|
export declare class ServiceProvider extends Providers.ServiceProvider {
|
4
4
|
register(): Promise<void>;
|
5
|
-
requiredByWorker(): boolean;
|
6
5
|
}
|
7
6
|
//# sourceMappingURL=index.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../source/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAI7C,cAAc,
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../source/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAI7C,cAAc,gBAAgB,CAAC;AAE/B,qBAAa,eAAgB,SAAQ,SAAS,CAAC,eAAe;IAChD,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;CAItC"}
|
package/distribution/index.js
CHANGED
@@ -1,32 +1,11 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
7
|
-
}
|
8
|
-
Object.defineProperty(o, k2, desc);
|
9
|
-
}) : (function(o, m, k, k2) {
|
10
|
-
if (k2 === undefined) k2 = k;
|
11
|
-
o[k2] = m[k];
|
12
|
-
}));
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
15
|
-
};
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
17
|
-
exports.ServiceProvider = void 0;
|
18
|
-
const contracts_1 = require("@mainsail/contracts");
|
19
|
-
const kernel_1 = require("@mainsail/kernel");
|
20
|
-
const signature_1 = require("./signature");
|
21
|
-
__exportStar(require("./signature"), exports);
|
22
|
-
class ServiceProvider extends kernel_1.Providers.ServiceProvider {
|
1
|
+
import { Identifiers } from "@mainsail/contracts";
|
2
|
+
import { Providers } from "@mainsail/kernel";
|
3
|
+
import { Signature } from "./signature.js";
|
4
|
+
export * from "./signature.js";
|
5
|
+
export class ServiceProvider extends Providers.ServiceProvider {
|
23
6
|
async register() {
|
24
|
-
this.app.bind(
|
25
|
-
this.app.bind(
|
26
|
-
}
|
27
|
-
requiredByWorker() {
|
28
|
-
return true;
|
7
|
+
this.app.bind(Identifiers.Cryptography.Signature.Size).toConstantValue(96);
|
8
|
+
this.app.bind(Identifiers.Cryptography.Signature.Instance).to(Signature).inSingletonScope();
|
29
9
|
}
|
30
10
|
}
|
31
|
-
exports.ServiceProvider = ServiceProvider;
|
32
11
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../source/index.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../source/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE7C,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C,cAAc,gBAAgB,CAAC;AAE/B,MAAM,OAAO,eAAgB,SAAQ,SAAS,CAAC,eAAe;IACtD,KAAK,CAAC,QAAQ;QACpB,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,eAAe,CAAC,EAAE,CAAC,CAAC;QAC3E,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC,gBAAgB,EAAE,CAAC;IAC7F,CAAC;CACD"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"signature.d.ts","sourceRoot":"","sources":["../source/signature.ts"],"names":[],"mappings":";
|
1
|
+
{"version":3,"file":"signature.d.ts","sourceRoot":"","sources":["../source/signature.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAEhD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C,qBACa,SAAU,YAAW,SAAS,CAAC,MAAM,CAAC,SAAS;IAC9C,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAK1D,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IASrF,SAAS,CAAC,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI;IAItD,WAAW,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM;IAIjC,SAAS,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC;CAM7D"}
|
@@ -1,20 +1,19 @@
|
|
1
|
-
"use strict";
|
2
1
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
3
2
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
4
3
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
5
4
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
6
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
7
6
|
};
|
8
|
-
|
9
|
-
|
10
|
-
const blst_1 = require("@chainsafe/blst");
|
11
|
-
const container_1 = require("@mainsail/container");
|
7
|
+
import { injectable } from "@mainsail/container";
|
8
|
+
import { getBls } from "@mainsail/crypto-key-pair-bls12-381";
|
12
9
|
let Signature = class Signature {
|
13
10
|
async sign(message, privateKey) {
|
14
|
-
|
11
|
+
const bls = await getBls();
|
12
|
+
return Buffer.from(bls.SecretKey.fromBytes(privateKey).sign(message).toBytes()).toString("hex");
|
15
13
|
}
|
16
14
|
async verify(signature, message, publicKey) {
|
17
|
-
|
15
|
+
const bls = await getBls();
|
16
|
+
return bls.verify(bls.PublicKey.fromBytes(publicKey).toBytes(), message, bls.Signature.fromBytes(signature).toBytes());
|
18
17
|
}
|
19
18
|
serialize(buffer, signature) {
|
20
19
|
buffer.writeBytes(Buffer.from(signature, "hex"));
|
@@ -23,11 +22,12 @@ let Signature = class Signature {
|
|
23
22
|
return buffer.readBytes(96);
|
24
23
|
}
|
25
24
|
async aggregate(signatures) {
|
26
|
-
|
25
|
+
const bls = await getBls();
|
26
|
+
return Buffer.from(bls.aggregateSignatures(signatures.map((s) => bls.Signature.fromBytes(s).toBytes()))).toString("hex");
|
27
27
|
}
|
28
28
|
};
|
29
|
-
|
30
|
-
|
31
|
-
(0, container_1.injectable)()
|
29
|
+
Signature = __decorate([
|
30
|
+
injectable()
|
32
31
|
], Signature);
|
32
|
+
export { Signature };
|
33
33
|
//# sourceMappingURL=signature.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"signature.js","sourceRoot":"","sources":["../source/signature.ts"],"names":[],"mappings":"
|
1
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AC,EAAE,EAAE,CAAC,GAAG,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CACpF,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IACnB,CAAC;CACD,CAAA;AA7BY,SAAS;IADrB,UAAU,EAAE;GACA,SAAS,CA6BrB"}
|
package/package.json
CHANGED
@@ -1,20 +1,21 @@
|
|
1
1
|
{
|
2
2
|
"name": "@mainsail/crypto-signature-bls12-381",
|
3
|
-
"version": "0.0.1-
|
3
|
+
"version": "0.0.1-evm.1",
|
4
4
|
"description": "BLS12-381 signatures for the Mainsail blockchain",
|
5
5
|
"license": "GPL-3.0-only",
|
6
6
|
"contributors": [],
|
7
|
+
"type": "module",
|
7
8
|
"main": "distribution/index.js",
|
8
9
|
"types": "distribution/index.d.ts",
|
9
10
|
"files": [
|
10
11
|
"distribution"
|
11
12
|
],
|
12
13
|
"dependencies": {
|
13
|
-
"@
|
14
|
-
"@mainsail/
|
15
|
-
"@mainsail/
|
16
|
-
"@mainsail/kernel": "0.0.1-
|
17
|
-
"@mainsail/utils": "0.0.1-
|
14
|
+
"@mainsail/container": "0.0.1-evm.1",
|
15
|
+
"@mainsail/contracts": "0.0.1-evm.1",
|
16
|
+
"@mainsail/crypto-key-pair-bls12-381": "0.0.1-evm.1",
|
17
|
+
"@mainsail/kernel": "0.0.1-evm.1",
|
18
|
+
"@mainsail/utils": "0.0.1-evm.1"
|
18
19
|
},
|
19
20
|
"devDependencies": {
|
20
21
|
"uvu": "^0.5.6"
|
@@ -27,9 +28,10 @@
|
|
27
28
|
"build:watch": "pnpm run clean && tsc -w",
|
28
29
|
"clean": "del distribution",
|
29
30
|
"release": "pnpm publish --access public",
|
30
|
-
"test": "
|
31
|
+
"test": "pnpm run uvu source .test.ts",
|
31
32
|
"test:coverage": "c8 pnpm run test",
|
32
33
|
"test:coverage:html": "c8 -r html --all pnpm run test",
|
33
|
-
"test:file": "
|
34
|
+
"test:file": "pnpm run uvu source",
|
35
|
+
"uvu": "tsx --tsconfig ../../tsconfig.test.json ./node_modules/uvu/bin.js"
|
34
36
|
}
|
35
37
|
}
|