@mainsail/crypto-signature-ecdsa 0.0.1-alpha.8 → 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 +0 -1
- package/distribution/index.d.ts.map +1 -1
- package/distribution/index.js +10 -17
- package/distribution/index.js.map +1 -1
- package/distribution/signature.d.ts +1 -1
- package/distribution/signature.js +12 -15
- package/distribution/signature.js.map +1 -1
- package/package.json +9 -7
package/distribution/index.d.ts
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../source/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAK7C,qBAAa,eAAgB,SAAQ,SAAS,CAAC,eAAe;IAChD,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../source/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAK7C,qBAAa,eAAgB,SAAQ,SAAS,CAAC,eAAe;IAChD,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;CAqBtC"}
|
package/distribution/index.js
CHANGED
@@ -1,14 +1,11 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
const kernel_1 = require("@mainsail/kernel");
|
7
|
-
const signature_1 = require("./signature");
|
8
|
-
class ServiceProvider extends kernel_1.Providers.ServiceProvider {
|
1
|
+
import { Selectors } from "@mainsail/container";
|
2
|
+
import { Identifiers } from "@mainsail/contracts";
|
3
|
+
import { Providers } from "@mainsail/kernel";
|
4
|
+
import { Signature } from "./signature.js";
|
5
|
+
export class ServiceProvider extends Providers.ServiceProvider {
|
9
6
|
async register() {
|
10
7
|
this.app
|
11
|
-
.bind(
|
8
|
+
.bind(Identifiers.Cryptography.Signature.Size)
|
12
9
|
.toFunction((buffer) => {
|
13
10
|
buffer.mark();
|
14
11
|
buffer.skip(1);
|
@@ -16,16 +13,12 @@ class ServiceProvider extends kernel_1.Providers.ServiceProvider {
|
|
16
13
|
buffer.reset();
|
17
14
|
return Number.parseInt(lengthHex, 16) + 2;
|
18
15
|
})
|
19
|
-
.when(
|
16
|
+
.when(Selectors.anyAncestorOrTargetTaggedFirst("type", "wallet"));
|
20
17
|
this.app
|
21
|
-
.bind(
|
22
|
-
.to(
|
18
|
+
.bind(Identifiers.Cryptography.Signature.Instance)
|
19
|
+
.to(Signature)
|
23
20
|
.inSingletonScope()
|
24
|
-
.when(
|
25
|
-
}
|
26
|
-
requiredByWorker() {
|
27
|
-
return true;
|
21
|
+
.when(Selectors.anyAncestorOrTargetTaggedFirst("type", "wallet"));
|
28
22
|
}
|
29
23
|
}
|
30
|
-
exports.ServiceProvider = ServiceProvider;
|
31
24
|
//# 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,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAG7C,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C,MAAM,OAAO,eAAgB,SAAQ,SAAS,CAAC,eAAe;IACtD,KAAK,CAAC,QAAQ;QACpB,IAAI,CAAC,GAAG;aACN,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC,SAAS,CAAC,IAAI,CAAC;aAC7C,UAAU,CAAC,CAAC,MAAkB,EAAE,EAAE;YAClC,MAAM,CAAC,IAAI,EAAE,CAAC;YACd,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YAEf,MAAM,SAAS,GAAW,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;YAE9D,MAAM,CAAC,KAAK,EAAE,CAAC;YAEf,OAAO,MAAM,CAAC,QAAQ,CAAC,SAAS,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC;QAC3C,CAAC,CAAC;aACD,IAAI,CAAC,SAAS,CAAC,8BAA8B,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC;QAEnE,IAAI,CAAC,GAAG;aACN,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC,SAAS,CAAC,QAAQ,CAAC;aACjD,EAAE,CAAC,SAAS,CAAC;aACb,gBAAgB,EAAE;aAClB,IAAI,CAAC,SAAS,CAAC,8BAA8B,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC;IACpE,CAAC;CACD"}
|
@@ -1,4 +1,3 @@
|
|
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);
|
@@ -8,18 +7,16 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
8
7
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
9
8
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
10
9
|
};
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
const contracts_1 = require("@mainsail/contracts");
|
15
|
-
const bcrypto_1 = require("bcrypto");
|
10
|
+
import { inject, injectable } from "@mainsail/container";
|
11
|
+
import { Exceptions, Identifiers } from "@mainsail/contracts";
|
12
|
+
import { secp256k1 } from "bcrypto";
|
16
13
|
let Signature = class Signature {
|
17
14
|
async sign(message, privateKey) {
|
18
|
-
return
|
15
|
+
return secp256k1.signatureExport(secp256k1.sign(message, privateKey)).toString("hex");
|
19
16
|
}
|
20
17
|
async verify(signature, message, publicKey) {
|
21
|
-
const signatureRS =
|
22
|
-
if (!
|
18
|
+
const signatureRS = secp256k1.signatureImport(signature);
|
19
|
+
if (!secp256k1.isLowS(signatureRS)) {
|
23
20
|
return false;
|
24
21
|
}
|
25
22
|
// check that global signature length matches R and S length, see DER format :
|
@@ -43,7 +40,7 @@ let Signature = class Signature {
|
|
43
40
|
(sFirstByte === 0 && signature.readInt8(4 + rLength + 2 + 1) >= 0)) {
|
44
41
|
return false;
|
45
42
|
}
|
46
|
-
return
|
43
|
+
return secp256k1.verify(message, signatureRS, publicKey);
|
47
44
|
}
|
48
45
|
serialize(buffer, signature) {
|
49
46
|
buffer.writeBytes(Buffer.from(signature, "hex"));
|
@@ -52,15 +49,15 @@ let Signature = class Signature {
|
|
52
49
|
return buffer.readBytes(this.signatureSize(buffer));
|
53
50
|
}
|
54
51
|
async aggregate(signatures) {
|
55
|
-
throw new
|
52
|
+
throw new Exceptions.NotImplemented(this.constructor.name, "aggregate");
|
56
53
|
}
|
57
54
|
};
|
58
|
-
exports.Signature = Signature;
|
59
55
|
__decorate([
|
60
|
-
|
56
|
+
inject(Identifiers.Cryptography.Signature.Size),
|
61
57
|
__metadata("design:type", Function)
|
62
58
|
], Signature.prototype, "signatureSize", void 0);
|
63
|
-
|
64
|
-
|
59
|
+
Signature = __decorate([
|
60
|
+
injectable()
|
65
61
|
], Signature);
|
62
|
+
export { Signature };
|
66
63
|
//# sourceMappingURL=signature.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"signature.js","sourceRoot":"","sources":["../source/signature.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"signature.js","sourceRoot":"","sources":["../source/signature.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAa,U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A) 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": [
|
@@ -11,10 +12,10 @@
|
|
11
12
|
],
|
12
13
|
"dependencies": {
|
13
14
|
"bcrypto": "5.5.2",
|
14
|
-
"@mainsail/
|
15
|
-
"@mainsail/
|
16
|
-
"@mainsail/kernel": "0.0.1-
|
17
|
-
"@mainsail/utils": "0.0.1-
|
15
|
+
"@mainsail/contracts": "0.0.1-evm.1",
|
16
|
+
"@mainsail/container": "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
|
}
|