@ocap/mcrypto 1.27.16 → 1.28.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/esm/crypter/aes-legacy.d.ts +8 -6
- package/esm/crypter/aes-legacy.js +27 -24
- package/esm/crypter/aes.d.ts +9 -7
- package/esm/crypter/aes.js +27 -25
- package/esm/crypter/rsa-browserify.d.ts +7 -6
- package/esm/crypter/rsa-browserify.js +34 -31
- package/esm/crypter/rsa.d.ts +11 -9
- package/esm/crypter/rsa.js +31 -28
- package/esm/encode.d.ts +12 -8
- package/esm/encode.js +13 -18
- package/esm/hasher/keccak.d.ts +8 -5
- package/esm/hasher/keccak.js +37 -36
- package/esm/hasher/sha2.d.ts +8 -5
- package/esm/hasher/sha2.js +42 -40
- package/esm/hasher/sha3.d.ts +8 -5
- package/esm/hasher/sha3.js +37 -36
- package/esm/index.d.ts +148 -143
- package/esm/index.js +172 -209
- package/esm/protocols/crypter.d.ts +3 -1
- package/esm/protocols/crypter.js +7 -4
- package/esm/protocols/hasher.d.ts +3 -1
- package/esm/protocols/hasher.js +7 -4
- package/esm/protocols/signer.d.ts +3 -1
- package/esm/protocols/signer.js +7 -4
- package/esm/signer/ed25519.d.ts +49 -46
- package/esm/signer/ed25519.js +80 -80
- package/esm/signer/ethereum.d.ts +11 -8
- package/esm/signer/ethereum.js +34 -34
- package/esm/signer/passkey.d.ts +21 -18
- package/esm/signer/passkey.js +49 -58
- package/esm/signer/secp256k1.d.ts +35 -32
- package/esm/signer/secp256k1.js +80 -93
- package/lib/_virtual/rolldown_runtime.js +29 -0
- package/lib/crypter/aes-legacy.d.ts +8 -6
- package/lib/crypter/aes-legacy.js +35 -52
- package/lib/crypter/aes.d.ts +9 -7
- package/lib/crypter/aes.js +29 -29
- package/lib/crypter/rsa-browserify.d.ts +7 -6
- package/lib/crypter/rsa-browserify.js +36 -33
- package/lib/crypter/rsa.d.ts +11 -9
- package/lib/crypter/rsa.js +33 -32
- package/lib/encode.d.ts +12 -8
- package/lib/encode.js +14 -21
- package/lib/hasher/keccak.d.ts +8 -5
- package/lib/hasher/keccak.js +40 -41
- package/lib/hasher/sha2.d.ts +8 -5
- package/lib/hasher/sha2.js +43 -42
- package/lib/hasher/sha3.d.ts +8 -5
- package/lib/hasher/sha3.js +40 -41
- package/lib/index.d.ts +148 -143
- package/lib/index.js +177 -216
- package/lib/protocols/crypter.d.ts +3 -1
- package/lib/protocols/crypter.js +10 -9
- package/lib/protocols/hasher.d.ts +3 -1
- package/lib/protocols/hasher.js +10 -9
- package/lib/protocols/signer.d.ts +3 -1
- package/lib/protocols/signer.js +10 -9
- package/lib/signer/ed25519.d.ts +49 -46
- package/lib/signer/ed25519.js +85 -86
- package/lib/signer/ethereum.d.ts +11 -8
- package/lib/signer/ethereum.js +38 -39
- package/lib/signer/passkey.d.ts +21 -18
- package/lib/signer/passkey.js +51 -63
- package/lib/signer/secp256k1.d.ts +35 -32
- package/lib/signer/secp256k1.js +85 -99
- package/package.json +21 -10
package/esm/index.js
CHANGED
|
@@ -1,220 +1,183 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
1
|
+
import { encode } from "./encode.js";
|
|
2
|
+
import keccak_default from "./hasher/keccak.js";
|
|
3
|
+
import sha2_default from "./hasher/sha2.js";
|
|
4
|
+
import sha3_default from "./hasher/sha3.js";
|
|
5
|
+
import ed25519_default from "./signer/ed25519.js";
|
|
6
|
+
import secp256k1_default from "./signer/secp256k1.js";
|
|
7
|
+
import ethereum_default from "./signer/ethereum.js";
|
|
8
|
+
import passkey_default from "./signer/passkey.js";
|
|
9
|
+
import randomBytes from "randombytes";
|
|
10
|
+
|
|
11
|
+
//#region src/index.ts
|
|
10
12
|
/**
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
13
|
+
* Contains all supported signers, eg: `Ed25519` and `Secp256k1`
|
|
14
|
+
*
|
|
15
|
+
* @readonly
|
|
16
|
+
* @type {object}
|
|
17
|
+
* @name Signer
|
|
18
|
+
* @static
|
|
19
|
+
* @example
|
|
20
|
+
* const { Signer } = require('@ocap/mcrypto');
|
|
21
|
+
* const message = 'some message to sign';
|
|
22
|
+
*
|
|
23
|
+
* // Use Signer directly
|
|
24
|
+
* const keyPair = Signer.Ed25519.genKeyPair();
|
|
25
|
+
* const signature = Signer.Ed25519.sign(message, keyPair.secretKey);
|
|
26
|
+
* const result = Signer.Ed25519.verify(message, signature, keyPair.publicKey);
|
|
27
|
+
* assert.ok(result);
|
|
28
|
+
*/
|
|
29
|
+
const Signer = {
|
|
30
|
+
Ed25519: ed25519_default,
|
|
31
|
+
Secp256k1: secp256k1_default,
|
|
32
|
+
Ethereum: ethereum_default,
|
|
33
|
+
Passkey: passkey_default
|
|
32
34
|
};
|
|
33
35
|
/**
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
36
|
+
* Contains all supported hasher, eg: `SHA2`,`SHA3` and `Keccak`, each of them supports `hash224`, `hash256`, `hash384`, `hash512`
|
|
37
|
+
*
|
|
38
|
+
* @readonly
|
|
39
|
+
* @type {object}
|
|
40
|
+
* @name Hasher
|
|
41
|
+
* @static
|
|
42
|
+
* @example
|
|
43
|
+
* const { Hasher } = require('@ocap/mcrypto');
|
|
44
|
+
*
|
|
45
|
+
* const message = 'message to hash';
|
|
46
|
+
* const hash = Hasher.SHA2.hash256(message);
|
|
47
|
+
*/
|
|
48
|
+
const Hasher = {
|
|
49
|
+
SHA2: sha2_default,
|
|
50
|
+
SHA3: sha3_default,
|
|
51
|
+
Keccak: keccak_default
|
|
50
52
|
};
|
|
51
53
|
/**
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
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
|
-
ROLE_APPLICATION: 3,
|
|
115
|
-
ROLE_SMART_CONTRACT: 4,
|
|
116
|
-
ROLE_BOT: 5,
|
|
117
|
-
ROLE_ASSET: 6,
|
|
118
|
-
ROLE_STAKE: 7,
|
|
119
|
-
ROLE_VALIDATOR: 8,
|
|
120
|
-
ROLE_GROUP: 9,
|
|
121
|
-
ROLE_TX: 10,
|
|
122
|
-
ROLE_TETHER: 11,
|
|
123
|
-
ROLE_SWAP: 12,
|
|
124
|
-
ROLE_DELEGATION: 13,
|
|
125
|
-
ROLE_VC: 14,
|
|
126
|
-
ROLE_BLOCKLET: 15,
|
|
127
|
-
ROLE_STORE: 16,
|
|
128
|
-
ROLE_TOKEN: 17,
|
|
129
|
-
ROLE_FACTORY: 18,
|
|
130
|
-
ROLE_ROLLUP: 19,
|
|
131
|
-
ROLE_STORAGE: 20,
|
|
132
|
-
ROLE_PROFILE: 21,
|
|
133
|
-
ROLE_PASSKEY: 22,
|
|
134
|
-
ROLE_TOKEN_FACTORY: 23,
|
|
135
|
-
ROLE_ANY: 63,
|
|
136
|
-
},
|
|
137
|
-
/**
|
|
138
|
-
* Address encoding algorithm, defaults to `base58btc`
|
|
139
|
-
*
|
|
140
|
-
* @readonly
|
|
141
|
-
* @enum {number}
|
|
142
|
-
* @name types.RoleType
|
|
143
|
-
* @memberof types
|
|
144
|
-
* @static
|
|
145
|
-
*/
|
|
146
|
-
EncodingType: {
|
|
147
|
-
BASE16: 0,
|
|
148
|
-
BASE58: 1,
|
|
149
|
-
},
|
|
54
|
+
* Contains type constants that represent can be used to compose different crypto method, each crypto method consist one of:
|
|
55
|
+
* FIXME: enum definition of forge-abi and abt-did-elixir are not exactly the same
|
|
56
|
+
*
|
|
57
|
+
* @readonly
|
|
58
|
+
* @type {object}
|
|
59
|
+
* @name types
|
|
60
|
+
* @static
|
|
61
|
+
* @example
|
|
62
|
+
* const { types } = require('@ocap/mcrypto');
|
|
63
|
+
*
|
|
64
|
+
* // types.RoleType.ROLE_ACCOUNT
|
|
65
|
+
* // types.KeyType.ED25519
|
|
66
|
+
* // types.HashType.SHA3
|
|
67
|
+
* // types.EncodingType.BASE58
|
|
68
|
+
*/
|
|
69
|
+
const types = {
|
|
70
|
+
KeyType: {
|
|
71
|
+
ED25519: 0,
|
|
72
|
+
SECP256K1: 1,
|
|
73
|
+
ETHEREUM: 2,
|
|
74
|
+
PASSKEY: 3
|
|
75
|
+
},
|
|
76
|
+
HashType: {
|
|
77
|
+
KECCAK: 0,
|
|
78
|
+
SHA3: 1,
|
|
79
|
+
KECCAK_384: 2,
|
|
80
|
+
SHA3_384: 3,
|
|
81
|
+
KECCAK_512: 4,
|
|
82
|
+
SHA3_512: 5,
|
|
83
|
+
SHA2: 6
|
|
84
|
+
},
|
|
85
|
+
RoleType: {
|
|
86
|
+
ROLE_ACCOUNT: 0,
|
|
87
|
+
ROLE_NODE: 1,
|
|
88
|
+
ROLE_DEVICE: 2,
|
|
89
|
+
ROLE_APPLICATION: 3,
|
|
90
|
+
ROLE_SMART_CONTRACT: 4,
|
|
91
|
+
ROLE_BOT: 5,
|
|
92
|
+
ROLE_ASSET: 6,
|
|
93
|
+
ROLE_STAKE: 7,
|
|
94
|
+
ROLE_VALIDATOR: 8,
|
|
95
|
+
ROLE_GROUP: 9,
|
|
96
|
+
ROLE_TX: 10,
|
|
97
|
+
ROLE_TETHER: 11,
|
|
98
|
+
ROLE_SWAP: 12,
|
|
99
|
+
ROLE_DELEGATION: 13,
|
|
100
|
+
ROLE_VC: 14,
|
|
101
|
+
ROLE_BLOCKLET: 15,
|
|
102
|
+
ROLE_STORE: 16,
|
|
103
|
+
ROLE_TOKEN: 17,
|
|
104
|
+
ROLE_FACTORY: 18,
|
|
105
|
+
ROLE_ROLLUP: 19,
|
|
106
|
+
ROLE_STORAGE: 20,
|
|
107
|
+
ROLE_PROFILE: 21,
|
|
108
|
+
ROLE_PASSKEY: 22,
|
|
109
|
+
ROLE_TOKEN_FACTORY: 23,
|
|
110
|
+
ROLE_ANY: 63
|
|
111
|
+
},
|
|
112
|
+
EncodingType: {
|
|
113
|
+
BASE16: 0,
|
|
114
|
+
BASE58: 1
|
|
115
|
+
}
|
|
150
116
|
};
|
|
151
117
|
/**
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
118
|
+
* Get signer instance
|
|
119
|
+
*
|
|
120
|
+
* @function
|
|
121
|
+
* @param {number} type - algorithm used to derive key pair, possible values are
|
|
122
|
+
* - types.KeyType.ED25519
|
|
123
|
+
* - types.KeyType.SECP256k1
|
|
124
|
+
* - types.KeyType.ETHEREUM
|
|
125
|
+
* @returns {object} signer instance
|
|
126
|
+
* @example
|
|
127
|
+
* const { getSigner, types } = require('@ocap/mcrypto');
|
|
128
|
+
* const message = 'some message to sign';
|
|
129
|
+
*
|
|
130
|
+
* const signer = getSigner(types.KeyType.ED25519);
|
|
131
|
+
* const keyPair1 = signer.genKeyPair();
|
|
132
|
+
* const signature1 = signer.sign(message, keyPair1.secretKey);
|
|
133
|
+
* const result1 = signer.verify(message, signature1, keyPair1.publicKey);
|
|
134
|
+
* assert.ok(result1);
|
|
135
|
+
*/
|
|
136
|
+
function getSigner(type) {
|
|
137
|
+
const Signers = Object.freeze({
|
|
138
|
+
[types.KeyType.ED25519]: Signer.Ed25519,
|
|
139
|
+
[types.KeyType.SECP256K1]: Signer.Secp256k1,
|
|
140
|
+
[types.KeyType.ETHEREUM]: Signer.Ethereum,
|
|
141
|
+
[types.KeyType.PASSKEY]: Signer.Passkey
|
|
142
|
+
});
|
|
143
|
+
if (typeof Signers[type] === "undefined") throw new Error(`Unsupported signer type: ${type}`);
|
|
144
|
+
return Signers[type];
|
|
176
145
|
}
|
|
177
146
|
/**
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
147
|
+
* Get hasher instance
|
|
148
|
+
*
|
|
149
|
+
* @function
|
|
150
|
+
* @param {number} type - algorithm used to hash data, possible values
|
|
151
|
+
* - types.HashType.KECCAK
|
|
152
|
+
* - types.HashType.KECCAK_384
|
|
153
|
+
* - types.HashType.KECCAK_512
|
|
154
|
+
* - types.HashType.SHA3
|
|
155
|
+
* - types.HashType.SHA3_384
|
|
156
|
+
* - types.HashType.SHA3_512
|
|
157
|
+
* @returns {object} hasher instance
|
|
158
|
+
* @example
|
|
159
|
+
* const { getHasher, types } = require('@ocap/mcrypto');
|
|
160
|
+
*
|
|
161
|
+
* const hashFn = getHasher(types.HashType.SHA3);
|
|
162
|
+
* const hash2 = hashFn(message);
|
|
163
|
+
*/
|
|
164
|
+
function getHasher(type) {
|
|
165
|
+
const Hashers = Object.freeze({
|
|
166
|
+
[types.HashType.KECCAK]: Hasher.Keccak.hash256,
|
|
167
|
+
[types.HashType.KECCAK_384]: Hasher.Keccak.hash384,
|
|
168
|
+
[types.HashType.KECCAK_512]: Hasher.Keccak.hash512,
|
|
169
|
+
[types.HashType.SHA3]: Hasher.SHA3.hash256,
|
|
170
|
+
[types.HashType.SHA3_384]: Hasher.SHA3.hash384,
|
|
171
|
+
[types.HashType.SHA3_512]: Hasher.SHA3.hash512,
|
|
172
|
+
[types.HashType.SHA2]: Hasher.SHA2.hash256
|
|
173
|
+
});
|
|
174
|
+
if (typeof Hashers[type] === "undefined") throw new Error(`Unsupported hash type: ${type}`);
|
|
175
|
+
return Hashers[type];
|
|
201
176
|
}
|
|
202
|
-
|
|
203
|
-
|
|
177
|
+
function getRandomBytes(length = 32, encoding = "hex") {
|
|
178
|
+
return encode(randomBytes(length), encoding);
|
|
204
179
|
}
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
[types.KeyType.PASSKEY]: Signer.Passkey,
|
|
210
|
-
});
|
|
211
|
-
export const Hashers = Object.freeze({
|
|
212
|
-
[types.HashType.KECCAK]: Hasher.Keccak.hash256,
|
|
213
|
-
[types.HashType.KECCAK_384]: Hasher.Keccak.hash384,
|
|
214
|
-
[types.HashType.KECCAK_512]: Hasher.Keccak.hash512,
|
|
215
|
-
[types.HashType.SHA3]: Hasher.SHA3.hash256,
|
|
216
|
-
[types.HashType.SHA3_384]: Hasher.SHA3.hash384,
|
|
217
|
-
[types.HashType.SHA3_512]: Hasher.SHA3.hash512,
|
|
218
|
-
[types.HashType.SHA2]: Hasher.SHA2.hash256,
|
|
219
|
-
});
|
|
220
|
-
export const toTxHash = (buf) => Hasher.SHA2.hash256(buf, 1, 'hex').replace(/^0x/, '').toUpperCase();
|
|
180
|
+
const toTxHash = (buf) => Hasher.SHA2.hash256(buf, 1, "hex").replace(/^0x/, "").toUpperCase();
|
|
181
|
+
|
|
182
|
+
//#endregion
|
|
183
|
+
export { Hasher, Signer, getHasher, getRandomBytes, getSigner, toTxHash, types };
|
package/esm/protocols/crypter.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import Interface from "interface";
|
|
2
|
+
|
|
3
|
+
//#region src/protocols/crypter.ts
|
|
4
|
+
var crypter_default = Interface.create("encrypt", "decrypt");
|
|
5
|
+
|
|
6
|
+
//#endregion
|
|
7
|
+
export { crypter_default as default };
|
package/esm/protocols/hasher.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import Interface from "interface";
|
|
2
|
+
|
|
3
|
+
//#region src/protocols/hasher.ts
|
|
4
|
+
var hasher_default = Interface.create("sha224", "sha256", "sha384", "sha512");
|
|
5
|
+
|
|
6
|
+
//#endregion
|
|
7
|
+
export { hasher_default as default };
|
package/esm/protocols/signer.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import Interface from "interface";
|
|
2
|
+
|
|
3
|
+
//#region src/protocols/signer.ts
|
|
4
|
+
var signer_default = Interface.create("genKeyPair", "getPublicKey", "sign", "verify");
|
|
5
|
+
|
|
6
|
+
//#endregion
|
|
7
|
+
export { signer_default as default };
|
package/esm/signer/ed25519.d.ts
CHANGED
|
@@ -1,53 +1,56 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import _default$1 from "../protocols/signer.js";
|
|
2
|
+
import { BytesType, EncodingType, KeyPairType } from "@ocap/util";
|
|
3
|
+
|
|
4
|
+
//#region src/signer/ed25519.d.ts
|
|
5
|
+
|
|
3
6
|
/**
|
|
4
7
|
* Signer implementation for ed25519, based on `tweetnacl`
|
|
5
8
|
*
|
|
6
9
|
* @class Ed25519Signer
|
|
7
10
|
*/
|
|
8
|
-
declare class Ed25519Signer extends
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
11
|
+
declare class Ed25519Signer extends _default$1 {
|
|
12
|
+
constructor();
|
|
13
|
+
/**
|
|
14
|
+
* @public
|
|
15
|
+
* @typedefKeyPairType
|
|
16
|
+
* @prop {string} publicKey - publicKey in hex format
|
|
17
|
+
* @prop {string} secretKey - secretKey in hex format
|
|
18
|
+
* @memberof Ed25519Signer
|
|
19
|
+
*/
|
|
20
|
+
/**
|
|
21
|
+
* Generate random secret/public key pair
|
|
22
|
+
*
|
|
23
|
+
* @param {Buffer|Uint8Array} [userSeed=undefined]
|
|
24
|
+
* @param {string} [encoding='hex']
|
|
25
|
+
* @returns {KeyPairType}
|
|
26
|
+
* @memberof Ed25519Signer
|
|
27
|
+
*/
|
|
28
|
+
genKeyPair(encoding?: EncodingType, userSeed?: BytesType): KeyPairType;
|
|
29
|
+
/**
|
|
30
|
+
* Get publicKey from secretKey
|
|
31
|
+
*
|
|
32
|
+
* @param {hex|buffer|base58|Uint8Array} sk - can be either a hex encoded string or a buffer
|
|
33
|
+
* @returns {string} hex encoded publicKey
|
|
34
|
+
*/
|
|
35
|
+
getPublicKey(sk: BytesType, encoding?: EncodingType): BytesType;
|
|
36
|
+
/**
|
|
37
|
+
* Sign a message and get the signature hex
|
|
38
|
+
*
|
|
39
|
+
* @param {hex|base58|buffer|Uint8Array} message
|
|
40
|
+
* @param {hex|base58|buffer|Uint8Array} sk
|
|
41
|
+
* @returns {string} hex encoded signature
|
|
42
|
+
*/
|
|
43
|
+
sign(message: BytesType, sk: BytesType, encoding?: EncodingType): BytesType;
|
|
44
|
+
/**
|
|
45
|
+
* Verify if a signature is valid
|
|
46
|
+
*
|
|
47
|
+
* @param {string|buffer} message
|
|
48
|
+
* @param {string|buffer} signature
|
|
49
|
+
* @param {string|buffer} pk
|
|
50
|
+
* @returns {bool}
|
|
51
|
+
*/
|
|
52
|
+
verify(message: BytesType, signature: BytesType, pk: BytesType): boolean;
|
|
50
53
|
}
|
|
51
54
|
declare const _default: Ed25519Signer;
|
|
52
|
-
|
|
53
|
-
export { Ed25519Signer };
|
|
55
|
+
//#endregion
|
|
56
|
+
export { Ed25519Signer, _default as default };
|