@prosopo/keyring 2.9.60 → 2.9.62
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/.turbo/turbo-build$colon$cjs.log +21 -19
- package/.turbo/turbo-build$colon$tsc.log +11 -11
- package/.turbo/turbo-build.log +23 -20
- package/CHANGELOG.md +18 -0
- package/dist/_virtual/_rolldown/runtime.js +3 -0
- package/dist/accounts/getPair.js +28 -38
- package/dist/accounts/getPair.test.d.ts +2 -0
- package/dist/accounts/getPair.test.d.ts.map +1 -0
- package/dist/accounts/getPair.test.js +86 -0
- package/dist/accounts/getPair.test.js.map +1 -0
- package/dist/accounts/index.js +1 -7
- package/dist/accounts/mnemonic.js +17 -13
- package/dist/accounts/mnemonic.test.d.ts +2 -0
- package/dist/accounts/mnemonic.test.d.ts.map +1 -0
- package/dist/accounts/mnemonic.test.js +64 -0
- package/dist/accounts/mnemonic.test.js.map +1 -0
- package/dist/accounts/testAccounts.js +36 -42
- package/dist/accounts/testAccounts.test.d.ts +2 -0
- package/dist/accounts/testAccounts.test.d.ts.map +1 -0
- package/dist/accounts/testAccounts.test.js +66 -0
- package/dist/accounts/testAccounts.test.js.map +1 -0
- package/dist/cjs/accounts/getPair.cjs +30 -40
- package/dist/cjs/accounts/index.cjs +8 -10
- package/dist/cjs/accounts/mnemonic.cjs +19 -14
- package/dist/cjs/accounts/testAccounts.cjs +36 -41
- package/dist/cjs/index.cjs +15 -18
- package/dist/cjs/keyring/index.cjs +5 -7
- package/dist/cjs/keyring/keyring.cjs +257 -266
- package/dist/cjs/keyring/pairs.cjs +23 -27
- package/dist/cjs/pair/decode.cjs +31 -29
- package/dist/cjs/pair/defaults.cjs +28 -28
- package/dist/cjs/pair/encode.cjs +14 -15
- package/dist/cjs/pair/index.cjs +191 -167
- package/dist/cjs/pair/toJson.cjs +8 -11
- package/dist/index.js +4 -15
- package/dist/keyring/index.js +2 -6
- package/dist/keyring/keyring.js +254 -265
- package/dist/keyring/keyring.test.d.ts +2 -0
- package/dist/keyring/keyring.test.d.ts.map +1 -0
- package/dist/keyring/keyring.test.js +239 -0
- package/dist/keyring/keyring.test.js.map +1 -0
- package/dist/keyring/pairs.js +22 -26
- package/dist/keyring/pairs.test.d.ts +2 -0
- package/dist/keyring/pairs.test.d.ts.map +1 -0
- package/dist/keyring/pairs.test.js +84 -0
- package/dist/keyring/pairs.test.js.map +1 -0
- package/dist/keyring/testing.test.d.ts +2 -0
- package/dist/keyring/testing.test.d.ts.map +1 -0
- package/dist/keyring/testing.test.js +97 -0
- package/dist/keyring/testing.test.js.map +1 -0
- package/dist/keyring.test-d.d.ts +2 -0
- package/dist/keyring.test-d.d.ts.map +1 -0
- package/dist/keyring.test-d.js +66 -0
- package/dist/keyring.test-d.js.map +1 -0
- package/dist/pair/decode.js +29 -29
- package/dist/pair/decode.spec.js +1 -1
- package/dist/pair/decode.spec.js.map +1 -1
- package/dist/pair/defaults.js +29 -30
- package/dist/pair/encode.js +14 -15
- package/dist/pair/encode.spec.js +1 -1
- package/dist/pair/encode.spec.js.map +1 -1
- package/dist/pair/index.js +188 -165
- package/dist/pair/nobody.test.d.ts +2 -0
- package/dist/pair/nobody.test.d.ts.map +1 -0
- package/dist/pair/nobody.test.js +77 -0
- package/dist/pair/nobody.test.js.map +1 -0
- package/dist/pair/toJson.js +8 -11
- package/dist/pair/toJson.spec.js +1 -1
- package/dist/pair/toJson.spec.js.map +1 -1
- package/package.json +8 -8
- package/src/accounts/getPair.test.ts +142 -0
- package/src/accounts/mnemonic.test.ts +103 -0
- package/src/accounts/testAccounts.test.ts +100 -0
- package/src/keyring/keyring.test.ts +373 -0
- package/src/keyring/pairs.test.ts +133 -0
- package/src/keyring/testing.test.ts +146 -0
- package/src/keyring.test-d.ts +134 -0
- package/src/pair/decode.spec.ts +3 -1
- package/src/pair/encode.spec.ts +9 -3
- package/src/pair/nobody.test.ts +127 -0
- package/src/pair/toJson.spec.ts +18 -12
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
1,
|
|
10
|
-
48,
|
|
11
|
-
5,
|
|
12
|
-
6,
|
|
13
|
-
3,
|
|
14
|
-
43,
|
|
15
|
-
101,
|
|
16
|
-
112,
|
|
17
|
-
4,
|
|
18
|
-
34,
|
|
19
|
-
4,
|
|
20
|
-
32
|
|
1
|
+
//#region src/pair/defaults.ts
|
|
2
|
+
/** public/secret section divider (generation 1-3, will change in 4, don't rely on value) */
|
|
3
|
+
var PAIR_DIV = new Uint8Array([
|
|
4
|
+
161,
|
|
5
|
+
35,
|
|
6
|
+
3,
|
|
7
|
+
33,
|
|
8
|
+
0
|
|
21
9
|
]);
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
10
|
+
/** public/secret start block (generation 1-3, will change in 4, don't rely on value) */
|
|
11
|
+
var PAIR_HDR = new Uint8Array([
|
|
12
|
+
48,
|
|
13
|
+
83,
|
|
14
|
+
2,
|
|
15
|
+
1,
|
|
16
|
+
1,
|
|
17
|
+
48,
|
|
18
|
+
5,
|
|
19
|
+
6,
|
|
20
|
+
3,
|
|
21
|
+
43,
|
|
22
|
+
101,
|
|
23
|
+
112,
|
|
24
|
+
4,
|
|
25
|
+
34,
|
|
26
|
+
4,
|
|
27
|
+
32
|
|
28
|
+
]);
|
|
29
|
+
//#endregion
|
|
26
30
|
exports.PAIR_DIV = PAIR_DIV;
|
|
27
31
|
exports.PAIR_HDR = PAIR_HDR;
|
|
28
|
-
exports.PUB_LENGTH = PUB_LENGTH;
|
|
29
|
-
exports.SALT_LENGTH = SALT_LENGTH;
|
|
30
|
-
exports.SEC_LENGTH = SEC_LENGTH;
|
|
31
|
-
exports.SEED_LENGTH = SEED_LENGTH;
|
package/dist/cjs/pair/encode.cjs
CHANGED
|
@@ -1,18 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
const require_defaults = require("./defaults.cjs");
|
|
2
|
+
let _prosopo_util_crypto = require("@prosopo/util-crypto");
|
|
3
|
+
let _polkadot_util = require("@polkadot/util");
|
|
4
|
+
//#region src/pair/encode.ts
|
|
5
|
+
/**
|
|
6
|
+
* Encode a pair with the latest generation format (generation 3)
|
|
7
|
+
**/
|
|
6
8
|
function encodePair({ publicKey, secretKey }, passphrase) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
const { params, password, salt } = utilCrypto.scryptEncode(passphrase);
|
|
15
|
-
const { encrypted, nonce } = utilCrypto.naclEncrypt(encoded, password.subarray(0, 32));
|
|
16
|
-
return util.u8aConcat(utilCrypto.scryptToU8a(salt, params), nonce, encrypted);
|
|
9
|
+
if (!secretKey) throw new Error("Expected a valid secretKey to be passed to encode");
|
|
10
|
+
const encoded = (0, _polkadot_util.u8aConcat)(require_defaults.PAIR_HDR, secretKey, require_defaults.PAIR_DIV, publicKey);
|
|
11
|
+
if (!passphrase) return encoded;
|
|
12
|
+
const { params, password, salt } = (0, _prosopo_util_crypto.scryptEncode)(passphrase);
|
|
13
|
+
const { encrypted, nonce } = (0, _prosopo_util_crypto.naclEncrypt)(encoded, password.subarray(0, 32));
|
|
14
|
+
return (0, _polkadot_util.u8aConcat)((0, _prosopo_util_crypto.scryptToU8a)(salt, params), nonce, encrypted);
|
|
17
15
|
}
|
|
16
|
+
//#endregion
|
|
18
17
|
exports.encodePair = encodePair;
|
package/dist/cjs/pair/index.cjs
CHANGED
|
@@ -1,177 +1,201 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
1
|
+
const require_decode = require("./decode.cjs");
|
|
2
|
+
const require_encode = require("./encode.cjs");
|
|
3
|
+
const require_toJson = require("./toJson.cjs");
|
|
4
|
+
let _prosopo_util_crypto = require("@prosopo/util-crypto");
|
|
5
|
+
let _polkadot_util = require("@polkadot/util");
|
|
6
|
+
//#region src/pair/index.ts
|
|
7
|
+
var SIG_TYPE_NONE = new Uint8Array([]);
|
|
8
|
+
var TYPE_FROM_SEED = {
|
|
9
|
+
sr25519: _prosopo_util_crypto.sr25519FromSeed,
|
|
10
|
+
ed25519: () => {
|
|
11
|
+
throw new Error("Not Implemented");
|
|
12
|
+
},
|
|
13
|
+
ecdsa: () => {
|
|
14
|
+
throw new Error("Not Implemented");
|
|
15
|
+
},
|
|
16
|
+
ethereum: () => {
|
|
17
|
+
throw new Error("Not Implemented");
|
|
18
|
+
}
|
|
20
19
|
};
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
20
|
+
var TYPE_PREFIX = {
|
|
21
|
+
ecdsa: new Uint8Array([2]),
|
|
22
|
+
ed25519: new Uint8Array([0]),
|
|
23
|
+
ethereum: new Uint8Array([2]),
|
|
24
|
+
sr25519: new Uint8Array([1])
|
|
26
25
|
};
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
26
|
+
var TYPE_SIGNATURE = {
|
|
27
|
+
sr25519: _prosopo_util_crypto.sr25519Sign,
|
|
28
|
+
ed25519: () => {
|
|
29
|
+
throw new Error("Not Implemented");
|
|
30
|
+
},
|
|
31
|
+
ecdsa: () => {
|
|
32
|
+
throw new Error("Not Implemented");
|
|
33
|
+
},
|
|
34
|
+
ethereum: () => {
|
|
35
|
+
throw new Error("Not Implemented");
|
|
36
|
+
}
|
|
38
37
|
};
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
38
|
+
var TYPE_JWT_ISSUE = {
|
|
39
|
+
sr25519: _prosopo_util_crypto.sr25519jwtIssue,
|
|
40
|
+
ed25519: () => {
|
|
41
|
+
throw new Error("Not Implemented");
|
|
42
|
+
},
|
|
43
|
+
ecdsa: () => {
|
|
44
|
+
throw new Error("Not Implemented");
|
|
45
|
+
},
|
|
46
|
+
ethereum: () => {
|
|
47
|
+
throw new Error("Not Implemented");
|
|
48
|
+
}
|
|
50
49
|
};
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
50
|
+
var TYPE_ADDRESS = {
|
|
51
|
+
sr25519: (p) => p,
|
|
52
|
+
ed25519: () => {
|
|
53
|
+
throw new Error("Not Implemented");
|
|
54
|
+
},
|
|
55
|
+
ecdsa: () => {
|
|
56
|
+
throw new Error("Not Implemented");
|
|
57
|
+
},
|
|
58
|
+
ethereum: () => {
|
|
59
|
+
throw new Error("Not Implemented");
|
|
60
|
+
}
|
|
62
61
|
};
|
|
63
62
|
function isLocked(secretKey) {
|
|
64
|
-
|
|
65
|
-
}
|
|
66
|
-
function vrfHash(proof, context, extra) {
|
|
67
|
-
return utilCrypto.blake2AsU8a(util.u8aConcat(context || "", extra || "", proof));
|
|
63
|
+
return !secretKey || (0, _polkadot_util.u8aEmpty)(secretKey);
|
|
68
64
|
}
|
|
65
|
+
/**
|
|
66
|
+
* @name createPair
|
|
67
|
+
* @summary Creates a keyring pair object
|
|
68
|
+
* @description Creates a keyring pair object with provided account public key, metadata, and encoded arguments.
|
|
69
|
+
* The keyring pair stores the account state including the encoded address and associated metadata.
|
|
70
|
+
*
|
|
71
|
+
* It has properties whose values are functions that may be called to perform account actions:
|
|
72
|
+
*
|
|
73
|
+
* - `address` function retrieves the address associated with the account.
|
|
74
|
+
* - `decodedPkcs8` function is called with the account passphrase and account encoded public key.
|
|
75
|
+
* It decodes the encoded public key using the passphrase provided to obtain the decoded account public key
|
|
76
|
+
* and associated secret key that are then available in memory, and changes the account address stored in the
|
|
77
|
+
* state of the pair to correspond to the address of the decoded public key.
|
|
78
|
+
* - `encodePkcs8` function when provided with the correct passphrase associated with the account pair
|
|
79
|
+
* and when the secret key is in memory (when the account pair is not locked) it returns an encoded
|
|
80
|
+
* public key of the account.
|
|
81
|
+
* - `meta` is the metadata that is stored in the state of the pair, either when it was originally
|
|
82
|
+
* created or set via `setMeta`.
|
|
83
|
+
* - `publicKey` returns the public key stored in memory for the pair.
|
|
84
|
+
* - `sign` may be used to return a signature by signing a provided message with the secret
|
|
85
|
+
* key (if it is in memory) using Nacl.
|
|
86
|
+
* - `toJson` calls another `toJson` function and provides the state of the pair,
|
|
87
|
+
* it generates arguments to be passed to the other `toJson` function including an encoded public key of the account
|
|
88
|
+
* that it generates using the secret key from memory (if it has been made available in memory)
|
|
89
|
+
* and the optionally provided passphrase argument. It passes a third boolean argument to `toJson`
|
|
90
|
+
* indicating whether the public key has been encoded or not (if a passphrase argument was provided then it is encoded).
|
|
91
|
+
* The `toJson` function that it calls returns a JSON object with properties including the `address`
|
|
92
|
+
* and `meta` that are assigned with the values stored in the corresponding state variables of the account pair,
|
|
93
|
+
* an `encoded` property that is assigned with the encoded public key in hex format, and an `encoding`
|
|
94
|
+
* property that indicates whether the public key value of the `encoded` property is encoded or not.
|
|
95
|
+
*/
|
|
69
96
|
function createPair({ toSS58, type }, { publicKey, secretKey }, meta = {}, encoded = null, encTypes) {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
vrfVerify: (message, vrfResult, signerPublic, context, extra) => {
|
|
173
|
-
return utilCrypto.sr25519VrfVerify(message, vrfResult, publicKey, context, extra);
|
|
174
|
-
}
|
|
175
|
-
};
|
|
97
|
+
const decodePkcs8 = (passphrase, userEncoded) => {
|
|
98
|
+
const decoded = require_decode.decodePair(passphrase, userEncoded || encoded, encTypes);
|
|
99
|
+
if (decoded.secretKey.length === 64) {
|
|
100
|
+
publicKey = decoded.publicKey;
|
|
101
|
+
secretKey = decoded.secretKey;
|
|
102
|
+
} else {
|
|
103
|
+
const pair = TYPE_FROM_SEED[type](decoded.secretKey);
|
|
104
|
+
publicKey = pair.publicKey;
|
|
105
|
+
secretKey = pair.secretKey;
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
const recode = (passphrase) => {
|
|
109
|
+
isLocked(secretKey) && encoded && decodePkcs8(passphrase, encoded);
|
|
110
|
+
encoded = require_encode.encodePair({
|
|
111
|
+
publicKey,
|
|
112
|
+
secretKey
|
|
113
|
+
}, passphrase);
|
|
114
|
+
encTypes = void 0;
|
|
115
|
+
return encoded;
|
|
116
|
+
};
|
|
117
|
+
const encodeAddress = () => {
|
|
118
|
+
return toSS58(TYPE_ADDRESS[type](publicKey));
|
|
119
|
+
};
|
|
120
|
+
return {
|
|
121
|
+
get address() {
|
|
122
|
+
return encodeAddress();
|
|
123
|
+
},
|
|
124
|
+
get addressRaw() {
|
|
125
|
+
return TYPE_ADDRESS[type](publicKey);
|
|
126
|
+
},
|
|
127
|
+
get isLocked() {
|
|
128
|
+
return isLocked(secretKey);
|
|
129
|
+
},
|
|
130
|
+
get meta() {
|
|
131
|
+
return meta;
|
|
132
|
+
},
|
|
133
|
+
get publicKey() {
|
|
134
|
+
return publicKey;
|
|
135
|
+
},
|
|
136
|
+
get type() {
|
|
137
|
+
return type;
|
|
138
|
+
},
|
|
139
|
+
decodePkcs8,
|
|
140
|
+
derive: (suri, meta) => {
|
|
141
|
+
if (isLocked(secretKey)) throw new Error("Cannot derive on a locked keypair");
|
|
142
|
+
const { path } = (0, _prosopo_util_crypto.keyExtractPath)(suri);
|
|
143
|
+
const derived = (0, _prosopo_util_crypto.keyFromPath)({
|
|
144
|
+
publicKey,
|
|
145
|
+
secretKey
|
|
146
|
+
}, path, type);
|
|
147
|
+
return createPair({
|
|
148
|
+
toSS58,
|
|
149
|
+
type
|
|
150
|
+
}, derived, meta, null);
|
|
151
|
+
},
|
|
152
|
+
encodePkcs8: (passphrase) => {
|
|
153
|
+
return recode(passphrase);
|
|
154
|
+
},
|
|
155
|
+
jwtIssue: (options, message) => {
|
|
156
|
+
if (isLocked(secretKey)) throw new Error("Cannot sign with a locked key pair");
|
|
157
|
+
return TYPE_JWT_ISSUE[type]({
|
|
158
|
+
publicKey,
|
|
159
|
+
secretKey
|
|
160
|
+
}, options, message);
|
|
161
|
+
},
|
|
162
|
+
jwtVerify: (jwt) => {
|
|
163
|
+
return (0, _prosopo_util_crypto.jwtVerify)(jwt, publicKey);
|
|
164
|
+
},
|
|
165
|
+
lock: () => {
|
|
166
|
+
secretKey = new Uint8Array([]);
|
|
167
|
+
},
|
|
168
|
+
setMeta: (additional) => {
|
|
169
|
+
meta = (0, _polkadot_util.objectSpread)({}, meta, additional);
|
|
170
|
+
},
|
|
171
|
+
sign: (message, options = {}) => {
|
|
172
|
+
if (isLocked(secretKey)) throw new Error("Cannot sign with a locked key pair");
|
|
173
|
+
return (0, _polkadot_util.u8aConcat)(options.withType ? TYPE_PREFIX[type] : SIG_TYPE_NONE, TYPE_SIGNATURE[type]((0, _polkadot_util.u8aToU8a)(message), {
|
|
174
|
+
publicKey,
|
|
175
|
+
secretKey
|
|
176
|
+
}));
|
|
177
|
+
},
|
|
178
|
+
toJson: (passphrase) => {
|
|
179
|
+
const address = ["ecdsa", "ethereum"].includes(type) ? publicKey.length === 20 ? (0, _polkadot_util.u8aToHex)(publicKey) : (0, _polkadot_util.u8aToHex)((0, _prosopo_util_crypto.secp256k1Compress)(publicKey)) : encodeAddress();
|
|
180
|
+
return require_toJson.pairToJson(type, {
|
|
181
|
+
address,
|
|
182
|
+
meta
|
|
183
|
+
}, recode(passphrase), !!passphrase);
|
|
184
|
+
},
|
|
185
|
+
unlock: (passphrase) => {
|
|
186
|
+
decodePkcs8(passphrase);
|
|
187
|
+
},
|
|
188
|
+
verify: (message, signature, signerPublic) => {
|
|
189
|
+
return (0, _prosopo_util_crypto.signatureVerify)(message, signature, TYPE_ADDRESS[type]((0, _polkadot_util.u8aToU8a)(signerPublic))).isValid;
|
|
190
|
+
},
|
|
191
|
+
vrfSign: (message, context, extra) => {
|
|
192
|
+
if (isLocked(secretKey)) throw new Error("Cannot sign with a locked key pair");
|
|
193
|
+
return (0, _prosopo_util_crypto.sr25519VrfSign)(message, { secretKey }, context, extra);
|
|
194
|
+
},
|
|
195
|
+
vrfVerify: (message, vrfResult, signerPublic, context, extra) => {
|
|
196
|
+
return (0, _prosopo_util_crypto.sr25519VrfVerify)(message, vrfResult, publicKey, context, extra);
|
|
197
|
+
}
|
|
198
|
+
};
|
|
176
199
|
}
|
|
200
|
+
//#endregion
|
|
177
201
|
exports.createPair = createPair;
|
package/dist/cjs/pair/toJson.cjs
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const utilCrypto = require("@prosopo/util-crypto");
|
|
1
|
+
let _prosopo_util_crypto = require("@prosopo/util-crypto");
|
|
2
|
+
let _polkadot_util = require("@polkadot/util");
|
|
3
|
+
//#region src/pair/toJson.ts
|
|
5
4
|
function pairToJson(type, { address, meta }, encoded, isEncrypted) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
meta
|
|
11
|
-
}
|
|
12
|
-
);
|
|
5
|
+
return (0, _polkadot_util.objectSpread)((0, _prosopo_util_crypto.jsonEncryptFormat)(encoded, ["pkcs8", type], isEncrypted), {
|
|
6
|
+
address,
|
|
7
|
+
meta
|
|
8
|
+
});
|
|
13
9
|
}
|
|
10
|
+
//#endregion
|
|
14
11
|
exports.pairToJson = pairToJson;
|
package/dist/index.js
CHANGED
|
@@ -1,19 +1,8 @@
|
|
|
1
|
-
import "./
|
|
2
|
-
import "./keyring/index.js";
|
|
1
|
+
import "./_virtual/_rolldown/runtime.js";
|
|
3
2
|
import { createPair } from "./pair/index.js";
|
|
3
|
+
import { Pairs } from "./keyring/pairs.js";
|
|
4
|
+
import { DEV_PHRASE, Keyring } from "./keyring/keyring.js";
|
|
4
5
|
import { generateMiniSecret, generateMnemonic } from "./accounts/mnemonic.js";
|
|
5
6
|
import { getPair } from "./accounts/getPair.js";
|
|
6
7
|
import { getDefaultProviders, getDefaultSiteKeys } from "./accounts/testAccounts.js";
|
|
7
|
-
|
|
8
|
-
import { Pairs } from "./keyring/pairs.js";
|
|
9
|
-
export {
|
|
10
|
-
DEV_PHRASE,
|
|
11
|
-
Keyring,
|
|
12
|
-
Pairs,
|
|
13
|
-
createPair,
|
|
14
|
-
generateMiniSecret,
|
|
15
|
-
generateMnemonic,
|
|
16
|
-
getDefaultProviders,
|
|
17
|
-
getDefaultSiteKeys,
|
|
18
|
-
getPair
|
|
19
|
-
};
|
|
8
|
+
export { DEV_PHRASE, Keyring, Pairs, createPair, generateMiniSecret, generateMnemonic, getDefaultProviders, getDefaultSiteKeys, getPair };
|
package/dist/keyring/index.js
CHANGED