@ocap/mcrypto 1.29.4 → 1.29.6

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 (49) hide show
  1. package/esm/_virtual/rolldown_runtime.mjs +32 -0
  2. package/esm/hasher/keccak.d.mts +1 -0
  3. package/esm/hasher/keccak.mjs +15 -5
  4. package/esm/hasher/sha2.d.mts +1 -0
  5. package/esm/hasher/sha2.mjs +8 -5
  6. package/esm/hasher/sha3.d.mts +1 -0
  7. package/esm/hasher/sha3.mjs +15 -5
  8. package/esm/node_modules/hash.js/lib/hash/common.mjs +77 -0
  9. package/esm/node_modules/hash.js/lib/hash/hmac.mjs +41 -0
  10. package/esm/node_modules/hash.js/lib/hash/ripemd.mjs +422 -0
  11. package/esm/node_modules/hash.js/lib/hash/sha/1.mjs +73 -0
  12. package/esm/node_modules/hash.js/lib/hash/sha/224.mjs +38 -0
  13. package/esm/node_modules/hash.js/lib/hash/sha/256.mjs +154 -0
  14. package/esm/node_modules/hash.js/lib/hash/sha/384.mjs +46 -0
  15. package/esm/node_modules/hash.js/lib/hash/sha/512.mjs +389 -0
  16. package/esm/node_modules/hash.js/lib/hash/sha/common.mjs +46 -0
  17. package/esm/node_modules/hash.js/lib/hash/sha.mjs +20 -0
  18. package/esm/node_modules/hash.js/lib/hash/utils.mjs +211 -0
  19. package/esm/node_modules/hash.js/lib/hash.mjs +27 -0
  20. package/esm/node_modules/inherits/inherits.mjs +20 -0
  21. package/esm/node_modules/inherits/inherits_browser.mjs +30 -0
  22. package/esm/node_modules/minimalistic-assert/index.mjs +17 -0
  23. package/esm/signer/ed25519.d.mts +1 -1
  24. package/esm/signer/ed25519.mjs +19 -12
  25. package/lib/_virtual/rolldown_runtime.cjs +2 -0
  26. package/lib/hasher/keccak.cjs +15 -6
  27. package/lib/hasher/keccak.d.cts +1 -0
  28. package/lib/hasher/sha2.cjs +12 -8
  29. package/lib/hasher/sha2.d.cts +1 -0
  30. package/lib/hasher/sha3.cjs +15 -6
  31. package/lib/hasher/sha3.d.cts +1 -0
  32. package/lib/node_modules/hash.js/lib/hash/common.cjs +82 -0
  33. package/lib/node_modules/hash.js/lib/hash/hmac.cjs +46 -0
  34. package/lib/node_modules/hash.js/lib/hash/ripemd.cjs +427 -0
  35. package/lib/node_modules/hash.js/lib/hash/sha/1.cjs +78 -0
  36. package/lib/node_modules/hash.js/lib/hash/sha/224.cjs +43 -0
  37. package/lib/node_modules/hash.js/lib/hash/sha/256.cjs +159 -0
  38. package/lib/node_modules/hash.js/lib/hash/sha/384.cjs +51 -0
  39. package/lib/node_modules/hash.js/lib/hash/sha/512.cjs +394 -0
  40. package/lib/node_modules/hash.js/lib/hash/sha/common.cjs +51 -0
  41. package/lib/node_modules/hash.js/lib/hash/sha.cjs +25 -0
  42. package/lib/node_modules/hash.js/lib/hash/utils.cjs +216 -0
  43. package/lib/node_modules/hash.js/lib/hash.cjs +30 -0
  44. package/lib/node_modules/inherits/inherits.cjs +23 -0
  45. package/lib/node_modules/inherits/inherits_browser.cjs +33 -0
  46. package/lib/node_modules/minimalistic-assert/index.cjs +20 -0
  47. package/lib/signer/ed25519.cjs +19 -13
  48. package/lib/signer/ed25519.d.cts +1 -1
  49. package/package.json +8 -8
