@mainsail/crypto-key-pair-schnorr 0.0.1-alpha.9 → 0.0.1-evm.2
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 +2 -3
- package/distribution/index.d.ts.map +1 -1
- package/distribution/index.js +27 -48
- package/distribution/index.js.map +1 -1
- package/distribution/pair.d.ts +1 -1
- package/distribution/pair.js +12 -18
- package/distribution/pair.js.map +1 -1
- package/distribution/private.js +6 -9
- package/distribution/private.js.map +1 -1
- package/distribution/public.d.ts +1 -1
- package/distribution/public.js +14 -17
- package/distribution/public.js.map +1 -1
- package/distribution/schemas.js +1 -4
- package/distribution/schemas.js.map +1 -1
- package/distribution/serializer.d.ts +1 -1
- package/distribution/serializer.js +4 -7
- package/distribution/serializer.js.map +1 -1
- package/package.json +12 -10
package/distribution/index.d.ts
CHANGED
@@ -1,9 +1,8 @@
|
|
1
1
|
import { Providers } from "@mainsail/kernel";
|
2
|
-
export * from "./pair";
|
3
|
-
export * from "./schemas";
|
2
|
+
export * from "./pair.js";
|
3
|
+
export * from "./schemas.js";
|
4
4
|
export declare class ServiceProvider extends Providers.ServiceProvider {
|
5
5
|
#private;
|
6
6
|
register(): Promise<void>;
|
7
|
-
requiredByWorker(): boolean;
|
8
7
|
}
|
9
8
|
//# sourceMappingURL=index.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../source/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAQ7C,cAAc,
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../source/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAQ7C,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAE7B,qBAAa,eAAgB,SAAQ,SAAS,CAAC,eAAe;;IAChD,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;CAmCtC"}
|
package/distribution/index.js
CHANGED
@@ -1,76 +1,55 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
-
if (k2 === undefined) k2 = k;
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
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
1
|
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
17
2
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
18
3
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
19
4
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
20
5
|
};
|
21
6
|
var _ServiceProvider_instances, _ServiceProvider_registerSchemas;
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
__exportStar(require("./schemas"), exports);
|
34
|
-
class ServiceProvider extends kernel_1.Providers.ServiceProvider {
|
7
|
+
import { Selectors } from "@mainsail/container";
|
8
|
+
import { Identifiers } from "@mainsail/contracts";
|
9
|
+
import { Providers } from "@mainsail/kernel";
|
10
|
+
import { KeyPairFactory } from "./pair.js";
|
11
|
+
import { PrivateKeyFactory } from "./private.js";
|
12
|
+
import { PublicKeyFactory } from "./public.js";
|
13
|
+
import { schemas } from "./schemas.js";
|
14
|
+
import { PublicKeySerializer } from "./serializer.js";
|
15
|
+
export * from "./pair.js";
|
16
|
+
export * from "./schemas.js";
|
17
|
+
export class ServiceProvider extends Providers.ServiceProvider {
|
35
18
|
constructor() {
|
36
19
|
super(...arguments);
|
37
20
|
_ServiceProvider_instances.add(this);
|
38
21
|
}
|
39
22
|
async register() {
|
40
23
|
this.app
|
41
|
-
.bind(
|
24
|
+
.bind(Identifiers.Cryptography.Identity.PublicKey.Size)
|
42
25
|
.toConstantValue(32)
|
43
|
-
.when(
|
26
|
+
.when(Selectors.anyAncestorOrTargetTaggedFirst("type", "wallet"));
|
44
27
|
this.app
|
45
|
-
.bind(
|
46
|
-
.to(
|
28
|
+
.bind(Identifiers.Cryptography.Identity.KeyPair.Factory)
|
29
|
+
.to(KeyPairFactory)
|
47
30
|
.inSingletonScope()
|
48
|
-
.when(
|
31
|
+
.when(Selectors.anyAncestorOrTargetTaggedFirst("type", "wallet"));
|
49
32
|
this.app
|
50
|
-
.bind(
|
51
|
-
.to(
|
33
|
+
.bind(Identifiers.Cryptography.Identity.PrivateKey.Factory)
|
34
|
+
.to(PrivateKeyFactory)
|
52
35
|
.inSingletonScope()
|
53
|
-
.when(
|
36
|
+
.when(Selectors.anyAncestorOrTargetTaggedFirst("type", "wallet"));
|
54
37
|
this.app
|
55
|
-
.bind(
|
56
|
-
.to(
|
38
|
+
.bind(Identifiers.Cryptography.Identity.PublicKey.Factory)
|
39
|
+
.to(PublicKeyFactory)
|
57
40
|
.inSingletonScope()
|
58
|
-
.when(
|
41
|
+
.when(Selectors.anyAncestorOrTargetTaggedFirst("type", "wallet"));
|
59
42
|
this.app
|
60
|
-
.bind(
|
61
|
-
.to(
|
43
|
+
.bind(Identifiers.Cryptography.Identity.PublicKey.Serializer)
|
44
|
+
.to(PublicKeySerializer)
|
62
45
|
.inSingletonScope()
|
63
|
-
.when(
|
46
|
+
.when(Selectors.anyAncestorOrTargetTaggedFirst("type", "wallet"));
|
64
47
|
__classPrivateFieldGet(this, _ServiceProvider_instances, "m", _ServiceProvider_registerSchemas).call(this);
|
65
48
|
}
|
66
|
-
requiredByWorker() {
|
67
|
-
return true;
|
68
|
-
}
|
69
49
|
}
|
70
|
-
exports.ServiceProvider = ServiceProvider;
|
71
50
|
_ServiceProvider_instances = new WeakSet(), _ServiceProvider_registerSchemas = function _ServiceProvider_registerSchemas() {
|
72
|
-
for (const schema of Object.values(
|
73
|
-
this.app.get(
|
51
|
+
for (const schema of Object.values(schemas)) {
|
52
|
+
this.app.get(Identifiers.Cryptography.Validator).addSchema(schema);
|
74
53
|
}
|
75
54
|
};
|
76
55
|
//# 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,EAAa,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE7C,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAEtD,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAE7B,MAAM,OAAO,eAAgB,SAAQ,SAAS,CAAC,eAAe;IAA9D;;;IAoCA,CAAC;IAnCO,KAAK,CAAC,QAAQ;QACpB,IAAI,C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AK,MAAM,MAAM,IAAI,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC;QAC7C,IAAI,CAAC,GAAG,CAAC,GAAG,CAA6B,WAAW,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IAChG,CAAC;AACF,CAAC"}
|
package/distribution/pair.d.ts
CHANGED
package/distribution/pair.js
CHANGED
@@ -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,42 +7,37 @@ 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
|
-
|
15
|
-
exports.KeyPairFactory = void 0;
|
16
|
-
const container_1 = require("@mainsail/container");
|
17
|
-
const contracts_1 = require("@mainsail/contracts");
|
18
|
-
const bcrypto_1 = require("bcrypto");
|
19
|
-
const wif_1 = __importDefault(require("wif"));
|
10
|
+
import { inject, injectable } from "@mainsail/container";
|
11
|
+
import { Contracts, Identifiers } from "@mainsail/contracts";
|
12
|
+
import { schnorr, SHA256 } from "bcrypto";
|
13
|
+
import WIF from "wif";
|
20
14
|
let KeyPairFactory = class KeyPairFactory {
|
21
15
|
async fromMnemonic(mnemonic) {
|
22
|
-
return this.fromPrivateKey(
|
16
|
+
return this.fromPrivateKey(SHA256.digest(Buffer.from(mnemonic, "utf8")));
|
23
17
|
}
|
24
18
|
async fromPrivateKey(privateKey) {
|
25
19
|
return {
|
26
20
|
compressed: true,
|
27
21
|
privateKey: privateKey.toString("hex"),
|
28
|
-
publicKey:
|
22
|
+
publicKey: schnorr.publicKeyCreate(privateKey).toString("hex"),
|
29
23
|
};
|
30
24
|
}
|
31
25
|
async fromWIF(wif) {
|
32
|
-
const decoded =
|
26
|
+
const decoded = WIF.decode(wif, this.configuration.get("network.wif"));
|
33
27
|
const privateKey = Buffer.from(decoded.privateKey);
|
34
28
|
return {
|
35
29
|
compressed: decoded.compressed,
|
36
30
|
privateKey: privateKey.toString("hex"),
|
37
|
-
publicKey:
|
31
|
+
publicKey: schnorr.publicKeyCreate(privateKey, decoded.compressed).toString("hex"),
|
38
32
|
};
|
39
33
|
}
|
40
34
|
};
|
41
|
-
exports.KeyPairFactory = KeyPairFactory;
|
42
35
|
__decorate([
|
43
|
-
|
36
|
+
inject(Identifiers.Cryptography.Configuration),
|
44
37
|
__metadata("design:type", Object)
|
45
38
|
], KeyPairFactory.prototype, "configuration", void 0);
|
46
|
-
|
47
|
-
|
39
|
+
KeyPairFactory = __decorate([
|
40
|
+
injectable()
|
48
41
|
], KeyPairFactory);
|
42
|
+
export { KeyPairFactory };
|
49
43
|
//# sourceMappingURL=pair.js.map
|
package/distribution/pair.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"pair.js","sourceRoot":"","sources":["../source/pair.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"pair.js","sourceRoot":"","sources":["../source/pair.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAC1C,OAAO,GAAG,MAAM,KAAK,CAAC;AAGf,IAAM,cAAc,GAApB,MAAM,cAAc;IAInB,KAAK,CAAC,YAAY,CAAC,QAAgB;QACzC,OAAO,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC;IAC1E,CAAC;IAEM,KAAK,CAAC,cAAc,CAAC,UAAkB;QAC7C,OAAO;YACN,UAAU,EAAE,IAAI;YAChB,UAAU,EAAE,UAAU,CAAC,QAAQ,CAAC,KAAK,CAAC;YACtC,SAAS,EAAE,OAAO,CAAC,eAAe,CAAC,UAAU,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC;SAC9D,CAAC;IACH,CAAC;IAEM,KAAK,CAAC,OAAO,CAAC,GAAW;QAC/B,MAAM,OAAO,GAAG,GAAG,CAAC,MAAM,CAAC,GAAG,EAAE,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC,CAAC;QACvE,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;QAEnD,OAAO;YACN,UAAU,EAAE,OAAO,CAAC,UAAU;YAC9B,UAAU,EAAE,UAAU,CAAC,QAAQ,CAAC,KAAK,CAAC;YACtC,SAAS,EAAE,OAAO,CAAC,eAAe,CAAC,UAAU,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC;SAClF,CAAC;IACH,CAAC;CACD,CAAA;AAxBiB;IADhB,MAAM,CAAC,WAAW,CAAC,YAAY,CAAC,aAAa,CAAC;;qDACiB;AAFpD,cAAc;IAD1B,UAAU,EAAE;GACA,cAAc,CA0B1B"}
|
package/distribution/private.js
CHANGED
@@ -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,10 +7,8 @@ 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
|
-
const container_1 = require("@mainsail/container");
|
14
|
-
const contracts_1 = require("@mainsail/contracts");
|
10
|
+
import { inject, injectable } from "@mainsail/container";
|
11
|
+
import { Contracts, Identifiers } from "@mainsail/contracts";
|
15
12
|
let PrivateKeyFactory = class PrivateKeyFactory {
|
16
13
|
async fromMnemonic(mnemonic) {
|
17
14
|
return (await this.keyPairFactory.fromMnemonic(mnemonic)).privateKey;
|
@@ -20,12 +17,12 @@ let PrivateKeyFactory = class PrivateKeyFactory {
|
|
20
17
|
return (await this.keyPairFactory.fromWIF(wif)).privateKey;
|
21
18
|
}
|
22
19
|
};
|
23
|
-
exports.PrivateKeyFactory = PrivateKeyFactory;
|
24
20
|
__decorate([
|
25
|
-
|
21
|
+
inject(Identifiers.Cryptography.Identity.KeyPair.Factory),
|
26
22
|
__metadata("design:type", Object)
|
27
23
|
], PrivateKeyFactory.prototype, "keyPairFactory", void 0);
|
28
|
-
|
29
|
-
|
24
|
+
PrivateKeyFactory = __decorate([
|
25
|
+
injectable()
|
30
26
|
], PrivateKeyFactory);
|
27
|
+
export { PrivateKeyFactory };
|
31
28
|
//# sourceMappingURL=private.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"private.js","sourceRoot":"","sources":["../source/private.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"private.js","sourceRoot":"","sources":["../source/private.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAGtD,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;IAItB,KAAK,CAAC,YAAY,CAAC,QAAgB;QACzC,OAAO,CAAC,MAAM,IAAI,CAAC,cAAc,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC;IACtE,CAAC;IAEM,KAAK,CAAC,OAAO,CAAC,GAAW;QAC/B,OAAO,CAAC,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,UAAU,CAAC;IAC5D,CAAC;CACD,CAAA;AATiB;IADhB,MAAM,CAAC,WAAW,CAAC,YAAY,CAAC,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC;;yDACQ;AAFtD,iBAAiB;IAD7B,UAAU,EAAE;GACA,iBAAiB,CAW7B"}
|
package/distribution/public.d.ts
CHANGED
package/distribution/public.js
CHANGED
@@ -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,12 +7,10 @@ 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
|
-
|
15
|
-
const utils_1 = require("@mainsail/utils");
|
16
|
-
const bcrypto_1 = require("bcrypto");
|
10
|
+
import { inject, injectable } from "@mainsail/container";
|
11
|
+
import { Contracts, Exceptions, Identifiers } from "@mainsail/contracts";
|
12
|
+
import { numberToHex } from "@mainsail/utils";
|
13
|
+
import { schnorr } from "bcrypto";
|
17
14
|
let PublicKeyFactory = class PublicKeyFactory {
|
18
15
|
async fromMnemonic(mnemonic) {
|
19
16
|
return (await this.keyPairFactory.fromMnemonic(mnemonic)).publicKey;
|
@@ -25,29 +22,29 @@ let PublicKeyFactory = class PublicKeyFactory {
|
|
25
22
|
const { min, publicKeys } = asset;
|
26
23
|
for (const publicKey of publicKeys) {
|
27
24
|
if (!this.verify(publicKey)) {
|
28
|
-
throw new
|
25
|
+
throw new Exceptions.PublicKeyError(publicKey);
|
29
26
|
}
|
30
27
|
}
|
31
28
|
if (min < 1 || min > publicKeys.length) {
|
32
|
-
throw new
|
29
|
+
throw new Exceptions.InvalidMultiSignatureAssetError();
|
33
30
|
}
|
34
|
-
const minKey = await this.fromMnemonic(
|
31
|
+
const minKey = await this.fromMnemonic(numberToHex(min));
|
35
32
|
const keys = [minKey, ...publicKeys];
|
36
|
-
return
|
33
|
+
return schnorr.publicKeyCombine(keys.map((publicKey) => Buffer.from(publicKey, "hex"))).toString("hex");
|
37
34
|
}
|
38
35
|
async verify(publicKey) {
|
39
|
-
return
|
36
|
+
return schnorr.publicKeyVerify(Buffer.from(publicKey, "hex"));
|
40
37
|
}
|
41
38
|
async aggregate(publicKeys) {
|
42
|
-
throw new
|
39
|
+
throw new Exceptions.NotImplemented(this.constructor.name, "aggregate");
|
43
40
|
}
|
44
41
|
};
|
45
|
-
exports.PublicKeyFactory = PublicKeyFactory;
|
46
42
|
__decorate([
|
47
|
-
|
43
|
+
inject(Identifiers.Cryptography.Identity.KeyPair.Factory),
|
48
44
|
__metadata("design:type", Object)
|
49
45
|
], PublicKeyFactory.prototype, "keyPairFactory", void 0);
|
50
|
-
|
51
|
-
|
46
|
+
PublicKeyFactory = __decorate([
|
47
|
+
injectable()
|
52
48
|
], PublicKeyFactory);
|
49
|
+
export { PublicKeyFactory };
|
53
50
|
//# sourceMappingURL=public.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"public.js","sourceRoot":"","sources":["../source/public.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"public.js","sourceRoot":"","sources":["../source/public.ts"],"names":[],"mappings":";;;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AAG,CAAC,CAAC,SAAiB,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IACjH,CAAC;IAEM,KAAK,CAAC,MAAM,CAAC,SAAiB;QACpC,OAAO,OAAO,CAAC,eAAe,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC,CAAC;IAC/D,CAAC;IAEM,KAAK,CAAC,SAAS,CAAC,UAAoB;QAC1C,MAAM,IAAI,UAAU,CAAC,cAAc,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;IACzE,CAAC;CACD,CAAA;AApCiB;IADhB,MAAM,CAAC,WAAW,CAAC,YAAY,CAAC,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC;;wDACQ;AAFtD,gBAAgB;IAD5B,UAAU,EAAE;GACA,gBAAgB,CAsC5B"}
|
package/distribution/schemas.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"schemas.js","sourceRoot":"","sources":["../source/schemas.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"schemas.js","sourceRoot":"","sources":["../source/schemas.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,OAAO,GAAG;IACtB,SAAS,EAAE;QACV,GAAG,EAAE,WAAW;QAChB,KAAK,EAAE,CAAC,EAAE,SAAS,EAAE,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;QAC1D,IAAI,EAAE,QAAQ;KACd;CACD,CAAC"}
|
@@ -1,4 +1,4 @@
|
|
1
|
-
/// <reference types="node" />
|
1
|
+
/// <reference types="node" resolution-mode="require"/>
|
2
2
|
import { Contracts } from "@mainsail/contracts";
|
3
3
|
import { ByteBuffer } from "@mainsail/utils";
|
4
4
|
export declare class PublicKeySerializer implements Contracts.Crypto.PublicKeySerializer {
|
@@ -1,13 +1,10 @@
|
|
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
|
-
exports.PublicKeySerializer = void 0;
|
10
|
-
const container_1 = require("@mainsail/container");
|
7
|
+
import { injectable } from "@mainsail/container";
|
11
8
|
let PublicKeySerializer = class PublicKeySerializer {
|
12
9
|
serialize(buffer, publicKey) {
|
13
10
|
buffer.writeBytes(Buffer.from(publicKey, "hex"));
|
@@ -16,8 +13,8 @@ let PublicKeySerializer = class PublicKeySerializer {
|
|
16
13
|
return buffer.readBytes(32);
|
17
14
|
}
|
18
15
|
};
|
19
|
-
|
20
|
-
|
21
|
-
(0, container_1.injectable)()
|
16
|
+
PublicKeySerializer = __decorate([
|
17
|
+
injectable()
|
22
18
|
], PublicKeySerializer);
|
19
|
+
export { PublicKeySerializer };
|
23
20
|
//# sourceMappingURL=serializer.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"serializer.js","sourceRoot":"","sources":["../source/serializer.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"serializer.js","sourceRoot":"","sources":["../source/serializer.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAK1C,IAAM,mBAAmB,GAAzB,MAAM,mBAAmB;IACxB,SAAS,CAAC,MAAkB,EAAE,SAAiB;QACrD,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC,CAAC;IAClD,CAAC;IAEM,WAAW,CAAC,MAAkB;QACpC,OAAO,MAAM,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;IAC7B,CAAC;CACD,CAAA;AARY,mBAAmB;IAD/B,UAAU,EAAE;GACA,mBAAmB,CAQ/B"}
|
package/package.json
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
{
|
2
2
|
"name": "@mainsail/crypto-key-pair-schnorr",
|
3
|
-
"version": "0.0.1-
|
3
|
+
"version": "0.0.1-evm.2",
|
4
4
|
"description": "Schnorr key derivation 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": [
|
@@ -12,18 +13,18 @@
|
|
12
13
|
"dependencies": {
|
13
14
|
"bcrypto": "5.5.2",
|
14
15
|
"wif": "^4.0.0",
|
15
|
-
"@mainsail/container": "0.0.1-
|
16
|
-
"@mainsail/contracts": "0.0.1-
|
17
|
-
"@mainsail/
|
18
|
-
"@mainsail/
|
16
|
+
"@mainsail/container": "0.0.1-evm.2",
|
17
|
+
"@mainsail/contracts": "0.0.1-evm.2",
|
18
|
+
"@mainsail/kernel": "0.0.1-evm.2",
|
19
|
+
"@mainsail/utils": "0.0.1-evm.2"
|
19
20
|
},
|
20
21
|
"devDependencies": {
|
21
22
|
"@types/wif": "^2.0.5",
|
22
23
|
"bip39": "3.1.0",
|
23
24
|
"uvu": "^0.5.6",
|
24
|
-
"@mainsail/crypto-config": "0.0.1-
|
25
|
-
"@mainsail/crypto-validation": "0.0.1-
|
26
|
-
"@mainsail/validation": "0.0.1-
|
25
|
+
"@mainsail/crypto-config": "0.0.1-evm.2",
|
26
|
+
"@mainsail/crypto-validation": "0.0.1-evm.2",
|
27
|
+
"@mainsail/validation": "0.0.1-evm.2"
|
27
28
|
},
|
28
29
|
"engines": {
|
29
30
|
"node": ">=20.x"
|
@@ -33,9 +34,10 @@
|
|
33
34
|
"build:watch": "pnpm run clean && tsc -w",
|
34
35
|
"clean": "del distribution",
|
35
36
|
"release": "pnpm publish --access public",
|
36
|
-
"test": "
|
37
|
+
"test": "pnpm run uvu source .test.ts",
|
37
38
|
"test:coverage": "c8 pnpm run test",
|
38
39
|
"test:coverage:html": "c8 -r html --all pnpm run test",
|
39
|
-
"test:file": "
|
40
|
+
"test:file": "pnpm run uvu source",
|
41
|
+
"uvu": "tsx --tsconfig ../../tsconfig.test.json ./node_modules/uvu/bin.js"
|
40
42
|
}
|
41
43
|
}
|