@elizaos/plugin-tee 0.1.9 → 1.0.0-alpha.0

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.
@@ -0,0 +1,139 @@
1
+ // ../../node_modules/@noble/hashes/esm/cryptoNode.js
2
+ import * as nc from "node:crypto";
3
+ var crypto = nc && typeof nc === "object" && "webcrypto" in nc ? nc.webcrypto : nc && typeof nc === "object" && "randomBytes" in nc ? nc : void 0;
4
+
5
+ // ../../node_modules/@noble/hashes/esm/_assert.js
6
+ function anumber(n) {
7
+ if (!Number.isSafeInteger(n) || n < 0)
8
+ throw new Error("positive integer expected, got " + n);
9
+ }
10
+ function isBytes(a) {
11
+ return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array";
12
+ }
13
+ function abytes(b, ...lengths) {
14
+ if (!isBytes(b))
15
+ throw new Error("Uint8Array expected");
16
+ if (lengths.length > 0 && !lengths.includes(b.length))
17
+ throw new Error("Uint8Array expected of length " + lengths + ", got length=" + b.length);
18
+ }
19
+ function ahash(h) {
20
+ if (typeof h !== "function" || typeof h.create !== "function")
21
+ throw new Error("Hash should be wrapped by utils.wrapConstructor");
22
+ anumber(h.outputLen);
23
+ anumber(h.blockLen);
24
+ }
25
+ function aexists(instance, checkFinished = true) {
26
+ if (instance.destroyed)
27
+ throw new Error("Hash instance has been destroyed");
28
+ if (checkFinished && instance.finished)
29
+ throw new Error("Hash#digest() has already been called");
30
+ }
31
+ function aoutput(out, instance) {
32
+ abytes(out);
33
+ const min = instance.outputLen;
34
+ if (out.length < min) {
35
+ throw new Error("digestInto() expects output buffer of length at least " + min);
36
+ }
37
+ }
38
+
39
+ // ../../node_modules/@noble/hashes/esm/utils.js
40
+ function u32(arr) {
41
+ return new Uint32Array(arr.buffer, arr.byteOffset, Math.floor(arr.byteLength / 4));
42
+ }
43
+ function createView(arr) {
44
+ return new DataView(arr.buffer, arr.byteOffset, arr.byteLength);
45
+ }
46
+ function rotr(word, shift) {
47
+ return word << 32 - shift | word >>> shift;
48
+ }
49
+ var isLE = /* @__PURE__ */ (() => new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68)();
50
+ function byteSwap(word) {
51
+ return word << 24 & 4278190080 | word << 8 & 16711680 | word >>> 8 & 65280 | word >>> 24 & 255;
52
+ }
53
+ function byteSwap32(arr) {
54
+ for (let i = 0; i < arr.length; i++) {
55
+ arr[i] = byteSwap(arr[i]);
56
+ }
57
+ }
58
+ function utf8ToBytes(str) {
59
+ if (typeof str !== "string")
60
+ throw new Error("utf8ToBytes expected string, got " + typeof str);
61
+ return new Uint8Array(new TextEncoder().encode(str));
62
+ }
63
+ function toBytes(data) {
64
+ if (typeof data === "string")
65
+ data = utf8ToBytes(data);
66
+ abytes(data);
67
+ return data;
68
+ }
69
+ function concatBytes(...arrays) {
70
+ let sum = 0;
71
+ for (let i = 0; i < arrays.length; i++) {
72
+ const a = arrays[i];
73
+ abytes(a);
74
+ sum += a.length;
75
+ }
76
+ const res = new Uint8Array(sum);
77
+ for (let i = 0, pad = 0; i < arrays.length; i++) {
78
+ const a = arrays[i];
79
+ res.set(a, pad);
80
+ pad += a.length;
81
+ }
82
+ return res;
83
+ }
84
+ var Hash = class {
85
+ // Safe version that clones internal state
86
+ clone() {
87
+ return this._cloneInto();
88
+ }
89
+ };
90
+ function wrapConstructor(hashCons) {
91
+ const hashC = (msg) => hashCons().update(toBytes(msg)).digest();
92
+ const tmp = hashCons();
93
+ hashC.outputLen = tmp.outputLen;
94
+ hashC.blockLen = tmp.blockLen;
95
+ hashC.create = () => hashCons();
96
+ return hashC;
97
+ }
98
+ function wrapXOFConstructorWithOpts(hashCons) {
99
+ const hashC = (msg, opts) => hashCons(opts).update(toBytes(msg)).digest();
100
+ const tmp = hashCons({});
101
+ hashC.outputLen = tmp.outputLen;
102
+ hashC.blockLen = tmp.blockLen;
103
+ hashC.create = (opts) => hashCons(opts);
104
+ return hashC;
105
+ }
106
+ function randomBytes(bytesLength = 32) {
107
+ if (crypto && typeof crypto.getRandomValues === "function") {
108
+ return crypto.getRandomValues(new Uint8Array(bytesLength));
109
+ }
110
+ if (crypto && typeof crypto.randomBytes === "function") {
111
+ return crypto.randomBytes(bytesLength);
112
+ }
113
+ throw new Error("crypto.getRandomValues must be defined");
114
+ }
115
+
116
+ export {
117
+ anumber,
118
+ abytes,
119
+ ahash,
120
+ aexists,
121
+ aoutput,
122
+ u32,
123
+ createView,
124
+ rotr,
125
+ isLE,
126
+ byteSwap32,
127
+ toBytes,
128
+ concatBytes,
129
+ Hash,
130
+ wrapConstructor,
131
+ wrapXOFConstructorWithOpts,
132
+ randomBytes
133
+ };
134
+ /*! Bundled license information:
135
+
136
+ @noble/hashes/esm/utils.js:
137
+ (*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
138
+ */
139
+ //# sourceMappingURL=chunk-672HY72Z.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../node_modules/@noble/hashes/src/cryptoNode.ts","../../../node_modules/@noble/hashes/src/_assert.ts","../../../node_modules/@noble/hashes/src/utils.ts"],"sourcesContent":["/**\n * Internal webcrypto alias.\n * We prefer WebCrypto aka globalThis.crypto, which exists in node.js 16+.\n * Falls back to Node.js built-in crypto for Node.js <=v14.\n * See utils.ts for details.\n * @module\n */\n// @ts-ignore\nimport * as nc from 'node:crypto';\nexport const crypto: any =\n nc && typeof nc === 'object' && 'webcrypto' in nc\n ? (nc.webcrypto as any)\n : nc && typeof nc === 'object' && 'randomBytes' in nc\n ? nc\n : undefined;\n","/**\n * Internal assertion helpers.\n * @module\n */\n\n/** Asserts something is positive integer. */\nfunction anumber(n: number): void {\n if (!Number.isSafeInteger(n) || n < 0) throw new Error('positive integer expected, got ' + n);\n}\n\n/** Is number an Uint8Array? Copied from utils for perf. */\nfunction isBytes(a: unknown): a is Uint8Array {\n return a instanceof Uint8Array || (ArrayBuffer.isView(a) && a.constructor.name === 'Uint8Array');\n}\n\n/** Asserts something is Uint8Array. */\nfunction abytes(b: Uint8Array | undefined, ...lengths: number[]): void {\n if (!isBytes(b)) throw new Error('Uint8Array expected');\n if (lengths.length > 0 && !lengths.includes(b.length))\n throw new Error('Uint8Array expected of length ' + lengths + ', got length=' + b.length);\n}\n\n/** Hash interface. */\nexport type Hash = {\n (data: Uint8Array): Uint8Array;\n blockLen: number;\n outputLen: number;\n create: any;\n};\n\n/** Asserts something is hash */\nfunction ahash(h: Hash): void {\n if (typeof h !== 'function' || typeof h.create !== 'function')\n throw new Error('Hash should be wrapped by utils.wrapConstructor');\n anumber(h.outputLen);\n anumber(h.blockLen);\n}\n\n/** Asserts a hash instance has not been destroyed / finished */\nfunction aexists(instance: any, checkFinished = true): void {\n if (instance.destroyed) throw new Error('Hash instance has been destroyed');\n if (checkFinished && instance.finished) throw new Error('Hash#digest() has already been called');\n}\n\n/** Asserts output is properly-sized byte array */\nfunction aoutput(out: any, instance: any): void {\n abytes(out);\n const min = instance.outputLen;\n if (out.length < min) {\n throw new Error('digestInto() expects output buffer of length at least ' + min);\n }\n}\n\nexport { anumber, abytes, ahash, aexists, aoutput };\n","/**\n * Utilities for hex, bytes, CSPRNG.\n * @module\n */\n/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */\n\n// We use WebCrypto aka globalThis.crypto, which exists in browsers and node.js 16+.\n// node.js versions earlier than v19 don't declare it in global scope.\n// For node.js, package.json#exports field mapping rewrites import\n// from `crypto` to `cryptoNode`, which imports native module.\n// Makes the utils un-importable in browsers without a bundler.\n// Once node.js 18 is deprecated (2025-04-30), we can just drop the import.\nimport { crypto } from '@noble/hashes/crypto';\nimport { abytes } from './_assert.js';\n// export { isBytes } from './_assert.js';\n// We can't reuse isBytes from _assert, because somehow this causes huge perf issues\nexport function isBytes(a: unknown): a is Uint8Array {\n return a instanceof Uint8Array || (ArrayBuffer.isView(a) && a.constructor.name === 'Uint8Array');\n}\n\n// prettier-ignore\nexport type TypedArray = Int8Array | Uint8ClampedArray | Uint8Array |\n Uint16Array | Int16Array | Uint32Array | Int32Array;\n\n// Cast array to different type\nexport function u8(arr: TypedArray): Uint8Array {\n return new Uint8Array(arr.buffer, arr.byteOffset, arr.byteLength);\n}\nexport function u32(arr: TypedArray): Uint32Array {\n return new Uint32Array(arr.buffer, arr.byteOffset, Math.floor(arr.byteLength / 4));\n}\n\n// Cast array to view\nexport function createView(arr: TypedArray): DataView {\n return new DataView(arr.buffer, arr.byteOffset, arr.byteLength);\n}\n\n/** The rotate right (circular right shift) operation for uint32 */\nexport function rotr(word: number, shift: number): number {\n return (word << (32 - shift)) | (word >>> shift);\n}\n/** The rotate left (circular left shift) operation for uint32 */\nexport function rotl(word: number, shift: number): number {\n return (word << shift) | ((word >>> (32 - shift)) >>> 0);\n}\n\n/** Is current platform little-endian? Most are. Big-Endian platform: IBM */\nexport const isLE: boolean = /* @__PURE__ */ (() =>\n new Uint8Array(new Uint32Array([0x11223344]).buffer)[0] === 0x44)();\n// The byte swap operation for uint32\nexport function byteSwap(word: number): number {\n return (\n ((word << 24) & 0xff000000) |\n ((word << 8) & 0xff0000) |\n ((word >>> 8) & 0xff00) |\n ((word >>> 24) & 0xff)\n );\n}\n/** Conditionally byte swap if on a big-endian platform */\nexport const byteSwapIfBE: (n: number) => number = isLE\n ? (n: number) => n\n : (n: number) => byteSwap(n);\n\n/** In place byte swap for Uint32Array */\nexport function byteSwap32(arr: Uint32Array): void {\n for (let i = 0; i < arr.length; i++) {\n arr[i] = byteSwap(arr[i]);\n }\n}\n\n// Array where index 0xf0 (240) is mapped to string 'f0'\nconst hexes = /* @__PURE__ */ Array.from({ length: 256 }, (_, i) =>\n i.toString(16).padStart(2, '0')\n);\n/**\n * Convert byte array to hex string.\n * @example bytesToHex(Uint8Array.from([0xca, 0xfe, 0x01, 0x23])) // 'cafe0123'\n */\nexport function bytesToHex(bytes: Uint8Array): string {\n abytes(bytes);\n // pre-caching improves the speed 6x\n let hex = '';\n for (let i = 0; i < bytes.length; i++) {\n hex += hexes[bytes[i]];\n }\n return hex;\n}\n\n// We use optimized technique to convert hex string to byte array\nconst asciis = { _0: 48, _9: 57, A: 65, F: 70, a: 97, f: 102 } as const;\nfunction asciiToBase16(ch: number): number | undefined {\n if (ch >= asciis._0 && ch <= asciis._9) return ch - asciis._0; // '2' => 50-48\n if (ch >= asciis.A && ch <= asciis.F) return ch - (asciis.A - 10); // 'B' => 66-(65-10)\n if (ch >= asciis.a && ch <= asciis.f) return ch - (asciis.a - 10); // 'b' => 98-(97-10)\n return;\n}\n\n/**\n * Convert hex string to byte array.\n * @example hexToBytes('cafe0123') // Uint8Array.from([0xca, 0xfe, 0x01, 0x23])\n */\nexport function hexToBytes(hex: string): Uint8Array {\n if (typeof hex !== 'string') throw new Error('hex string expected, got ' + typeof hex);\n const hl = hex.length;\n const al = hl / 2;\n if (hl % 2) throw new Error('hex string expected, got unpadded hex of length ' + hl);\n const array = new Uint8Array(al);\n for (let ai = 0, hi = 0; ai < al; ai++, hi += 2) {\n const n1 = asciiToBase16(hex.charCodeAt(hi));\n const n2 = asciiToBase16(hex.charCodeAt(hi + 1));\n if (n1 === undefined || n2 === undefined) {\n const char = hex[hi] + hex[hi + 1];\n throw new Error('hex string expected, got non-hex character \"' + char + '\" at index ' + hi);\n }\n array[ai] = n1 * 16 + n2; // multiply first octet, e.g. 'a3' => 10*16+3 => 160 + 3 => 163\n }\n return array;\n}\n\n/**\n * There is no setImmediate in browser and setTimeout is slow.\n * Call of async fn will return Promise, which will be fullfiled only on\n * next scheduler queue processing step and this is exactly what we need.\n */\nexport const nextTick = async (): Promise<void> => {};\n\n/** Returns control to thread each 'tick' ms to avoid blocking. */\nexport async function asyncLoop(\n iters: number,\n tick: number,\n cb: (i: number) => void\n): Promise<void> {\n let ts = Date.now();\n for (let i = 0; i < iters; i++) {\n cb(i);\n // Date.now() is not monotonic, so in case if clock goes backwards we return return control too\n const diff = Date.now() - ts;\n if (diff >= 0 && diff < tick) continue;\n await nextTick();\n ts += diff;\n }\n}\n\n// Global symbols in both browsers and Node.js since v11\n// See https://github.com/microsoft/TypeScript/issues/31535\ndeclare const TextEncoder: any;\n\n/**\n * Convert JS string to byte array.\n * @example utf8ToBytes('abc') // new Uint8Array([97, 98, 99])\n */\nexport function utf8ToBytes(str: string): Uint8Array {\n if (typeof str !== 'string') throw new Error('utf8ToBytes expected string, got ' + typeof str);\n return new Uint8Array(new TextEncoder().encode(str)); // https://bugzil.la/1681809\n}\n\n/** Accepted input of hash functions. Strings are converted to byte arrays. */\nexport type Input = Uint8Array | string;\n/**\n * Normalizes (non-hex) string or Uint8Array to Uint8Array.\n * Warning: when Uint8Array is passed, it would NOT get copied.\n * Keep in mind for future mutable operations.\n */\nexport function toBytes(data: Input): Uint8Array {\n if (typeof data === 'string') data = utf8ToBytes(data);\n abytes(data);\n return data;\n}\n\n/**\n * Copies several Uint8Arrays into one.\n */\nexport function concatBytes(...arrays: Uint8Array[]): Uint8Array {\n let sum = 0;\n for (let i = 0; i < arrays.length; i++) {\n const a = arrays[i];\n abytes(a);\n sum += a.length;\n }\n const res = new Uint8Array(sum);\n for (let i = 0, pad = 0; i < arrays.length; i++) {\n const a = arrays[i];\n res.set(a, pad);\n pad += a.length;\n }\n return res;\n}\n\n/** For runtime check if class implements interface */\nexport abstract class Hash<T extends Hash<T>> {\n abstract blockLen: number; // Bytes per block\n abstract outputLen: number; // Bytes in output\n abstract update(buf: Input): this;\n // Writes digest into buf\n abstract digestInto(buf: Uint8Array): void;\n abstract digest(): Uint8Array;\n /**\n * Resets internal state. Makes Hash instance unusable.\n * Reset is impossible for keyed hashes if key is consumed into state. If digest is not consumed\n * by user, they will need to manually call `destroy()` when zeroing is necessary.\n */\n abstract destroy(): void;\n /**\n * Clones hash instance. Unsafe: doesn't check whether `to` is valid. Can be used as `clone()`\n * when no options are passed.\n * Reasons to use `_cloneInto` instead of clone: 1) performance 2) reuse instance => all internal\n * buffers are overwritten => causes buffer overwrite which is used for digest in some cases.\n * There are no guarantees for clean-up because it's impossible in JS.\n */\n abstract _cloneInto(to?: T): T;\n // Safe version that clones internal state\n clone(): T {\n return this._cloneInto();\n }\n}\n\n/**\n * XOF: streaming API to read digest in chunks.\n * Same as 'squeeze' in keccak/k12 and 'seek' in blake3, but more generic name.\n * When hash used in XOF mode it is up to user to call '.destroy' afterwards, since we cannot\n * destroy state, next call can require more bytes.\n */\nexport type HashXOF<T extends Hash<T>> = Hash<T> & {\n xof(bytes: number): Uint8Array; // Read 'bytes' bytes from digest stream\n xofInto(buf: Uint8Array): Uint8Array; // read buf.length bytes from digest stream into buf\n};\n\ntype EmptyObj = {};\nexport function checkOpts<T1 extends EmptyObj, T2 extends EmptyObj>(\n defaults: T1,\n opts?: T2\n): T1 & T2 {\n if (opts !== undefined && {}.toString.call(opts) !== '[object Object]')\n throw new Error('Options should be object or undefined');\n const merged = Object.assign(defaults, opts);\n return merged as T1 & T2;\n}\n\n/** Hash function */\nexport type CHash = ReturnType<typeof wrapConstructor>;\n/** Hash function with output */\nexport type CHashO = ReturnType<typeof wrapConstructorWithOpts>;\n/** XOF with output */\nexport type CHashXO = ReturnType<typeof wrapXOFConstructorWithOpts>;\n\n/** Wraps hash function, creating an interface on top of it */\nexport function wrapConstructor<T extends Hash<T>>(\n hashCons: () => Hash<T>\n): {\n (msg: Input): Uint8Array;\n outputLen: number;\n blockLen: number;\n create(): Hash<T>;\n} {\n const hashC = (msg: Input): Uint8Array => hashCons().update(toBytes(msg)).digest();\n const tmp = hashCons();\n hashC.outputLen = tmp.outputLen;\n hashC.blockLen = tmp.blockLen;\n hashC.create = () => hashCons();\n return hashC;\n}\n\nexport function wrapConstructorWithOpts<H extends Hash<H>, T extends Object>(\n hashCons: (opts?: T) => Hash<H>\n): {\n (msg: Input, opts?: T): Uint8Array;\n outputLen: number;\n blockLen: number;\n create(opts: T): Hash<H>;\n} {\n const hashC = (msg: Input, opts?: T): Uint8Array => hashCons(opts).update(toBytes(msg)).digest();\n const tmp = hashCons({} as T);\n hashC.outputLen = tmp.outputLen;\n hashC.blockLen = tmp.blockLen;\n hashC.create = (opts: T) => hashCons(opts);\n return hashC;\n}\n\nexport function wrapXOFConstructorWithOpts<H extends HashXOF<H>, T extends Object>(\n hashCons: (opts?: T) => HashXOF<H>\n): {\n (msg: Input, opts?: T): Uint8Array;\n outputLen: number;\n blockLen: number;\n create(opts: T): HashXOF<H>;\n} {\n const hashC = (msg: Input, opts?: T): Uint8Array => hashCons(opts).update(toBytes(msg)).digest();\n const tmp = hashCons({} as T);\n hashC.outputLen = tmp.outputLen;\n hashC.blockLen = tmp.blockLen;\n hashC.create = (opts: T) => hashCons(opts);\n return hashC;\n}\n\n/** Cryptographically secure PRNG. Uses internal OS-level `crypto.getRandomValues`. */\nexport function randomBytes(bytesLength = 32): Uint8Array {\n if (crypto && typeof crypto.getRandomValues === 'function') {\n return crypto.getRandomValues(new Uint8Array(bytesLength));\n }\n // Legacy Node.js compatibility\n if (crypto && typeof crypto.randomBytes === 'function') {\n return crypto.randomBytes(bytesLength);\n }\n throw new Error('crypto.getRandomValues must be defined');\n}\n"],"mappings":";AAQA,YAAY,QAAQ;AACb,IAAM,SACX,MAAM,OAAO,OAAO,YAAY,eAAe,KACvC,eACJ,MAAM,OAAO,OAAO,YAAY,iBAAiB,KAC/C,KACA;;;ACRR,SAAS,QAAQ,GAAS;AACxB,MAAI,CAAC,OAAO,cAAc,CAAC,KAAK,IAAI;AAAG,UAAM,IAAI,MAAM,oCAAoC,CAAC;AAC9F;AAGA,SAAS,QAAQ,GAAU;AACzB,SAAO,aAAa,cAAe,YAAY,OAAO,CAAC,KAAK,EAAE,YAAY,SAAS;AACrF;AAGA,SAAS,OAAO,MAA8B,SAAiB;AAC7D,MAAI,CAAC,QAAQ,CAAC;AAAG,UAAM,IAAI,MAAM,qBAAqB;AACtD,MAAI,QAAQ,SAAS,KAAK,CAAC,QAAQ,SAAS,EAAE,MAAM;AAClD,UAAM,IAAI,MAAM,mCAAmC,UAAU,kBAAkB,EAAE,MAAM;AAC3F;AAWA,SAAS,MAAM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Y;AACtD,WAAO,OAAO,YAAY,WAAW;EACvC;AACA,QAAM,IAAI,MAAM,wCAAwC;AAC1D;","names":[]}
@@ -1,99 +1,21 @@
1
+ import {
2
+ Hash,
3
+ abytes,
4
+ aexists,
5
+ ahash,
6
+ aoutput,
7
+ concatBytes,
8
+ createView,
9
+ randomBytes,
10
+ rotr,
11
+ toBytes,
12
+ wrapConstructor
13
+ } from "./chunk-672HY72Z.js";
1
14
  import {
2
15
  __export
3
16
  } from "./chunk-PR4QN5HX.js";