@@ -0,0 +1,46 @@
1
+ import { __commonJSMin } from "../../../../../_virtual/rolldown_runtime.mjs";
2
+ import { require_utils } from "../utils.mjs";
3
+
4
+ //#region ../../node_modules/hash.js/lib/hash/sha/common.js
5
+ var require_common = /* @__PURE__ */ __commonJSMin(((exports) => {
6
+ var rotr32 = require_utils().rotr32;
7
+ function ft_1(s, x, y, z) {
8
+ if (s === 0) return ch32(x, y, z);
9
+ if (s === 1 || s === 3) return p32(x, y, z);
10
+ if (s === 2) return maj32(x, y, z);
11
+ }
12
+ exports.ft_1 = ft_1;
13
+ function ch32(x, y, z) {
14
+ return x & y ^ ~x & z;
15
+ }
16
+ exports.ch32 = ch32;
17
+ function maj32(x, y, z) {
18
+ return x & y ^ x & z ^ y & z;
19
+ }
20
+ exports.maj32 = maj32;
21
+ function p32(x, y, z) {
22
+ return x ^ y ^ z;
23
+ }
24
+ exports.p32 = p32;
25
+ function s0_256(x) {
26
+ return rotr32(x, 2) ^ rotr32(x, 13) ^ rotr32(x, 22);
27
+ }
28
+ exports.s0_256 = s0_256;
29
+ function s1_256(x) {
30
+ return rotr32(x, 6) ^ rotr32(x, 11) ^ rotr32(x, 25);
31
+ }
32
+ exports.s1_256 = s1_256;
33
+ function g0_256(x) {
34
+ return rotr32(x, 7) ^ rotr32(x, 18) ^ x >>> 3;
35
+ }
36
+ exports.g0_256 = g0_256;
37
+ function g1_256(x) {
38
+ return rotr32(x, 17) ^ rotr32(x, 19) ^ x >>> 10;
39
+ }
40
+ exports.g1_256 = g1_256;
41
+ }));
42
+
43
+ //#endregion
44
+ export default require_common();
45
+
46
+ export { require_common };
@@ -0,0 +1,20 @@
1
+ import { __commonJSMin } from "../../../../_virtual/rolldown_runtime.mjs";
2
+ import { require__1 } from "./sha/1.mjs";
3
+ import { require__256 } from "./sha/256.mjs";
4
+ import { require__224 } from "./sha/224.mjs";
5
+ import { require__512 } from "./sha/512.mjs";
6
+ import { require__384 } from "./sha/384.mjs";
7
+
8
+ //#region ../../node_modules/hash.js/lib/hash/sha.js
9
+ var require_sha = /* @__PURE__ */ __commonJSMin(((exports) => {
10
+ exports.sha1 = require__1();
11
+ exports.sha224 = require__224();
12
+ exports.sha256 = require__256();
13
+ exports.sha384 = require__384();
14
+ exports.sha512 = require__512();
15
+ }));
16
+
17
+ //#endregion
18
+ export default require_sha();
19
+
20
+ export { require_sha };
@@ -0,0 +1,211 @@
1
+ import { __commonJSMin } from "../../../../_virtual/rolldown_runtime.mjs";
2
+ import { require_minimalistic_assert } from "../../../minimalistic-assert/index.mjs";
3
+ import { require_inherits } from "../../../inherits/inherits.mjs";
4
+
5
+ //#region ../../node_modules/hash.js/lib/hash/utils.js
6
+ var require_utils = /* @__PURE__ */ __commonJSMin(((exports) => {
7
+ var assert = require_minimalistic_assert();
8
+ var inherits = require_inherits();
9
+ exports.inherits = inherits;
10
+ function isSurrogatePair(msg, i) {
11
+ if ((msg.charCodeAt(i) & 64512) !== 55296) return false;
12
+ if (i < 0 || i + 1 >= msg.length) return false;
13
+ return (msg.charCodeAt(i + 1) & 64512) === 56320;
14
+ }
15
+ function toArray(msg, enc) {
16
+ if (Array.isArray(msg)) return msg.slice();
17
+ if (!msg) return [];
18
+ var res = [];
19
+ if (typeof msg === "string") {
20
+ if (!enc) {
21
+ var p = 0;
22
+ for (var i = 0; i < msg.length; i++) {
23
+ var c = msg.charCodeAt(i);
24
+ if (c < 128) res[p++] = c;
25
+ else if (c < 2048) {
26
+ res[p++] = c >> 6 | 192;
27
+ res[p++] = c & 63 | 128;
28
+ } else if (isSurrogatePair(msg, i)) {
29
+ c = 65536 + ((c & 1023) << 10) + (msg.charCodeAt(++i) & 1023);
30
+ res[p++] = c >> 18 | 240;
31
+ res[p++] = c >> 12 & 63 | 128;
32
+ res[p++] = c >> 6 & 63 | 128;
33
+ res[p++] = c & 63 | 128;
34
+ } else {
35
+ res[p++] = c >> 12 | 224;
36
+ res[p++] = c >> 6 & 63 | 128;
37
+ res[p++] = c & 63 | 128;
38
+ }
39
+ }
40
+ } else if (enc === "hex") {
41
+ msg = msg.replace(/[^a-z0-9]+/gi, "");
42
+ if (msg.length % 2 !== 0) msg = "0" + msg;
43
+ for (i = 0; i < msg.length; i += 2) res.push(parseInt(msg[i] + msg[i + 1], 16));
44
+ }
45
+ } else for (i = 0; i < msg.length; i++) res[i] = msg[i] | 0;
46
+ return res;
47
+ }
48
+ exports.toArray = toArray;
49
+ function toHex(msg) {
50
+ var res = "";
51
+ for (var i = 0; i < msg.length; i++) res += zero2(msg[i].toString(16));
52
+ return res;
53
+ }
54
+ exports.toHex = toHex;
55
+ function htonl(w) {
56
+ return (w >>> 24 | w >>> 8 & 65280 | w << 8 & 16711680 | (w & 255) << 24) >>> 0;
57
+ }
58
+ exports.htonl = htonl;
59
+ function toHex32(msg, endian) {
60
+ var res = "";
61
+ for (var i = 0; i < msg.length; i++) {
62
+ var w = msg[i];
63
+ if (endian === "little") w = htonl(w);
64
+ res += zero8(w.toString(16));
65
+ }
66
+ return res;
67
+ }
68
+ exports.toHex32 = toHex32;
69
+ function zero2(word) {
70
+ if (word.length === 1) return "0" + word;
71
+ else return word;
72
+ }
73
+ exports.zero2 = zero2;
74
+ function zero8(word) {
75
+ if (word.length === 7) return "0" + word;
76
+ else if (word.length === 6) return "00" + word;
77
+ else if (word.length === 5) return "000" + word;
78
+ else if (word.length === 4) return "0000" + word;
79
+ else if (word.length === 3) return "00000" + word;
80
+ else if (word.length === 2) return "000000" + word;
81
+ else if (word.length === 1) return "0000000" + word;
82
+ else return word;
83
+ }
84
+ exports.zero8 = zero8;
85
+ function join32(msg, start, end, endian) {
86
+ var len = end - start;
87
+ assert(len % 4 === 0);
88
+ var res = new Array(len / 4);
89
+ for (var i = 0, k = start; i < res.length; i++, k += 4) {
90
+ var w;
91
+ if (endian === "big") w = msg[k] << 24 | msg[k + 1] << 16 | msg[k + 2] << 8 | msg[k + 3];
92
+ else w = msg[k + 3] << 24 | msg[k + 2] << 16 | msg[k + 1] << 8 | msg[k];
93
+ res[i] = w >>> 0;
94
+ }
95
+ return res;
96
+ }
97
+ exports.join32 = join32;
98
+ function split32(msg, endian) {
99
+ var res = new Array(msg.length * 4);
100
+ for (var i = 0, k = 0; i < msg.length; i++, k += 4) {
101
+ var m = msg[i];
102
+ if (endian === "big") {
103
+ res[k] = m >>> 24;
104
+ res[k + 1] = m >>> 16 & 255;
105
+ res[k + 2] = m >>> 8 & 255;
106
+ res[k + 3] = m & 255;
107
+ } else {
108
+ res[k + 3] = m >>> 24;
109
+ res[k + 2] = m >>> 16 & 255;
110
+ res[k + 1] = m >>> 8 & 255;
111
+ res[k] = m & 255;
112
+ }
113
+ }
114
+ return res;
115
+ }
116
+ exports.split32 = split32;
117
+ function rotr32(w, b) {
118
+ return w >>> b | w << 32 - b;
119
+ }
120
+ exports.rotr32 = rotr32;
121
+ function rotl32(w, b) {
122
+ return w << b | w >>> 32 - b;
123
+ }
124
+ exports.rotl32 = rotl32;
125
+ function sum32(a, b) {
126
+ return a + b >>> 0;
127
+ }
128
+ exports.sum32 = sum32;
129
+ function sum32_3(a, b, c) {
130
+ return a + b + c >>> 0;
131
+ }
132
+ exports.sum32_3 = sum32_3;
133
+ function sum32_4(a, b, c, d) {
134
+ return a + b + c + d >>> 0;
135
+ }
136
+ exports.sum32_4 = sum32_4;
137
+ function sum32_5(a, b, c, d, e) {
138
+ return a + b + c + d + e >>> 0;
139
+ }
140
+ exports.sum32_5 = sum32_5;
141
+ function sum64(buf, pos, ah, al) {
142
+ var bh = buf[pos];
143
+ var lo = al + buf[pos + 1] >>> 0;
144
+ buf[pos] = (lo < al ? 1 : 0) + ah + bh >>> 0;
145
+ buf[pos + 1] = lo;
146
+ }
147
+ exports.sum64 = sum64;
148
+ function sum64_hi(ah, al, bh, bl) {
149
+ return (al + bl >>> 0 < al ? 1 : 0) + ah + bh >>> 0;
150
+ }
151
+ exports.sum64_hi = sum64_hi;
152
+ function sum64_lo(ah, al, bh, bl) {
153
+ return al + bl >>> 0;
154
+ }
155
+ exports.sum64_lo = sum64_lo;
156
+ function sum64_4_hi(ah, al, bh, bl, ch, cl, dh, dl) {
157
+ var carry = 0;
158
+ var lo = al;
159
+ lo = lo + bl >>> 0;
160
+ carry += lo < al ? 1 : 0;
161
+ lo = lo + cl >>> 0;
162
+ carry += lo < cl ? 1 : 0;
163
+ lo = lo + dl >>> 0;
164
+ carry += lo < dl ? 1 : 0;
165
+ return ah + bh + ch + dh + carry >>> 0;
166
+ }
167
+ exports.sum64_4_hi = sum64_4_hi;
168
+ function sum64_4_lo(ah, al, bh, bl, ch, cl, dh, dl) {
169
+ return al + bl + cl + dl >>> 0;
170
+ }
171
+ exports.sum64_4_lo = sum64_4_lo;
172
+ function sum64_5_hi(ah, al, bh, bl, ch, cl, dh, dl, eh, el) {
173
+ var carry = 0;
174
+ var lo = al;
175
+ lo = lo + bl >>> 0;
176
+ carry += lo < al ? 1 : 0;
177
+ lo = lo + cl >>> 0;
178
+ carry += lo < cl ? 1 : 0;
179
+ lo = lo + dl >>> 0;
180
+ carry += lo < dl ? 1 : 0;
181
+ lo = lo + el >>> 0;
182
+ carry += lo < el ? 1 : 0;
183
+ return ah + bh + ch + dh + eh + carry >>> 0;
184
+ }
185
+ exports.sum64_5_hi = sum64_5_hi;
186
+ function sum64_5_lo(ah, al, bh, bl, ch, cl, dh, dl, eh, el) {
187
+ return al + bl + cl + dl + el >>> 0;
188
+ }
189
+ exports.sum64_5_lo = sum64_5_lo;
190
+ function rotr64_hi(ah, al, num) {
191
+ return (al << 32 - num | ah >>> num) >>> 0;
192
+ }
193
+ exports.rotr64_hi = rotr64_hi;
194
+ function rotr64_lo(ah, al, num) {
195
+ return (ah << 32 - num | al >>> num) >>> 0;
196
+ }
197
+ exports.rotr64_lo = rotr64_lo;
198
+ function shr64_hi(ah, al, num) {
199
+ return ah >>> num;
200
+ }
201
+ exports.shr64_hi = shr64_hi;
202
+ function shr64_lo(ah, al, num) {
203
+ return (ah << 32 - num | al >>> num) >>> 0;
204
+ }
205
+ exports.shr64_lo = shr64_lo;
206
+ }));
207
+
208
+ //#endregion
209
+ export default require_utils();
210
+
211
+ export { require_utils };
@@ -0,0 +1,27 @@
1
+ import { __commonJSMin } from "../../../_virtual/rolldown_runtime.mjs";
2
+ import { require_utils } from "./hash/utils.mjs";
3
+ import { require_common } from "./hash/common.mjs";
4
+ import { require_sha } from "./hash/sha.mjs";
5
+ import { require_ripemd } from "./hash/ripemd.mjs";
6
+ import { require_hmac } from "./hash/hmac.mjs";
7
+
8
+ //#region ../../node_modules/hash.js/lib/hash.js
9
+ var require_hash = /* @__PURE__ */ __commonJSMin(((exports) => {
10
+ var hash = exports;
11
+ hash.utils = require_utils();
12
+ hash.common = require_common();
13
+ hash.sha = require_sha();
14
+ hash.ripemd = require_ripemd();
15
+ hash.hmac = require_hmac();
16
+ hash.sha1 = hash.sha.sha1;
17
+ hash.sha256 = hash.sha.sha256;
18
+ hash.sha224 = hash.sha.sha224;
19
+ hash.sha384 = hash.sha.sha384;
20
+ hash.sha512 = hash.sha.sha512;
21
+ hash.ripemd160 = hash.ripemd.ripemd160;
22
+ }));
23
+
24
+ //#endregion
25
+ export default require_hash();
26
+
27
+ export { require_hash };
@@ -0,0 +1,20 @@
1
+ import { __commonJSMin, __require } from "../../_virtual/rolldown_runtime.mjs";
2
+ import { require_inherits_browser } from "./inherits_browser.mjs";
3
+
4
+ //#region ../../node_modules/inherits/inherits.js
5
+ var require_inherits = /* @__PURE__ */ __commonJSMin(((exports, module) => {
6
+ try {
7
+ var util = __require("util");
8
+ /* istanbul ignore next */
9
+ if (typeof util.inherits !== "function") throw "";
10
+ module.exports = util.inherits;
11
+ } catch (e) {
12
+ /* istanbul ignore next */
13
+ module.exports = require_inherits_browser();
14
+ }
15
+ }));
16
+
17
+ //#endregion
18
+ export default require_inherits();
19
+
20
+ export { require_inherits };
@@ -0,0 +1,30 @@
1
+ import { __commonJSMin } from "../../_virtual/rolldown_runtime.mjs";
2
+
3
+ //#region ../../node_modules/inherits/inherits_browser.js
4
+ var require_inherits_browser = /* @__PURE__ */ __commonJSMin(((exports, module) => {
5
+ if (typeof Object.create === "function") module.exports = function inherits(ctor, superCtor) {
6
+ if (superCtor) {
7
+ ctor.super_ = superCtor;
8
+ ctor.prototype = Object.create(superCtor.prototype, { constructor: {
9
+ value: ctor,
10
+ enumerable: false,
11
+ writable: true,
12
+ configurable: true
13
+ } });
14
+ }
15
+ };
16
+ else module.exports = function inherits(ctor, superCtor) {
17
+ if (superCtor) {
18
+ ctor.super_ = superCtor;
19
+ var TempCtor = function() {};
20
+ TempCtor.prototype = superCtor.prototype;
21
+ ctor.prototype = new TempCtor();
22
+ ctor.prototype.constructor = ctor;
23
+ }
24
+ };
25
+ }));
26
+
27
+ //#endregion
28
+ export default require_inherits_browser();
29
+
30
+ export { require_inherits_browser };
@@ -0,0 +1,17 @@
1
+ import { __commonJSMin } from "../../_virtual/rolldown_runtime.mjs";
2
+
3
+ //#region ../../node_modules/minimalistic-assert/index.js
4
+ var require_minimalistic_assert = /* @__PURE__ */ __commonJSMin(((exports, module) => {
5
+ module.exports = assert;
6
+ function assert(val, msg) {
7
+ if (!val) throw new Error(msg || "Assertion failed");
8
+ }
9
+ assert.equal = function assertEqual(l, r, msg) {
10
+ if (l != r) throw new Error(msg || "Assertion failed: " + l + " != " + r);
11
+ };
12
+ }));
13
+
14
+ //#endregion
15
+ export default require_minimalistic_assert();
16
+
17
+ export { require_minimalistic_assert };
@@ -4,7 +4,7 @@ import { BytesType, EncodingType, KeyPairType } from "@ocap/util";
4
4
  //#region src/signer/ed25519.d.ts
