@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.
Files changed (66) hide show
  1. package/esm/crypter/aes-legacy.d.ts +8 -6
  2. package/esm/crypter/aes-legacy.js +27 -24
  3. package/esm/crypter/aes.d.ts +9 -7
  4. package/esm/crypter/aes.js +27 -25
  5. package/esm/crypter/rsa-browserify.d.ts +7 -6
  6. package/esm/crypter/rsa-browserify.js +34 -31
  7. package/esm/crypter/rsa.d.ts +11 -9
  8. package/esm/crypter/rsa.js +31 -28
  9. package/esm/encode.d.ts +12 -8
  10. package/esm/encode.js +13 -18
  11. package/esm/hasher/keccak.d.ts +8 -5
  12. package/esm/hasher/keccak.js +37 -36
  13. package/esm/hasher/sha2.d.ts +8 -5
  14. package/esm/hasher/sha2.js +42 -40
  15. package/esm/hasher/sha3.d.ts +8 -5
  16. package/esm/hasher/sha3.js +37 -36
  17. package/esm/index.d.ts +148 -143
  18. package/esm/index.js +172 -209
  19. package/esm/protocols/crypter.d.ts +3 -1
  20. package/esm/protocols/crypter.js +7 -4
  21. package/esm/protocols/hasher.d.ts +3 -1
  22. package/esm/protocols/hasher.js +7 -4
  23. package/esm/protocols/signer.d.ts +3 -1
  24. package/esm/protocols/signer.js +7 -4
  25. package/esm/signer/ed25519.d.ts +49 -46
  26. package/esm/signer/ed25519.js +80 -80
  27. package/esm/signer/ethereum.d.ts +11 -8
  28. package/esm/signer/ethereum.js +34 -34
  29. package/esm/signer/passkey.d.ts +21 -18
  30. package/esm/signer/passkey.js +49 -58
  31. package/esm/signer/secp256k1.d.ts +35 -32
  32. package/esm/signer/secp256k1.js +80 -93
  33. package/lib/_virtual/rolldown_runtime.js +29 -0
  34. package/lib/crypter/aes-legacy.d.ts +8 -6
  35. package/lib/crypter/aes-legacy.js +35 -52
  36. package/lib/crypter/aes.d.ts +9 -7
  37. package/lib/crypter/aes.js +29 -29
  38. package/lib/crypter/rsa-browserify.d.ts +7 -6
  39. package/lib/crypter/rsa-browserify.js +36 -33
  40. package/lib/crypter/rsa.d.ts +11 -9
  41. package/lib/crypter/rsa.js +33 -32
  42. package/lib/encode.d.ts +12 -8
  43. package/lib/encode.js +14 -21
  44. package/lib/hasher/keccak.d.ts +8 -5
  45. package/lib/hasher/keccak.js +40 -41
  46. package/lib/hasher/sha2.d.ts +8 -5
  47. package/lib/hasher/sha2.js +43 -42
  48. package/lib/hasher/sha3.d.ts +8 -5
  49. package/lib/hasher/sha3.js +40 -41
  50. package/lib/index.d.ts +148 -143
  51. package/lib/index.js +177 -216
  52. package/lib/protocols/crypter.d.ts +3 -1
  53. package/lib/protocols/crypter.js +10 -9
  54. package/lib/protocols/hasher.d.ts +3 -1
  55. package/lib/protocols/hasher.js +10 -9
  56. package/lib/protocols/signer.d.ts +3 -1
  57. package/lib/protocols/signer.js +10 -9
  58. package/lib/signer/ed25519.d.ts +49 -46
  59. package/lib/signer/ed25519.js +85 -86
  60. package/lib/signer/ethereum.d.ts +11 -8
  61. package/lib/signer/ethereum.js +38 -39
  62. package/lib/signer/passkey.d.ts +21 -18
  63. package/lib/signer/passkey.js +51 -63
  64. package/lib/signer/secp256k1.d.ts +35 -32
  65. package/lib/signer/secp256k1.js +85 -99
  66. package/package.json +21 -10