4
17
 
5
- // ../../node_modules/viem/node_modules/@noble/curves/node_modules/@noble/hashes/esm/_assert.js
6
- function anumber(n) {
7
- if (!Number.isSafeInteger(n) || n < 0)
8
- throw new Error("positive integer expected, got " + n);
9
- }
10
- function isBytes(a) {
11
- return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array";
12
- }
13
- function abytes(b, ...lengths) {
14
- if (!isBytes(b))
15
- throw new Error("Uint8Array expected");
16
- if (lengths.length > 0 && !lengths.includes(b.length))
17
- throw new Error("Uint8Array expected of length " + lengths + ", got length=" + b.length);
18
- }
19
- function ahash(h) {
20
- if (typeof h !== "function" || typeof h.create !== "function")
21
- throw new Error("Hash should be wrapped by utils.wrapConstructor");
22
- anumber(h.outputLen);
23
- anumber(h.blockLen);
24
- }
25
- function aexists(instance, checkFinished = true) {
26
- if (instance.destroyed)
27
- throw new Error("Hash instance has been destroyed");
28
- if (checkFinished && instance.finished)
29
- throw new Error("Hash#digest() has already been called");
30
- }
31
- function aoutput(out, instance) {
32
- abytes(out);
33
- const min = instance.outputLen;
34
- if (out.length < min) {
35
- throw new Error("digestInto() expects output buffer of length at least " + min);
36
- }
37
- }
38
-
39
- // ../../node_modules/viem/node_modules/@noble/curves/node_modules/@noble/hashes/esm/cryptoNode.js
40
- import * as nc from "node:crypto";
41
- var crypto = nc && typeof nc === "object" && "webcrypto" in nc ? nc.webcrypto : nc && typeof nc === "object" && "randomBytes" in nc ? nc : void 0;
42
-
43
- // ../../node_modules/viem/node_modules/@noble/curves/node_modules/@noble/hashes/esm/utils.js
44
- var createView = (arr) => new DataView(arr.buffer, arr.byteOffset, arr.byteLength);
45
- var rotr = (word, shift) => word << 32 - shift | word >>> shift;
46
- function utf8ToBytes(str) {
47
- if (typeof str !== "string")
48
- throw new Error("utf8ToBytes expected string, got " + typeof str);
49
- return new Uint8Array(new TextEncoder().encode(str));
50
- }
51
- function toBytes(data) {
52
- if (typeof data === "string")
53
- data = utf8ToBytes(data);
54
- abytes(data);
55
- return data;
56
- }
57
- function concatBytes(...arrays) {
58
- let sum = 0;
59
- for (let i = 0; i < arrays.length; i++) {
60
- const a = arrays[i];
61
- abytes(a);
62
- sum += a.length;
63
- }
64
- const res = new Uint8Array(sum);
65
- for (let i = 0, pad = 0; i < arrays.length; i++) {
66
- const a = arrays[i];
67
- res.set(a, pad);
68
- pad += a.length;
69
- }
70
- return res;
71
- }
72
- var Hash = class {
73
- // Safe version that clones internal state
74
- clone() {
75
- return this._cloneInto();
76
- }
77
- };
78
- function wrapConstructor(hashCons) {
79
- const hashC = (msg) => hashCons().update(toBytes(msg)).digest();
80
- const tmp = hashCons();
81
- hashC.outputLen = tmp.outputLen;
82
- hashC.blockLen = tmp.blockLen;
83
- hashC.create = () => hashCons();
84
- return hashC;
85
- }
86
- function randomBytes(bytesLength = 32) {
87
- if (crypto && typeof crypto.getRandomValues === "function") {
88
- return crypto.getRandomValues(new Uint8Array(bytesLength));
89
- }
90
- if (crypto && typeof crypto.randomBytes === "function") {
91
- return crypto.randomBytes(bytesLength);
92
- }
93
- throw new Error("crypto.getRandomValues must be defined");
94
- }
95
-
96
- // ../../node_modules/viem/node_modules/@noble/curves/node_modules/@noble/hashes/esm/_md.js
18
+ // ../../node_modules/@noble/hashes/esm/_md.js
97
19
  function setBigUint64(view, byteOffset, value, isLE) {
98
20
  if (typeof view.setBigUint64 === "function")
99
21
  return view.setBigUint64(byteOffset, value, isLE);
@@ -106,8 +28,12 @@ function setBigUint64(view, byteOffset, value, isLE) {
106
28
  view.setUint32(byteOffset + h, wh, isLE);
107
29
  view.setUint32(byteOffset + l, wl, isLE);
108
30
  }
109
- var Chi = (a, b, c) => a & b ^ ~a & c;
110
- var Maj = (a, b, c) => a & b ^ a & c ^ b & c;
31
+ function Chi(a, b, c) {
32
+ return a & b ^ ~a & c;
33
+ }
34
+ function Maj(a, b, c) {
35
+ return a & b ^ a & c ^ b & c;
36
+ }
111
37
  var HashMD = class extends Hash {
112
38
  constructor(blockLen, outputLen, padOffset, isLE) {
113
39
  super();
@@ -195,7 +121,7 @@ var HashMD = class extends Hash {
195
121
  }
196
122
  };
197
123
 
198
- // ../../node_modules/viem/node_modules/@noble/curves/node_modules/@noble/hashes/esm/sha256.js
124
+ // ../../node_modules/@noble/hashes/esm/sha256.js
199
125
  var SHA256_K = /* @__PURE__ */ new Uint32Array([
200
126
  1116352408,
201
127
  1899447441,
@@ -345,7 +271,7 @@ var SHA256 = class extends HashMD {
345
271
  };
346
272
  var sha256 = /* @__PURE__ */ wrapConstructor(() => new SHA256());
347
273
 
348
- // ../../node_modules/viem/node_modules/@noble/curves/node_modules/@noble/hashes/esm/hmac.js
274
+ // ../../node_modules/@noble/hashes/esm/hmac.js
349
275
  var HMAC = class extends Hash {
350
276
  constructor(hash, _key) {
351
277
  super();
@@ -410,7 +336,7 @@ var HMAC = class extends Hash {
410
336
  var hmac = (hash, key, message) => new HMAC(hash, key).update(message).digest();
411
337
  hmac.create = (hash, key) => new HMAC(hash, key);
412
338
 
413
- // ../../node_modules/viem/node_modules/@noble/curves/esm/abstract/utils.js
339
+ // ../../node_modules/@noble/curves/esm/abstract/utils.js
414
340
  var utils_exports = {};
415
341
  __export(utils_exports, {
416
342
  aInRange: () => aInRange,
@@ -430,24 +356,24 @@ __export(utils_exports, {
430
356
  hexToBytes: () => hexToBytes,
431
357
  hexToNumber: () => hexToNumber,
432
358
  inRange: () => inRange,
433
- isBytes: () => isBytes2,
359
+ isBytes: () => isBytes,
434
360
  memoized: () => memoized,
435
361
  notImplemented: () => notImplemented,
436
362
  numberToBytesBE: () => numberToBytesBE,
437
363
  numberToBytesLE: () => numberToBytesLE,
438
364
  numberToHexUnpadded: () => numberToHexUnpadded,
439
365
  numberToVarBytesBE: () => numberToVarBytesBE,
440
- utf8ToBytes: () => utf8ToBytes2,
366
+ utf8ToBytes: () => utf8ToBytes,
441
367
  validateObject: () => validateObject
442
368
  });
443
369
  var _0n = /* @__PURE__ */ BigInt(0);
444
370
  var _1n = /* @__PURE__ */ BigInt(1);
445
371
  var _2n = /* @__PURE__ */ BigInt(2);
446
- function isBytes2(a) {
372
+ function isBytes(a) {
447
373
  return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array";
448
374
  }
449
375
  function abytes2(item) {
450
- if (!isBytes2(item))
376
+ if (!isBytes(item))
451
377
  throw new Error("Uint8Array expected");
452
378
  }
453
379
  function abool(title, value) {
@@ -525,7 +451,7 @@ function ensureBytes(title, hex, expectedLength) {
525
451
  } catch (e) {
526
452
  throw new Error(title + " must be hex string or Uint8Array, cause: " + e);
527
453
  }
528
- } else if (isBytes2(hex)) {
454
+ } else if (isBytes(hex)) {
529
455
  res = Uint8Array.from(hex);
530
456
  } else {
531
457
  throw new Error(title + " must be hex string or Uint8Array");
@@ -558,7 +484,7 @@ function equalBytes(a, b) {
558
484
  diff |= a[i] ^ b[i];
559
485
  return diff === 0;
560
486
  }
561
- function utf8ToBytes2(str) {
487
+ function utf8ToBytes(str) {
562
488
  if (typeof str !== "string")
563
489
  throw new Error("string expected");
564
490
  return new Uint8Array(new TextEncoder().encode(str));
@@ -639,7 +565,7 @@ var validatorFns = {
639
565
  function: (val) => typeof val === "function",
640
566
  boolean: (val) => typeof val === "boolean",
641
567
  string: (val) => typeof val === "string",
642
- stringOrUint8Array: (val) => typeof val === "string" || isBytes2(val),
568
+ stringOrUint8Array: (val) => typeof val === "string" || isBytes(val),
643
569
  isSafeInteger: (val) => Number.isSafeInteger(val),
644
570
  array: (val) => Array.isArray(val),
645
571
  field: (val, object) => object.Fp.isValid(val),
@@ -678,7 +604,7 @@ function memoized(fn) {
678
604
  };
679
605
  }
680
606
 
681
- // ../../node_modules/viem/node_modules/@noble/curves/esm/abstract/modular.js
607
+ // ../../node_modules/@noble/curves/esm/abstract/modular.js
682
608
  var _0n2 = BigInt(0);
683
609
  var _1n2 = BigInt(1);
684
610
  var _2n2 = /* @__PURE__ */ BigInt(2);
@@ -887,6 +813,7 @@ function Field(ORDER, bitLen2, isLE = false, redef = {}) {
887
813
  let sqrtP;
888
814
  const f = Object.freeze({
889
815
  ORDER,
816
+ isLE,
890
817
  BITS,
891
818
  BYTES,
892
819
  MASK: bitMask(BITS),
@@ -948,12 +875,12 @@ function mapHashToField(key, fieldOrder, isLE = false) {
948
875
  const minLen = getMinHashLength(fieldOrder);
949
876
  if (len < 16 || len < minLen || len > 1024)
950
877
  throw new Error("expected " + minLen + "-1024 bytes of input, got " + len);
951
- const num2 = isLE ? bytesToNumberBE(key) : bytesToNumberLE(key);
878
+ const num2 = isLE ? bytesToNumberLE(key) : bytesToNumberBE(key);
952
879
  const reduced = mod(num2, fieldOrder - _1n2) + _1n2;
953
880
  return isLE ? numberToBytesLE(reduced, fieldLen) : numberToBytesBE(reduced, fieldLen);
954
881
  }
955
882
 
956
- // ../../node_modules/viem/node_modules/@noble/curves/esm/abstract/curve.js
883
+ // ../../node_modules/@noble/curves/esm/abstract/curve.js
957
884
  var _0n3 = BigInt(0);
958
885
  var _1n3 = BigInt(1);
959
886
  function constTimeNegate(condition, item) {
@@ -1180,7 +1107,7 @@ function validateBasic(curve) {
1180
1107
  });
1181
1108
  }
1182
1109
 
1183
- // ../../node_modules/viem/node_modules/@noble/curves/esm/abstract/weierstrass.js
1110
+ // ../../node_modules/@noble/curves/esm/abstract/weierstrass.js
1184
1111
  function validateSigVerOpts(opts) {
1185
1112
  if (opts.lowS !== void 0)
1186
1113
  abool("lowS", opts.lowS);
@@ -1213,13 +1140,14 @@ function validatePointOpts(curve) {
1213
1140
  return Object.freeze({ ...opts });
1214
1141
  }
1215
1142
  var { bytesToNumberBE: b2n, hexToBytes: h2b } = utils_exports;
1143
+ var DERErr = class extends Error {
1144
+ constructor(m = "") {
1145
+ super(m);
1146
+ }
1147
+ };
1216
1148
  var DER = {
1217
1149
  // asn.1 DER encoding utils
1218
- Err: class DERErr extends Error {
1219
- constructor(m = "") {
1220
- super(m);
1221
- }
1222
- },
1150
+ Err: DERErr,
1223
1151
  // Basic building block is TLV (Tag-Length-Value)
1224
1152
  _tlv: {
1225
1153
  encode: (tag, data) => {
@@ -1351,7 +1279,7 @@ function weierstrassPoints(opts) {
1351
1279
  function normPrivateKeyToScalar(key) {
1352
1280
  const { allowedPrivateKeyLengths: lengths, nByteLength, wrapPrivateKey, n: N } = CURVE;
1353
1281
  if (lengths && typeof key !== "bigint") {
1354
- if (isBytes2(key))
1282
+ if (isBytes(key))
1355
1283
  key = bytesToHex(key);
1356
1284
  if (typeof key !== "string" || !lengths.includes(key.length))
1357
1285
  throw new Error("invalid private key");
@@ -1900,7 +1828,7 @@ function weierstrass(curveDef) {
1900
1828
  return Point2.fromPrivateKey(privateKey).toRawBytes(isCompressed);
1901
1829
  }
1902
1830
  function isProbPub(item) {
1903
- const arr = isBytes2(item);
1831
+ const arr = isBytes(item);
1904
1832
  const str = typeof item === "string";
1905
1833
  const len = (arr || str) && item.length;
1906
1834
  if (arr)
@@ -1995,7 +1923,7 @@ function weierstrass(curveDef) {
1995
1923
  throw new Error("options.strict was renamed to lowS");
1996
1924
  if (format !== void 0 && format !== "compact" && format !== "der")
1997
1925
  throw new Error("format must be compact or der");
1998
- const isHex = typeof sg === "string" || isBytes2(sg);
1926
+ const isHex = typeof sg === "string" || isBytes(sg);
1999
1927
  const isObj = !isHex && !format && typeof sg === "object" && sg !== null && typeof sg.r === "bigint" && typeof sg.s === "bigint";
2000
1928
  if (!isHex && !isObj)
2001
1929
  throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");
@@ -2147,7 +2075,7 @@ function mapToCurveSimpleSWU(Fp, opts) {
2147
2075
  };
2148
2076
  }
2149
2077
 
2150
- // ../../node_modules/viem/node_modules/@noble/curves/esm/_shortw_utils.js
2078
+ // ../../node_modules/@noble/curves/esm/_shortw_utils.js
2151
2079
  function getHash(hash) {
2152
2080
  return {
2153
2081
  hash,
@@ -2157,10 +2085,10 @@ function getHash(hash) {
2157
2085
  }
2158
2086
  function createCurve(curveDef, defHash) {
2159
2087
  const create = (hash) => weierstrass({ ...curveDef, ...getHash(hash) });
2160
- return Object.freeze({ ...create(defHash), create });
2088
+ return { ...create(defHash), create };
2161
2089
  }
2162
2090
 
2163
- // ../../node_modules/viem/node_modules/@noble/curves/esm/abstract/hash-to-curve.js
2091
+ // ../../node_modules/@noble/curves/esm/abstract/hash-to-curve.js
2164
2092
  var os2ip = bytesToNumberBE;
2165
2093
  function i2osp(value, length) {
2166
2094
  anum(value);
@@ -2190,7 +2118,7 @@ function expand_message_xmd(msg, DST, lenInBytes, H) {
2190
2118
  abytes2(DST);
2191
2119
  anum(lenInBytes);
2192
2120
  if (DST.length > 255)
2193
- DST = H(concatBytes2(utf8ToBytes2("H2C-OVERSIZE-DST-"), DST));
2121
+ DST = H(concatBytes2(utf8ToBytes("H2C-OVERSIZE-DST-"), DST));
2194
2122
  const { outputLen: b_in_bytes, blockLen: r_in_bytes } = H;
2195
2123
  const ell = Math.ceil(lenInBytes / b_in_bytes);
2196
2124
  if (lenInBytes > 65535 || ell > 255)
@@ -2214,7 +2142,7 @@ function expand_message_xof(msg, DST, lenInBytes, k, H) {
2214
2142
  anum(lenInBytes);
2215
2143
  if (DST.length > 255) {
2216
2144
  const dkLen = Math.ceil(2 * k / 8);
2217
- DST = H.create({ dkLen }).update(utf8ToBytes2("H2C-OVERSIZE-DST-")).update(DST).digest();
2145
+ DST = H.create({ dkLen }).update(utf8ToBytes("H2C-OVERSIZE-DST-")).update(DST).digest();
2218
2146
  }
2219
2147
  if (lenInBytes > 65535 || DST.length > 255)
2220
2148
  throw new Error("expand_message_xof: invalid lenInBytes");
@@ -2231,7 +2159,7 @@ function hash_to_field(msg, count, options) {
2231
2159
  const { p, k, m, hash, expand, DST: _DST } = options;
2232
2160
  abytes2(msg);
2233
2161
  anum(count);
2234
- const DST = typeof _DST === "string" ? utf8ToBytes2(_DST) : _DST;
2162
+ const DST = typeof _DST === "string" ? utf8ToBytes(_DST) : _DST;
2235
2163
  const log2p = p.toString(2).length;
2236
2164
  const L = Math.ceil((log2p + k) / 8);
2237
2165
  const len_in_bytes = count * m * L;
@@ -2302,7 +2230,7 @@ function createHasher(Point2, mapToCurve, def) {
2302
2230
  };
2303
2231
  }
2304
2232
 
2305
- // ../../node_modules/viem/node_modules/@noble/curves/esm/secp256k1.js
2233
+ // ../../node_modules/@noble/curves/esm/secp256k1.js
2306
2234
  var secp256k1P = BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f");
2307
2235
  var secp256k1N = BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141");
2308
2236
  var _1n5 = BigInt(1);
@@ -2335,7 +2263,6 @@ var secp256k1 = createCurve({
2335
2263
  a: BigInt(0),
2336
2264
  // equation params: a, b
2337
2265
  b: BigInt(7),
2338
- // Seem to be rigid: bitcointalk.org/index.php?topic=289795.msg3183975#msg3183975
2339
2266
  Fp: Fpk1,
2340
2267
  // Field's prime: 2n**256n - 2n**32n - 2n**9n - 2n**8n - 2n**7n - 2n**6n - 2n**4n - 1n
2341
2268
  n: secp256k1N,
@@ -2347,13 +2274,8 @@ var secp256k1 = createCurve({
2347
2274
  // Cofactor
2348
2275
  lowS: true,
2349
2276
  // Allow only low-S signatures by default in sign() and verify()
2350
- /**
2351
- * secp256k1 belongs to Koblitz curves: it has efficiently computable endomorphism.
2352
- * Endomorphism uses 2x less RAM, speeds up precomputation by 2x and ECDH / key recovery by 20%.
2353
- * For precomputed wNAF it trades off 1/2 init time & 1/3 ram for 20% perf hit.
2354
- * Explanation: https://gist.github.com/paulmillr/eb670806793e84df628a7c434a873066
2355
- */
2356
2277
  endo: {
2278
+ // Endomorphism, see above
2357
2279
  beta: BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),
2358
2280
  splitScalar: (k) => {
2359
2281
  const n = secp256k1N;
@@ -2525,6 +2447,7 @@ var hashToCurve = /* @__PURE__ */ (() => htf.hashToCurve)();
2525
2447
  var encodeToCurve = /* @__PURE__ */ (() => htf.encodeToCurve)();
2526
2448
 
2527
2449
  export {
2450
+ sha256,
2528
2451
  secp256k1,
2529
2452
  schnorr,
2530
2453
  hashToCurve,
@@ -2532,9 +2455,6 @@ export {
2532
2455
  };
2533
2456
  /*! Bundled license information:
2534
2457
 
2535
- @noble/hashes/esm/utils.js:
2536
- (*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
2537
-
2538
2458
  @noble/curves/esm/abstract/utils.js:
2539
2459
  (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
2540
2460
 
@@ -2553,4 +2473,4 @@ export {
2553
2473
  @noble/curves/esm/secp256k1.js:
2554
2474
  (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
2555
2475
  */
2556
- //# sourceMappingURL=chunk-4L6P6TY5.js.map
2476
+ //# sourceMappingURL=chunk-LCSUOOZR.js.map