5
5
 
6
6
  /**
7
- * Signer implementation for ed25519, based on `tweetnacl`
7
+ * Signer implementation for ed25519, based on `@noble/ed25519`
8
8
  *
9
9
  * @class Ed25519Signer
10
10
  */
@@ -1,13 +1,16 @@
1
+ import { __toESM } from "../_virtual/rolldown_runtime.mjs";
1
2
  import { encode } from "../encode.mjs";
3
+ import { require_hash } from "../node_modules/hash.js/lib/hash.mjs";
2
4
  import signer_default from "../protocols/signer.mjs";
3
5
  import { toUint8Array } from "@ocap/util";
4
6
  import randomBytes from "randombytes";
5
- import tweetnacl from "tweetnacl";
7
+ import * as ed from "@noble/ed25519";
6
8
 
7
9
  //#region src/signer/ed25519.ts
8
- const ed25519 = tweetnacl.sign;
10
+ var import_hash = /* @__PURE__ */ __toESM(require_hash(), 1);
11
+ ed.hashes.sha512 = (msg) => new Uint8Array(import_hash.default.sha512().update(msg).digest());
9
12
  /**
10
- * Signer implementation for ed25519, based on `tweetnacl`
13
+ * Signer implementation for ed25519, based on `@noble/ed25519`
11
14
  *
12
15
  * @class Ed25519Signer
13
16
  */