package/lib/index.js CHANGED
@@ -1,230 +1,191 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.toTxHash = exports.Hashers = exports.Signers = exports.types = exports.Hasher = exports.Signer = void 0;
7
- exports.getSigner = getSigner;
8
- exports.getHasher = getHasher;
9
- exports.getRandomBytes = getRandomBytes;
10
- const randombytes_1 = __importDefault(require("randombytes"));
11
- const encode_1 = require("./encode");
12
- const keccak_1 = __importDefault(require("./hasher/keccak"));
13
- const sha2_1 = __importDefault(require("./hasher/sha2"));
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
- * Contains all supported signers, eg: `Ed25519` and `Secp256k1`
21
- *
22
- * @readonly
23
- * @type {object}
24
- * @name Signer
25
- * @static
26
- * @example
27
- * const { Signer } = require('@ocap/mcrypto');
28
- * const message = 'some message to sign';
29
- *
30
- * // Use Signer directly
31
- * const keyPair = Signer.Ed25519.genKeyPair();
32
- * const signature = Signer.Ed25519.sign(message, keyPair.secretKey);
33
- * const result = Signer.Ed25519.verify(message, signature, keyPair.publicKey);
34
- * assert.ok(result);
35
- */
36
- exports.Signer = {
37
- Ed25519: ed25519_1.default,
38
- Secp256k1: secp256k1_1.default,
39
- Ethereum: ethereum_1.default,
40
- Passkey: passkey_1.default,
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
- * Contains all supported hasher, eg: `SHA2`,`SHA3` and `Keccak`, each of them supports `hash224`, `hash256`, `hash384`, `hash512`
44
- *
45
- * @readonly
46
- * @type {object}
47
- * @name Hasher
48
- * @static
49
- * @example
50
- * const { Hasher } = require('@ocap/mcrypto');
51
- *
52
- * const message = 'message to hash';
53
- * const hash = Hasher.SHA2.hash256(message);
54
- */
55
- exports.Hasher = {
56
- SHA2: sha2_1.default,
57
- SHA3: sha3_1.default,
58
- Keccak: keccak_1.default,
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
- * Contains type constants that represent can be used to compose different crypto method, each crypto method consist one of:
62
- * FIXME: enum definition of forge-abi and abt-did-elixir are not exactly the same
63
- *
64
- * @readonly
65
- * @type {object}
66
- * @name types
67
- * @static
68
- * @example
69
- * const { types } = require('@ocap/mcrypto');
70
- *
71
- * // types.RoleType.ROLE_ACCOUNT
72
- * // types.KeyType.ED25519
73
- * // types.HashType.SHA3
74
- * // types.EncodingType.BASE58
75
- */
76
- exports.types = {
77
- /**
78
- * Key-pair derivation algorithms
79
- *
80
- * @readonly
81
- * @enum {number}
82
- * @name types.KeyType
83
- * @memberof types
84
- * @static
85
- */
86
- KeyType: {
87
- ED25519: 0,
88
- SECP256K1: 1,
89
- ETHEREUM: 2,
90
- PASSKEY: 3,
91
- },
92
- /**
93
- * Hashing algorithms
94
- *
95
- * @readonly
96
- * @enum {number}
97
- * @name types.HashType
98
- * @memberof types
99
- * @static
100
- */
101
- HashType: {
102
- KECCAK: 0,
103
- SHA3: 1,
104
- KECCAK_384: 2,
105
- SHA3_384: 3,
106
- KECCAK_512: 4,
107
- SHA3_512: 5,
108
- SHA2: 6,
109
- },
110
- /**
111
- * DID wallet role type
112
- *
113
- * @readonly
114
- * @enum {number}
115
- * @name types.RoleType
116
- * @memberof types
117
- * @static
118
- */
119
- RoleType: {
120
- ROLE_ACCOUNT: 0,
121
- ROLE_NODE: 1,
122
- ROLE_DEVICE: 2,
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
- * Get signer instance
162
- *
163
- * @function
164
- * @param {number} type - algorithm used to derive key pair, possible values are
165
- * - types.KeyType.ED25519
166
- * - types.KeyType.SECP256k1
167
- * - types.KeyType.ETHEREUM
168
- * @returns {object} signer instance
169
- * @example
170
- * const { getSigner, types } = require('@ocap/mcrypto');
171
- * const message = 'some message to sign';
172
- *
173
- * const signer = getSigner(types.KeyType.ED25519);
174
- * const keyPair1 = signer.genKeyPair();
175
- * const signature1 = signer.sign(message, keyPair1.secretKey);
176
- * const result1 = signer.verify(message, signature1, keyPair1.publicKey);
177
- * assert.ok(result1);
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
- if (typeof exports.Signers[type] === 'undefined') {
181
- throw new Error(`Unsupported signer type: ${type}`);
182
- }
183
- // @ts-ignore
184
- return exports.Signers[type];
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
- * Get hasher instance
188
- *
189
- * @function
190
- * @param {number} type - algorithm used to hash data, possible values
191
- * - types.HashType.KECCAK
192
- * - types.HashType.KECCAK_384
193
- * - types.HashType.KECCAK_512
194
- * - types.HashType.SHA3
195
- * - types.HashType.SHA3_384
196
- * - types.HashType.SHA3_512
197
- * @returns {object} hasher instance
198
- * @example
199
- * const { getHasher, types } = require('@ocap/mcrypto');
200
- *
201
- * const hashFn = getHasher(types.HashType.SHA3);
202
- * const hash2 = hashFn(message);
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
- if (typeof exports.Hashers[type] === 'undefined') {
206
- throw new Error(`Unsupported hash type: ${type}`);
207
- }
208
- // @ts-ignore
209
- return exports.Hashers[type];
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 = 'hex') {
212
- return (0, encode_1.encode)((0, randombytes_1.default)(length), encoding);
179
+ function getRandomBytes(length = 32, encoding = "hex") {
180
+ return require_encode.encode((0, randombytes.default)(length), encoding);
213
181
  }
214
- exports.Signers = Object.freeze({
215
- [exports.types.KeyType.ED25519]: exports.Signer.Ed25519,
216
- [exports.types.KeyType.SECP256K1]: exports.Signer.Secp256k1,
217
- [exports.types.KeyType.ETHEREUM]: exports.Signer.Ethereum,
218
- [exports.types.KeyType.PASSKEY]: exports.Signer.Passkey,
219
- });
220
- exports.Hashers = Object.freeze({
221
- [exports.types.HashType.KECCAK]: exports.Hasher.Keccak.hash256,
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;
@@ -1,2 +1,4 @@
1
+ //#region src/protocols/crypter.d.ts
1
2
  declare const _default: any;
2
- export default _default;
3
+ //#endregion
4
+ export { _default as default };
@@ -1,9 +1,10 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- /* eslint-disable @typescript-eslint/ban-ts-comment */
7
- // @ts-ignore
8
- const interface_1 = __importDefault(require("interface"));
9
- exports.default = interface_1.default.create('encrypt', 'decrypt');
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;
@@ -1,2 +1,4 @@
1
+ //#region src/protocols/hasher.d.ts
1
2
  declare const _default: any;
2
- export default _default;
3
+ //#endregion
4
+ export { _default as default };
@@ -1,9 +1,10 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- /* eslint-disable @typescript-eslint/ban-ts-comment */
7
- // @ts-ignore
8
- const interface_1 = __importDefault(require("interface"));
9
- exports.default = interface_1.default.create('sha224', 'sha256', 'sha384', 'sha512');
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;
@@ -1,2 +1,4 @@
1
+ //#region src/protocols/signer.d.ts
1
2
  declare const _default: any;
2
- export default _default;
3
+ //#endregion
4
+ export { _default as default };
@@ -1,9 +1,10 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- /* eslint-disable @typescript-eslint/ban-ts-comment */
7
- // @ts-ignore
8
- const interface_1 = __importDefault(require("interface"));
9
- exports.default = interface_1.default.create('genKeyPair', 'getPublicKey', 'sign', 'verify');
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;
@@ -1,53 +1,56 @@
1
- import { BytesType, EncodingType, KeyPairType } from '@ocap/util';
2
- import BaseSigner from '../protocols/signer';
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 BaseSigner {
9
- constructor();
10
- /**
11
- * @public
12
- * @typedefKeyPairType
13
- * @prop {string} publicKey - publicKey in hex format
14
- * @prop {string} secretKey - secretKey in hex format
15
- * @memberof Ed25519Signer
16
- */
17
- /**
18
- * Generate random secret/public key pair
19
- *
20
- * @param {Buffer|Uint8Array} [userSeed=undefined]
21
- * @param {string} [encoding='hex']
22
- * @returns {KeyPairType}
23
- * @memberof Ed25519Signer
24
- */
25
- genKeyPair(encoding?: EncodingType, userSeed?: BytesType): KeyPairType;
26
- /**
27
- * Get publicKey from secretKey
28
- *
29
- * @param {hex|buffer|base58|Uint8Array} sk - can be either a hex encoded string or a buffer
30
- * @returns {string} hex encoded publicKey
31
- */
32
- getPublicKey(sk: BytesType, encoding?: EncodingType): BytesType;
33
- /**
34
- * Sign a message and get the signature hex
35
- *
36
- * @param {hex|base58|buffer|Uint8Array} message
37
- * @param {hex|base58|buffer|Uint8Array} sk
38
- * @returns {string} hex encoded signature
39
- */
40
- sign(message: BytesType, sk: BytesType, encoding?: EncodingType): BytesType;
41
- /**
42
- * Verify if a signature is valid
43
- *
44
- * @param {string|buffer} message
45
- * @param {string|buffer} signature
46
- * @param {string|buffer} pk
47
- * @returns {bool}
48
- */
49
- verify(message: BytesType, signature: BytesType, pk: BytesType): boolean;
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
- export default _default;
53
- export { Ed25519Signer };
55
+ //#endregion
56
+ export { Ed25519Signer, _default as default };