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