@@ -30,10 +33,14 @@ var Ed25519Signer = class extends signer_default {
30
33
  genKeyPair(encoding = "hex", userSeed) {
31
34
  const seed = userSeed ? toUint8Array(userSeed) : new Uint8Array(randomBytes(32));
32
35
  if (seed.byteLength !== 32) throw new Error("Invalid seed to generate key pair");
33
- const keyPair = ed25519.keyPair.fromSeed(seed);
34
- keyPair.publicKey = encode(keyPair.publicKey, encoding);
35
- keyPair.secretKey = encode(keyPair.secretKey, encoding);
36
- return keyPair;
36
+ const publicKey = ed.getPublicKey(seed);
37
+ const secretKey = new Uint8Array(64);
38
+ secretKey.set(seed);
39
+ secretKey.set(publicKey, 32);
40
+ return {
41
+ publicKey: encode(publicKey, encoding),
42
+ secretKey: encode(secretKey, encoding)
43
+ };
37
44
  }
38
45
  /**
39
46
  * Get publicKey from secretKey
@@ -43,8 +50,8 @@ var Ed25519Signer = class extends signer_default {
43
50
  */
44
51
  getPublicKey(sk, encoding = "hex") {
45
52
  const skBytes = toUint8Array(sk);
46
- const pk = ed25519.keyPair.fromSecretKey(skBytes).publicKey;
47
- return encode(pk, encoding);
53
+ if (skBytes.byteLength === 64) return encode(skBytes.slice(32, 64), encoding);
54
+ return encode(ed.getPublicKey(skBytes), encoding);
48
55
  }
49
56
  /**
50
57
  * Sign a message and get the signature hex
@@ -54,9 +61,9 @@ var Ed25519Signer = class extends signer_default {
54
61
  * @returns {string} hex encoded signature
55
62
  */
56
63
  sign(message, sk, encoding = "hex") {
57
- const skBytes = toUint8Array(sk);
64
+ const seed = toUint8Array(sk).slice(0, 32);
58
65
  const messageBytes = toUint8Array(message);
59
- return encode(ed25519.detached(messageBytes, skBytes), encoding);
66
+ return encode(ed.sign(messageBytes, seed), encoding);
60
67
  }
61
68
  /**
62
69
  * Verify if a signature is valid
@@ -70,7 +77,7 @@ var Ed25519Signer = class extends signer_default {
70
77
  const pkBytes = toUint8Array(pk);
71
78
  const messageBytes = toUint8Array(message);
72
79
  const signatureBytes = toUint8Array(signature);
73
- return ed25519.detached.verify(messageBytes, signatureBytes, pkBytes);
80
+ return ed.verify(signatureBytes, messageBytes, pkBytes);
74
81
  }
75
82
  };
76
83
  var ed25519_default = new Ed25519Signer();
@@ -5,6 +5,7 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __getProtoOf = Object.getPrototypeOf;
7
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
8
9
  var __copyProps = (to, from, except, desc) => {
9
10
  if (from && typeof from === "object" || typeof from === "function") {
10
11
  for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
@@ -26,4 +27,5 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
26
27
 
27
28
  //#endregion
28
29
 
30
+ exports.__commonJSMin = __commonJSMin;
29
31
  exports.__toESM = __toESM;
@@ -2,12 +2,19 @@ Object.defineProperty(exports, '__esModule', { value: true });
2
2
  const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
3
3
  const require_encode = require('../encode.cjs');
4
4
  let _ocap_util = require("@ocap/util");
5
- let js_sha3 = require("js-sha3");
6
- js_sha3 = require_rolldown_runtime.__toESM(js_sha3);
5
+ let _noble_hashes_sha3_js = require("@noble/hashes/sha3.js");
6
+ let _noble_hashes_utils_js = require("@noble/hashes/utils.js");
7
7
 
8
8
  //#region src/hasher/keccak.ts
9
+ const hashFns = {
10
+ keccak_224: _noble_hashes_sha3_js.keccak_224,
11
+ keccak_256: _noble_hashes_sha3_js.keccak_256,
12
+ keccak_384: _noble_hashes_sha3_js.keccak_384,
13
+ keccak_512: _noble_hashes_sha3_js.keccak_512
14
+ };
9
15
  /**
10
16
  * Keccak support with different hash length
17
+ * Uses @noble/hashes for unified implementation
11
18
  *
12
19
  * @class KeccakHasher
13
20
  */
@@ -20,17 +27,19 @@ var KeccakHasher = class {
20
27
  512
21
28
  ].forEach((x) => {
22
29
  const name = `hash${x}`;
23
- const hasher = (data) => js_sha3.default[`keccak${x}`](data);
30
+ const hasher = hashFns[`keccak_${x}`];
24
31
  const hashFn = (input, round) => {
25
32
  if (round === 1) return hasher(input);
26
33
  return hashFn(hasher(input), round - 1);
27
34
  };
28
35
  this[name] = (data, round = 1, encoding = "hex") => {
29
- let input = data;
36
+ let input;
30
37
  try {
31
38
  input = (0, _ocap_util.toUint8Array)(data);
32
- } catch (_err) {}
33
- return require_encode.encode(`0x${hashFn(input, round)}`, encoding);
39
+ } catch (_err) {
40
+ input = data;
41
+ }
42
+ return require_encode.encode(`0x${(0, _noble_hashes_utils_js.bytesToHex)(hashFn(input, round))}`, encoding);
34
43
  };
35
44
  });
36
45
  }
@@ -4,6 +4,7 @@ import { BytesType, EncodingType } from "@ocap/util";
4
4
 
5
5
  /**
6
6
  * Keccak support with different hash length
7
+ * Uses @noble/hashes for unified implementation
7
8
  *
8
9
  * @class KeccakHasher
9
10
  */
@@ -2,17 +2,19 @@ Object.defineProperty(exports, '__esModule', { value: true });
2
2
  const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
3
3
  const require_encode = require('../encode.cjs');
4
4
  let _ocap_util = require("@ocap/util");
5
- let hash_js = require("hash.js");
5
+ let _noble_hashes_utils_js = require("@noble/hashes/utils.js");
6
+ let _noble_hashes_sha2_js = require("@noble/hashes/sha2.js");
6
7
 
7
8
  //#region src/hasher/sha2.ts
8
9
  const hashFns = {
9
- sha224: hash_js.sha224,
10
- sha256: hash_js.sha256,
11
- sha384: hash_js.sha384,
12
- sha512: hash_js.sha512
10
+ sha224: _noble_hashes_sha2_js.sha224,
11
+ sha256: _noble_hashes_sha2_js.sha256,
12
+ sha384: _noble_hashes_sha2_js.sha384,
13
+ sha512: _noble_hashes_sha2_js.sha512
13
14
  };
14
15
  /**
15
16
  * Sha2 support with different hash length
17
+ * Uses @noble/hashes for better performance
16
18
  *
17
19
  * @class
18
20
  */
@@ -27,11 +29,13 @@ var Sha2Hasher = class {
27
29
  const name = `hash${x}`;
28
30
  const hasher = hashFns[`sha${x}`];
29
31
  const hashFn = (input, round) => {
30
- let inputBytes = input;
32
+ let inputBytes;
31
33
  try {
32
34
  inputBytes = (0, _ocap_util.toUint8Array)(input);
33
- } catch (_err) {}
34
- if (round === 1) return `0x${hasher().update(inputBytes).digest("hex")}`;
35
+ } catch (_err) {
36
+ inputBytes = input;
37
+ }
38
+ if (round === 1) return `0x${(0, _noble_hashes_utils_js.bytesToHex)(hasher(inputBytes))}`;
35
39
  return hashFn(hashFn(inputBytes, 1), round - 1);
36
40
  };
37
41
  this[name] = (data, round = 2, encoding = "hex") => {
@@ -4,6 +4,7 @@ import { BytesType, EncodingType } from "@ocap/util";
4
4
 
5
5
  /**
6
6
  * Sha2 support with different hash length
7
+ * Uses @noble/hashes for better performance
7
8
  *
8
9
  * @class
9
10
  */
@@ -2,12 +2,19 @@ Object.defineProperty(exports, '__esModule', { value: true });
2
2
  const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
3
3
  const require_encode = require('../encode.cjs');
4
4
  let _ocap_util = require("@ocap/util");
5
- let js_sha3 = require("js-sha3");
6
- js_sha3 = require_rolldown_runtime.__toESM(js_sha3);
5
+ let _noble_hashes_sha3_js = require("@noble/hashes/sha3.js");
6
+ let _noble_hashes_utils_js = require("@noble/hashes/utils.js");
7
7
 
8
8
  //#region src/hasher/sha3.ts
9
+ const hashFns = {
10
+ sha3_224: _noble_hashes_sha3_js.sha3_224,
11
+ sha3_256: _noble_hashes_sha3_js.sha3_256,
12
+ sha3_384: _noble_hashes_sha3_js.sha3_384,
13
+ sha3_512: _noble_hashes_sha3_js.sha3_512
14
+ };
9
15
  /**
10
16
  * Sha3 support with different hash length
17
+ * Uses @noble/hashes for unified implementation
11
18
  *
12
19
  * @class Sha3Hasher
13
20
  */
@@ -20,17 +27,19 @@ var Sha3Hasher = class {
20
27
  512
21
28
  ].forEach((x) => {
22
29
  const name = `hash${x}`;
23
- const hasher = js_sha3.default[`sha3_${x}`];
30
+ const hasher = hashFns[`sha3_${x}`];
24
31
  const hashFn = (input, round) => {
25
32
  if (round === 1) return hasher(input);
26
33
  return hashFn(hasher(input), round - 1);
27
34
  };
28
35
  this[name] = (data, round = 1, encoding = "hex") => {
29
- let input = data;
36
+ let input;
30
37
  try {
31
38
  input = (0, _ocap_util.toUint8Array)(data);
32
- } catch (_err) {}
33
- return require_encode.encode(`0x${hashFn(input, round)}`, encoding);
39
+ } catch (_err) {
40
+ input = data;
41
+ }
42
+ return require_encode.encode(`0x${(0, _noble_hashes_utils_js.bytesToHex)(hashFn(input, round))}`, encoding);
34
43
  };
35
44
  });
36
45
  }
@@ -4,6 +4,7 @@ import { BytesType, EncodingType } from "@ocap/util";
4
4
 
5
5
  /**
6
6
  * Sha3 support with different hash length
7
+ * Uses @noble/hashes for unified implementation
7
8
  *
8
9
  * @class Sha3Hasher
9
10
  */