@primust/verifier 1.0.0 → 1.0.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/dist/chunk-LTWQK3HT.js +432 -0
- package/dist/chunk-ZADQUKKN.js +2963 -0
- package/dist/cli.d.ts +3 -2
- package/dist/cli.js +309 -361
- package/dist/index.d.ts +335 -13
- package/dist/index.js +1181 -13
- package/dist/v29-envelope-GFVVA2S6.js +42 -0
- package/package.json +7 -8
- package/dist/bounded-trace.d.ts +0 -46
- package/dist/bounded-trace.d.ts.map +0 -1
- package/dist/bounded-trace.js +0 -558
- package/dist/bounded-trace.js.map +0 -1
- package/dist/cli.d.ts.map +0 -1
- package/dist/cli.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/key-cache.d.ts +0 -20
- package/dist/key-cache.d.ts.map +0 -1
- package/dist/key-cache.js +0 -68
- package/dist/key-cache.js.map +0 -1
- package/dist/scoped.d.ts +0 -35
- package/dist/scoped.d.ts.map +0 -1
- package/dist/scoped.js +0 -582
- package/dist/scoped.js.map +0 -1
- package/dist/types.d.ts +0 -60
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -5
- package/dist/types.js.map +0 -1
- package/dist/upstream_resolver.d.ts +0 -60
- package/dist/upstream_resolver.d.ts.map +0 -1
- package/dist/upstream_resolver.js +0 -126
- package/dist/upstream_resolver.js.map +0 -1
- package/dist/v29-envelope.d.ts +0 -55
- package/dist/v29-envelope.d.ts.map +0 -1
- package/dist/v29-envelope.js +0 -450
- package/dist/v29-envelope.js.map +0 -1
- package/dist/verifier.d.ts +0 -36
- package/dist/verifier.d.ts.map +0 -1
- package/dist/verifier.js +0 -1235
- package/dist/verifier.js.map +0 -1
- package/dist/verifier.test.d.ts +0 -2
- package/dist/verifier.test.d.ts.map +0 -1
- package/dist/verifier.test.js +0 -395
- package/dist/verifier.test.js.map +0 -1
- package/dist/verify-html-template.d.ts +0 -45
- package/dist/verify-html-template.d.ts.map +0 -1
- package/dist/verify-html-template.js +0 -182
- package/dist/verify-html-template.js.map +0 -1
|
@@ -0,0 +1,2963 @@
|
|
|
1
|
+
// src/key-cache.ts
|
|
2
|
+
import { readFileSync, existsSync } from "fs";
|
|
3
|
+
var cache = /* @__PURE__ */ new Map();
|
|
4
|
+
var DEFAULT_TRUSTED_HOSTS = /* @__PURE__ */ new Set([
|
|
5
|
+
"keys.primust.com",
|
|
6
|
+
"keys.eu.primust.com"
|
|
7
|
+
]);
|
|
8
|
+
function trustedHosts() {
|
|
9
|
+
const env = globalThis.process?.env?.PRIMUST_TRUST_ROOT_HOSTS;
|
|
10
|
+
if (!env || !env.trim()) return DEFAULT_TRUSTED_HOSTS;
|
|
11
|
+
return new Set(env.split(",").map((h2) => h2.trim()).filter(Boolean));
|
|
12
|
+
}
|
|
13
|
+
function isTrustedKeyUrl(rawUrl) {
|
|
14
|
+
try {
|
|
15
|
+
const u = new URL(rawUrl);
|
|
16
|
+
if (u.protocol !== "https:") return false;
|
|
17
|
+
return trustedHosts().has(u.host);
|
|
18
|
+
} catch {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
function seedKeyCache(kid, publicKey) {
|
|
23
|
+
cache.set(kid, publicKey);
|
|
24
|
+
}
|
|
25
|
+
async function getKey(kid, publicKeyUrl, trustRoot) {
|
|
26
|
+
if (trustRoot) {
|
|
27
|
+
if (existsSync(trustRoot)) {
|
|
28
|
+
return readFileSync(trustRoot, "utf-8").trim();
|
|
29
|
+
}
|
|
30
|
+
return trustRoot.trim();
|
|
31
|
+
}
|
|
32
|
+
const cached = cache.get(kid);
|
|
33
|
+
if (cached) return cached;
|
|
34
|
+
if (!publicKeyUrl) {
|
|
35
|
+
throw new Error(`No public_key_url for kid=${kid}`);
|
|
36
|
+
}
|
|
37
|
+
if (!isTrustedKeyUrl(publicKeyUrl)) {
|
|
38
|
+
throw new Error(
|
|
39
|
+
`Refusing to fetch verification key from untrusted host: ${publicKeyUrl}. Pass an explicit trust_root or set PRIMUST_TRUST_ROOT_HOSTS to allow this host.`
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
let lastError = null;
|
|
43
|
+
for (let attempt = 0; attempt < 3; attempt++) {
|
|
44
|
+
try {
|
|
45
|
+
const resp = await fetch(publicKeyUrl, {
|
|
46
|
+
headers: { Accept: "application/x-pem-file" },
|
|
47
|
+
signal: AbortSignal.timeout(1e4)
|
|
48
|
+
});
|
|
49
|
+
if (!resp.ok) {
|
|
50
|
+
throw new Error(`HTTP ${resp.status}`);
|
|
51
|
+
}
|
|
52
|
+
const pem = (await resp.text()).trim();
|
|
53
|
+
if (!pem) {
|
|
54
|
+
throw new Error("Empty response");
|
|
55
|
+
}
|
|
56
|
+
cache.set(kid, pem);
|
|
57
|
+
return pem;
|
|
58
|
+
} catch (e) {
|
|
59
|
+
lastError = e instanceof Error ? e : new Error(String(e));
|
|
60
|
+
if (attempt < 2) {
|
|
61
|
+
await new Promise((r) => setTimeout(r, 500 * (attempt + 1)));
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
throw new Error(`Failed to fetch key from ${publicKeyUrl} after 3 attempts: ${lastError?.message}`);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// src/verifier.ts
|
|
69
|
+
import { createHash, createPublicKey } from "crypto";
|
|
70
|
+
|
|
71
|
+
// ../artifact-core/dist/canonical.js
|
|
72
|
+
function canonical(value) {
|
|
73
|
+
return serializeValue(value);
|
|
74
|
+
}
|
|
75
|
+
function serializeValue(value) {
|
|
76
|
+
if (value === null) {
|
|
77
|
+
return "null";
|
|
78
|
+
}
|
|
79
|
+
switch (typeof value) {
|
|
80
|
+
case "string":
|
|
81
|
+
return JSON.stringify(value);
|
|
82
|
+
case "number":
|
|
83
|
+
if (!Number.isFinite(value)) {
|
|
84
|
+
throw new TypeError(`canonical: cannot serialize ${value} (NaN/Infinity are not valid JSON)`);
|
|
85
|
+
}
|
|
86
|
+
return JSON.stringify(value);
|
|
87
|
+
case "boolean":
|
|
88
|
+
return value ? "true" : "false";
|
|
89
|
+
case "object":
|
|
90
|
+
if (Array.isArray(value)) {
|
|
91
|
+
return serializeArray(value);
|
|
92
|
+
}
|
|
93
|
+
if (value instanceof Date) {
|
|
94
|
+
throw new TypeError("canonical: Date objects must be converted to ISO 8601 strings before serialization");
|
|
95
|
+
}
|
|
96
|
+
if (value instanceof Uint8Array || typeof Buffer !== "undefined" && Buffer.isBuffer(value)) {
|
|
97
|
+
throw new TypeError("canonical: byte arrays must be base64url-encoded before serialization");
|
|
98
|
+
}
|
|
99
|
+
return serializeObject(value);
|
|
100
|
+
case "undefined":
|
|
101
|
+
throw new TypeError("canonical: undefined is not valid JSON");
|
|
102
|
+
case "function":
|
|
103
|
+
throw new TypeError("canonical: functions are not valid JSON");
|
|
104
|
+
case "symbol":
|
|
105
|
+
throw new TypeError("canonical: symbols are not valid JSON");
|
|
106
|
+
case "bigint":
|
|
107
|
+
throw new TypeError("canonical: BigInt must be converted to string or number before serialization");
|
|
108
|
+
default:
|
|
109
|
+
throw new TypeError(`canonical: unsupported type ${typeof value}`);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
function serializeObject(obj) {
|
|
113
|
+
const keys = Object.keys(obj).sort();
|
|
114
|
+
const pairs = [];
|
|
115
|
+
for (const key of keys) {
|
|
116
|
+
const val = obj[key];
|
|
117
|
+
if (val === void 0) {
|
|
118
|
+
continue;
|
|
119
|
+
}
|
|
120
|
+
pairs.push(`${JSON.stringify(key)}:${serializeValue(val)}`);
|
|
121
|
+
}
|
|
122
|
+
return `{${pairs.join(",")}}`;
|
|
123
|
+
}
|
|
124
|
+
function serializeArray(arr) {
|
|
125
|
+
const elements = [];
|
|
126
|
+
for (const item of arr) {
|
|
127
|
+
elements.push(serializeValue(item));
|
|
128
|
+
}
|
|
129
|
+
return `[${elements.join(",")}]`;
|
|
130
|
+
}
|
|
131
|
+
function canonicalLegacy(value) {
|
|
132
|
+
return serializeValueLegacy(value);
|
|
133
|
+
}
|
|
134
|
+
function serializeValueLegacy(value) {
|
|
135
|
+
if (value === null)
|
|
136
|
+
return "null";
|
|
137
|
+
switch (typeof value) {
|
|
138
|
+
case "string":
|
|
139
|
+
return JSON.stringify(value);
|
|
140
|
+
case "number":
|
|
141
|
+
if (!Number.isFinite(value)) {
|
|
142
|
+
throw new TypeError(`canonical_legacy: cannot serialize ${value} (NaN/Infinity are not valid JSON)`);
|
|
143
|
+
}
|
|
144
|
+
return pythonFloatRepr(value);
|
|
145
|
+
case "boolean":
|
|
146
|
+
return value ? "true" : "false";
|
|
147
|
+
case "object":
|
|
148
|
+
if (Array.isArray(value)) {
|
|
149
|
+
return "[" + value.map((item) => serializeValueLegacy(item)).join(",") + "]";
|
|
150
|
+
}
|
|
151
|
+
if (value instanceof Date) {
|
|
152
|
+
throw new TypeError("canonical_legacy: Date objects must be ISO strings");
|
|
153
|
+
}
|
|
154
|
+
if (value instanceof Uint8Array || typeof Buffer !== "undefined" && Buffer.isBuffer(value)) {
|
|
155
|
+
throw new TypeError("canonical_legacy: byte arrays must be base64url");
|
|
156
|
+
}
|
|
157
|
+
return serializeObjectLegacy(value);
|
|
158
|
+
case "undefined":
|
|
159
|
+
throw new TypeError("canonical_legacy: undefined is not valid JSON");
|
|
160
|
+
default:
|
|
161
|
+
throw new TypeError(`canonical_legacy: unsupported type ${typeof value}`);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
function serializeObjectLegacy(obj) {
|
|
165
|
+
const keys = Object.keys(obj).sort();
|
|
166
|
+
const pairs = [];
|
|
167
|
+
for (const key of keys) {
|
|
168
|
+
const val = obj[key];
|
|
169
|
+
if (val === void 0)
|
|
170
|
+
continue;
|
|
171
|
+
pairs.push(`${JSON.stringify(key)}:${serializeValueLegacy(val)}`);
|
|
172
|
+
}
|
|
173
|
+
return `{${pairs.join(",")}}`;
|
|
174
|
+
}
|
|
175
|
+
function pythonFloatRepr(n) {
|
|
176
|
+
if (Number.isInteger(n) && !Object.is(n, -0)) {
|
|
177
|
+
if (Math.abs(n) < 1e16) {
|
|
178
|
+
return `${n.toFixed(1)}`;
|
|
179
|
+
}
|
|
180
|
+
return pythonScientific(n);
|
|
181
|
+
}
|
|
182
|
+
if (Object.is(n, -0))
|
|
183
|
+
return "-0.0";
|
|
184
|
+
if (Math.abs(n) >= 1e16 || n !== 0 && Math.abs(n) < 1e-4) {
|
|
185
|
+
return pythonScientific(n);
|
|
186
|
+
}
|
|
187
|
+
return n.toString();
|
|
188
|
+
}
|
|
189
|
+
function pythonScientific(n) {
|
|
190
|
+
const s = n.toExponential();
|
|
191
|
+
return s.replace(/e([+-])(\d)$/, "e$10$2");
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
// ../../node_modules/.pnpm/@noble+ed25519@2.3.0/node_modules/@noble/ed25519/index.js
|
|
195
|
+
var ed25519_CURVE = {
|
|
196
|
+
p: 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffedn,
|
|
197
|
+
n: 0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3edn,
|
|
198
|
+
h: 8n,
|
|
199
|
+
a: 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffecn,
|
|
200
|
+
d: 0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3n,
|
|
201
|
+
Gx: 0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51an,
|
|
202
|
+
Gy: 0x6666666666666666666666666666666666666666666666666666666666666658n
|
|
203
|
+
};
|
|
204
|
+
var { p: P, n: N, Gx, Gy, a: _a, d: _d } = ed25519_CURVE;
|
|
205
|
+
var h = 8n;
|
|
206
|
+
var L = 32;
|
|
207
|
+
var L2 = 64;
|
|
208
|
+
var err = (m = "") => {
|
|
209
|
+
throw new Error(m);
|
|
210
|
+
};
|
|
211
|
+
var isBig = (n) => typeof n === "bigint";
|
|
212
|
+
var isStr = (s) => typeof s === "string";
|
|
213
|
+
var isBytes = (a) => a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array";
|
|
214
|
+
var abytes = (a, l) => !isBytes(a) || typeof l === "number" && l > 0 && a.length !== l ? err("Uint8Array expected") : a;
|
|
215
|
+
var u8n = (len) => new Uint8Array(len);
|
|
216
|
+
var u8fr = (buf) => Uint8Array.from(buf);
|
|
217
|
+
var padh = (n, pad) => n.toString(16).padStart(pad, "0");
|
|
218
|
+
var bytesToHex = (b) => Array.from(abytes(b)).map((e) => padh(e, 2)).join("");
|
|
219
|
+
var C = { _0: 48, _9: 57, A: 65, F: 70, a: 97, f: 102 };
|
|
220
|
+
var _ch = (ch) => {
|
|
221
|
+
if (ch >= C._0 && ch <= C._9)
|
|
222
|
+
return ch - C._0;
|
|
223
|
+
if (ch >= C.A && ch <= C.F)
|
|
224
|
+
return ch - (C.A - 10);
|
|
225
|
+
if (ch >= C.a && ch <= C.f)
|
|
226
|
+
return ch - (C.a - 10);
|
|
227
|
+
return;
|
|
228
|
+
};
|
|
229
|
+
var hexToBytes = (hex) => {
|
|
230
|
+
const e = "hex invalid";
|
|
231
|
+
if (!isStr(hex))
|
|
232
|
+
return err(e);
|
|
233
|
+
const hl = hex.length;
|
|
234
|
+
const al = hl / 2;
|
|
235
|
+
if (hl % 2)
|
|
236
|
+
return err(e);
|
|
237
|
+
const array = u8n(al);
|
|
238
|
+
for (let ai = 0, hi = 0; ai < al; ai++, hi += 2) {
|
|
239
|
+
const n1 = _ch(hex.charCodeAt(hi));
|
|
240
|
+
const n2 = _ch(hex.charCodeAt(hi + 1));
|
|
241
|
+
if (n1 === void 0 || n2 === void 0)
|
|
242
|
+
return err(e);
|
|
243
|
+
array[ai] = n1 * 16 + n2;
|
|
244
|
+
}
|
|
245
|
+
return array;
|
|
246
|
+
};
|
|
247
|
+
var toU8 = (a, len) => abytes(isStr(a) ? hexToBytes(a) : u8fr(abytes(a)), len);
|
|
248
|
+
var cr = () => globalThis?.crypto;
|
|
249
|
+
var subtle = () => cr()?.subtle ?? err("crypto.subtle must be defined");
|
|
250
|
+
var concatBytes = (...arrs) => {
|
|
251
|
+
const r = u8n(arrs.reduce((sum, a) => sum + abytes(a).length, 0));
|
|
252
|
+
let pad = 0;
|
|
253
|
+
arrs.forEach((a) => {
|
|
254
|
+
r.set(a, pad);
|
|
255
|
+
pad += a.length;
|
|
256
|
+
});
|
|
257
|
+
return r;
|
|
258
|
+
};
|
|
259
|
+
var randomBytes = (len = L) => {
|
|
260
|
+
const c = cr();
|
|
261
|
+
return c.getRandomValues(u8n(len));
|
|
262
|
+
};
|
|
263
|
+
var big = BigInt;
|
|
264
|
+
var arange = (n, min, max, msg = "bad number: out of range") => isBig(n) && min <= n && n < max ? n : err(msg);
|
|
265
|
+
var M = (a, b = P) => {
|
|
266
|
+
const r = a % b;
|
|
267
|
+
return r >= 0n ? r : b + r;
|
|
268
|
+
};
|
|
269
|
+
var modN = (a) => M(a, N);
|
|
270
|
+
var invert = (num, md) => {
|
|
271
|
+
if (num === 0n || md <= 0n)
|
|
272
|
+
err("no inverse n=" + num + " mod=" + md);
|
|
273
|
+
let a = M(num, md), b = md, x = 0n, y = 1n, u = 1n, v = 0n;
|
|
274
|
+
while (a !== 0n) {
|
|
275
|
+
const q = b / a, r = b % a;
|
|
276
|
+
const m = x - u * q, n = y - v * q;
|
|
277
|
+
b = a, a = r, x = u, y = v, u = m, v = n;
|
|
278
|
+
}
|
|
279
|
+
return b === 1n ? M(x, md) : err("no inverse");
|
|
280
|
+
};
|
|
281
|
+
var callHash = (name) => {
|
|
282
|
+
const fn = etc[name];
|
|
283
|
+
if (typeof fn !== "function")
|
|
284
|
+
err("hashes." + name + " not set");
|
|
285
|
+
return fn;
|
|
286
|
+
};
|
|
287
|
+
var apoint = (p) => p instanceof Point ? p : err("Point expected");
|
|
288
|
+
var B256 = 2n ** 256n;
|
|
289
|
+
var Point = class _Point {
|
|
290
|
+
static BASE;
|
|
291
|
+
static ZERO;
|
|
292
|
+
ex;
|
|
293
|
+
ey;
|
|
294
|
+
ez;
|
|
295
|
+
et;
|
|
296
|
+
constructor(ex, ey, ez, et) {
|
|
297
|
+
const max = B256;
|
|
298
|
+
this.ex = arange(ex, 0n, max);
|
|
299
|
+
this.ey = arange(ey, 0n, max);
|
|
300
|
+
this.ez = arange(ez, 1n, max);
|
|
301
|
+
this.et = arange(et, 0n, max);
|
|
302
|
+
Object.freeze(this);
|
|
303
|
+
}
|
|
304
|
+
static fromAffine(p) {
|
|
305
|
+
return new _Point(p.x, p.y, 1n, M(p.x * p.y));
|
|
306
|
+
}
|
|
307
|
+
/** RFC8032 5.1.3: Uint8Array to Point. */
|
|
308
|
+
static fromBytes(hex, zip215 = false) {
|
|
309
|
+
const d = _d;
|
|
310
|
+
const normed = u8fr(abytes(hex, L));
|
|
311
|
+
const lastByte = hex[31];
|
|
312
|
+
normed[31] = lastByte & ~128;
|
|
313
|
+
const y = bytesToNumLE(normed);
|
|
314
|
+
const max = zip215 ? B256 : P;
|
|
315
|
+
arange(y, 0n, max);
|
|
316
|
+
const y2 = M(y * y);
|
|
317
|
+
const u = M(y2 - 1n);
|
|
318
|
+
const v = M(d * y2 + 1n);
|
|
319
|
+
let { isValid, value: x } = uvRatio(u, v);
|
|
320
|
+
if (!isValid)
|
|
321
|
+
err("bad point: y not sqrt");
|
|
322
|
+
const isXOdd = (x & 1n) === 1n;
|
|
323
|
+
const isLastByteOdd = (lastByte & 128) !== 0;
|
|
324
|
+
if (!zip215 && x === 0n && isLastByteOdd)
|
|
325
|
+
err("bad point: x==0, isLastByteOdd");
|
|
326
|
+
if (isLastByteOdd !== isXOdd)
|
|
327
|
+
x = M(-x);
|
|
328
|
+
return new _Point(x, y, 1n, M(x * y));
|
|
329
|
+
}
|
|
330
|
+
/** Checks if the point is valid and on-curve. */
|
|
331
|
+
assertValidity() {
|
|
332
|
+
const a = _a;
|
|
333
|
+
const d = _d;
|
|
334
|
+
const p = this;
|
|
335
|
+
if (p.is0())
|
|
336
|
+
throw new Error("bad point: ZERO");
|
|
337
|
+
const { ex: X, ey: Y, ez: Z, et: T } = p;
|
|
338
|
+
const X2 = M(X * X);
|
|
339
|
+
const Y2 = M(Y * Y);
|
|
340
|
+
const Z2 = M(Z * Z);
|
|
341
|
+
const Z4 = M(Z2 * Z2);
|
|
342
|
+
const aX2 = M(X2 * a);
|
|
343
|
+
const left = M(Z2 * M(aX2 + Y2));
|
|
344
|
+
const right = M(Z4 + M(d * M(X2 * Y2)));
|
|
345
|
+
if (left !== right)
|
|
346
|
+
throw new Error("bad point: equation left != right (1)");
|
|
347
|
+
const XY = M(X * Y);
|
|
348
|
+
const ZT = M(Z * T);
|
|
349
|
+
if (XY !== ZT)
|
|
350
|
+
throw new Error("bad point: equation left != right (2)");
|
|
351
|
+
return this;
|
|
352
|
+
}
|
|
353
|
+
/** Equality check: compare points P&Q. */
|
|
354
|
+
equals(other) {
|
|
355
|
+
const { ex: X1, ey: Y1, ez: Z1 } = this;
|
|
356
|
+
const { ex: X2, ey: Y2, ez: Z2 } = apoint(other);
|
|
357
|
+
const X1Z2 = M(X1 * Z2);
|
|
358
|
+
const X2Z1 = M(X2 * Z1);
|
|
359
|
+
const Y1Z2 = M(Y1 * Z2);
|
|
360
|
+
const Y2Z1 = M(Y2 * Z1);
|
|
361
|
+
return X1Z2 === X2Z1 && Y1Z2 === Y2Z1;
|
|
362
|
+
}
|
|
363
|
+
is0() {
|
|
364
|
+
return this.equals(I);
|
|
365
|
+
}
|
|
366
|
+
/** Flip point over y coordinate. */
|
|
367
|
+
negate() {
|
|
368
|
+
return new _Point(M(-this.ex), this.ey, this.ez, M(-this.et));
|
|
369
|
+
}
|
|
370
|
+
/** Point doubling. Complete formula. Cost: `4M + 4S + 1*a + 6add + 1*2`. */
|
|
371
|
+
double() {
|
|
372
|
+
const { ex: X1, ey: Y1, ez: Z1 } = this;
|
|
373
|
+
const a = _a;
|
|
374
|
+
const A = M(X1 * X1);
|
|
375
|
+
const B = M(Y1 * Y1);
|
|
376
|
+
const C2 = M(2n * M(Z1 * Z1));
|
|
377
|
+
const D = M(a * A);
|
|
378
|
+
const x1y1 = X1 + Y1;
|
|
379
|
+
const E = M(M(x1y1 * x1y1) - A - B);
|
|
380
|
+
const G2 = D + B;
|
|
381
|
+
const F4 = G2 - C2;
|
|
382
|
+
const H = D - B;
|
|
383
|
+
const X3 = M(E * F4);
|
|
384
|
+
const Y3 = M(G2 * H);
|
|
385
|
+
const T3 = M(E * H);
|
|
386
|
+
const Z3 = M(F4 * G2);
|
|
387
|
+
return new _Point(X3, Y3, Z3, T3);
|
|
388
|
+
}
|
|
389
|
+
/** Point addition. Complete formula. Cost: `8M + 1*k + 8add + 1*2`. */
|
|
390
|
+
add(other) {
|
|
391
|
+
const { ex: X1, ey: Y1, ez: Z1, et: T1 } = this;
|
|
392
|
+
const { ex: X2, ey: Y2, ez: Z2, et: T2 } = apoint(other);
|
|
393
|
+
const a = _a;
|
|
394
|
+
const d = _d;
|
|
395
|
+
const A = M(X1 * X2);
|
|
396
|
+
const B = M(Y1 * Y2);
|
|
397
|
+
const C2 = M(T1 * d * T2);
|
|
398
|
+
const D = M(Z1 * Z2);
|
|
399
|
+
const E = M((X1 + Y1) * (X2 + Y2) - A - B);
|
|
400
|
+
const F4 = M(D - C2);
|
|
401
|
+
const G2 = M(D + C2);
|
|
402
|
+
const H = M(B - a * A);
|
|
403
|
+
const X3 = M(E * F4);
|
|
404
|
+
const Y3 = M(G2 * H);
|
|
405
|
+
const T3 = M(E * H);
|
|
406
|
+
const Z3 = M(F4 * G2);
|
|
407
|
+
return new _Point(X3, Y3, Z3, T3);
|
|
408
|
+
}
|
|
409
|
+
/**
|
|
410
|
+
* Point-by-scalar multiplication. Scalar must be in range 1 <= n < CURVE.n.
|
|
411
|
+
* Uses {@link wNAF} for base point.
|
|
412
|
+
* Uses fake point to mitigate side-channel leakage.
|
|
413
|
+
* @param n scalar by which point is multiplied
|
|
414
|
+
* @param safe safe mode guards against timing attacks; unsafe mode is faster
|
|
415
|
+
*/
|
|
416
|
+
multiply(n, safe = true) {
|
|
417
|
+
if (!safe && (n === 0n || this.is0()))
|
|
418
|
+
return I;
|
|
419
|
+
arange(n, 1n, N);
|
|
420
|
+
if (n === 1n)
|
|
421
|
+
return this;
|
|
422
|
+
if (this.equals(G))
|
|
423
|
+
return wNAF(n).p;
|
|
424
|
+
let p = I;
|
|
425
|
+
let f = G;
|
|
426
|
+
for (let d = this; n > 0n; d = d.double(), n >>= 1n) {
|
|
427
|
+
if (n & 1n)
|
|
428
|
+
p = p.add(d);
|
|
429
|
+
else if (safe)
|
|
430
|
+
f = f.add(d);
|
|
431
|
+
}
|
|
432
|
+
return p;
|
|
433
|
+
}
|
|
434
|
+
/** Convert point to 2d xy affine point. (X, Y, Z) ∋ (x=X/Z, y=Y/Z) */
|
|
435
|
+
toAffine() {
|
|
436
|
+
const { ex: x, ey: y, ez: z } = this;
|
|
437
|
+
if (this.equals(I))
|
|
438
|
+
return { x: 0n, y: 1n };
|
|
439
|
+
const iz = invert(z, P);
|
|
440
|
+
if (M(z * iz) !== 1n)
|
|
441
|
+
err("invalid inverse");
|
|
442
|
+
return { x: M(x * iz), y: M(y * iz) };
|
|
443
|
+
}
|
|
444
|
+
toBytes() {
|
|
445
|
+
const { x, y } = this.assertValidity().toAffine();
|
|
446
|
+
const b = numTo32bLE(y);
|
|
447
|
+
b[31] |= x & 1n ? 128 : 0;
|
|
448
|
+
return b;
|
|
449
|
+
}
|
|
450
|
+
toHex() {
|
|
451
|
+
return bytesToHex(this.toBytes());
|
|
452
|
+
}
|
|
453
|
+
// encode to hex string
|
|
454
|
+
clearCofactor() {
|
|
455
|
+
return this.multiply(big(h), false);
|
|
456
|
+
}
|
|
457
|
+
isSmallOrder() {
|
|
458
|
+
return this.clearCofactor().is0();
|
|
459
|
+
}
|
|
460
|
+
isTorsionFree() {
|
|
461
|
+
let p = this.multiply(N / 2n, false).double();
|
|
462
|
+
if (N % 2n)
|
|
463
|
+
p = p.add(this);
|
|
464
|
+
return p.is0();
|
|
465
|
+
}
|
|
466
|
+
static fromHex(hex, zip215) {
|
|
467
|
+
return _Point.fromBytes(toU8(hex), zip215);
|
|
468
|
+
}
|
|
469
|
+
get x() {
|
|
470
|
+
return this.toAffine().x;
|
|
471
|
+
}
|
|
472
|
+
get y() {
|
|
473
|
+
return this.toAffine().y;
|
|
474
|
+
}
|
|
475
|
+
toRawBytes() {
|
|
476
|
+
return this.toBytes();
|
|
477
|
+
}
|
|
478
|
+
};
|
|
479
|
+
var G = new Point(Gx, Gy, 1n, M(Gx * Gy));
|
|
480
|
+
var I = new Point(0n, 1n, 1n, 0n);
|
|
481
|
+
Point.BASE = G;
|
|
482
|
+
Point.ZERO = I;
|
|
483
|
+
var numTo32bLE = (num) => hexToBytes(padh(arange(num, 0n, B256), L2)).reverse();
|
|
484
|
+
var bytesToNumLE = (b) => big("0x" + bytesToHex(u8fr(abytes(b)).reverse()));
|
|
485
|
+
var pow2 = (x, power) => {
|
|
486
|
+
let r = x;
|
|
487
|
+
while (power-- > 0n) {
|
|
488
|
+
r *= r;
|
|
489
|
+
r %= P;
|
|
490
|
+
}
|
|
491
|
+
return r;
|
|
492
|
+
};
|
|
493
|
+
var pow_2_252_3 = (x) => {
|
|
494
|
+
const x2 = x * x % P;
|
|
495
|
+
const b2 = x2 * x % P;
|
|
496
|
+
const b4 = pow2(b2, 2n) * b2 % P;
|
|
497
|
+
const b5 = pow2(b4, 1n) * x % P;
|
|
498
|
+
const b10 = pow2(b5, 5n) * b5 % P;
|
|
499
|
+
const b20 = pow2(b10, 10n) * b10 % P;
|
|
500
|
+
const b40 = pow2(b20, 20n) * b20 % P;
|
|
501
|
+
const b80 = pow2(b40, 40n) * b40 % P;
|
|
502
|
+
const b160 = pow2(b80, 80n) * b80 % P;
|
|
503
|
+
const b240 = pow2(b160, 80n) * b80 % P;
|
|
504
|
+
const b250 = pow2(b240, 10n) * b10 % P;
|
|
505
|
+
const pow_p_5_8 = pow2(b250, 2n) * x % P;
|
|
506
|
+
return { pow_p_5_8, b2 };
|
|
507
|
+
};
|
|
508
|
+
var RM1 = 0x2b8324804fc1df0b2b4d00993dfbd7a72f431806ad2fe478c4ee1b274a0ea0b0n;
|
|
509
|
+
var uvRatio = (u, v) => {
|
|
510
|
+
const v3 = M(v * v * v);
|
|
511
|
+
const v7 = M(v3 * v3 * v);
|
|
512
|
+
const pow = pow_2_252_3(u * v7).pow_p_5_8;
|
|
513
|
+
let x = M(u * v3 * pow);
|
|
514
|
+
const vx2 = M(v * x * x);
|
|
515
|
+
const root1 = x;
|
|
516
|
+
const root2 = M(x * RM1);
|
|
517
|
+
const useRoot1 = vx2 === u;
|
|
518
|
+
const useRoot2 = vx2 === M(-u);
|
|
519
|
+
const noRoot = vx2 === M(-u * RM1);
|
|
520
|
+
if (useRoot1)
|
|
521
|
+
x = root1;
|
|
522
|
+
if (useRoot2 || noRoot)
|
|
523
|
+
x = root2;
|
|
524
|
+
if ((M(x) & 1n) === 1n)
|
|
525
|
+
x = M(-x);
|
|
526
|
+
return { isValid: useRoot1 || useRoot2, value: x };
|
|
527
|
+
};
|
|
528
|
+
var modL_LE = (hash) => modN(bytesToNumLE(hash));
|
|
529
|
+
var sha512s = (...m) => callHash("sha512Sync")(...m);
|
|
530
|
+
var hashFinishS = (res) => res.finish(sha512s(res.hashable));
|
|
531
|
+
var veriOpts = { zip215: true };
|
|
532
|
+
var _verify = (sig, msg, pub, opts = veriOpts) => {
|
|
533
|
+
sig = toU8(sig, L2);
|
|
534
|
+
msg = toU8(msg);
|
|
535
|
+
pub = toU8(pub, L);
|
|
536
|
+
const { zip215 } = opts;
|
|
537
|
+
let A;
|
|
538
|
+
let R;
|
|
539
|
+
let s;
|
|
540
|
+
let SB;
|
|
541
|
+
let hashable = Uint8Array.of();
|
|
542
|
+
try {
|
|
543
|
+
A = Point.fromHex(pub, zip215);
|
|
544
|
+
R = Point.fromHex(sig.slice(0, L), zip215);
|
|
545
|
+
s = bytesToNumLE(sig.slice(L, L2));
|
|
546
|
+
SB = G.multiply(s, false);
|
|
547
|
+
hashable = concatBytes(R.toBytes(), A.toBytes(), msg);
|
|
548
|
+
} catch (error) {
|
|
549
|
+
}
|
|
550
|
+
const finish = (hashed) => {
|
|
551
|
+
if (SB == null)
|
|
552
|
+
return false;
|
|
553
|
+
if (!zip215 && A.isSmallOrder())
|
|
554
|
+
return false;
|
|
555
|
+
const k = modL_LE(hashed);
|
|
556
|
+
const RkA = R.add(A.multiply(k, false));
|
|
557
|
+
return RkA.add(SB.negate()).clearCofactor().is0();
|
|
558
|
+
};
|
|
559
|
+
return { hashable, finish };
|
|
560
|
+
};
|
|
561
|
+
var verify = (s, m, p, opts = veriOpts) => hashFinishS(_verify(s, m, p, opts));
|
|
562
|
+
var etc = {
|
|
563
|
+
sha512Async: async (...messages) => {
|
|
564
|
+
const s = subtle();
|
|
565
|
+
const m = concatBytes(...messages);
|
|
566
|
+
return u8n(await s.digest("SHA-512", m.buffer));
|
|
567
|
+
},
|
|
568
|
+
sha512Sync: void 0,
|
|
569
|
+
bytesToHex,
|
|
570
|
+
hexToBytes,
|
|
571
|
+
concatBytes,
|
|
572
|
+
mod: M,
|
|
573
|
+
invert,
|
|
574
|
+
randomBytes
|
|
575
|
+
};
|
|
576
|
+
var W = 8;
|
|
577
|
+
var scalarBits = 256;
|
|
578
|
+
var pwindows = Math.ceil(scalarBits / W) + 1;
|
|
579
|
+
var pwindowSize = 2 ** (W - 1);
|
|
580
|
+
var precompute = () => {
|
|
581
|
+
const points = [];
|
|
582
|
+
let p = G;
|
|
583
|
+
let b = p;
|
|
584
|
+
for (let w = 0; w < pwindows; w++) {
|
|
585
|
+
b = p;
|
|
586
|
+
points.push(b);
|
|
587
|
+
for (let i = 1; i < pwindowSize; i++) {
|
|
588
|
+
b = b.add(p);
|
|
589
|
+
points.push(b);
|
|
590
|
+
}
|
|
591
|
+
p = b.double();
|
|
592
|
+
}
|
|
593
|
+
return points;
|
|
594
|
+
};
|
|
595
|
+
var Gpows = void 0;
|
|
596
|
+
var ctneg = (cnd, p) => {
|
|
597
|
+
const n = p.negate();
|
|
598
|
+
return cnd ? n : p;
|
|
599
|
+
};
|
|
600
|
+
var wNAF = (n) => {
|
|
601
|
+
const comp = Gpows || (Gpows = precompute());
|
|
602
|
+
let p = I;
|
|
603
|
+
let f = G;
|
|
604
|
+
const pow_2_w = 2 ** W;
|
|
605
|
+
const maxNum = pow_2_w;
|
|
606
|
+
const mask = big(pow_2_w - 1);
|
|
607
|
+
const shiftBy = big(W);
|
|
608
|
+
for (let w = 0; w < pwindows; w++) {
|
|
609
|
+
let wbits = Number(n & mask);
|
|
610
|
+
n >>= shiftBy;
|
|
611
|
+
if (wbits > pwindowSize) {
|
|
612
|
+
wbits -= maxNum;
|
|
613
|
+
n += 1n;
|
|
614
|
+
}
|
|
615
|
+
const off = w * pwindowSize;
|
|
616
|
+
const offF = off;
|
|
617
|
+
const offP = off + Math.abs(wbits) - 1;
|
|
618
|
+
const isEven = w % 2 !== 0;
|
|
619
|
+
const isNeg = wbits < 0;
|
|
620
|
+
if (wbits === 0) {
|
|
621
|
+
f = f.add(ctneg(isEven, comp[offF]));
|
|
622
|
+
} else {
|
|
623
|
+
p = p.add(ctneg(isNeg, comp[offP]));
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
return { p, f };
|
|
627
|
+
};
|
|
628
|
+
|
|
629
|
+
// ../../node_modules/.pnpm/@noble+hashes@1.8.0/node_modules/@noble/hashes/esm/utils.js
|
|
630
|
+
function isBytes2(a) {
|
|
631
|
+
return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array";
|
|
632
|
+
}
|
|
633
|
+
function abytes2(b, ...lengths) {
|
|
634
|
+
if (!isBytes2(b))
|
|
635
|
+
throw new Error("Uint8Array expected");
|
|
636
|
+
if (lengths.length > 0 && !lengths.includes(b.length))
|
|
637
|
+
throw new Error("Uint8Array expected of length " + lengths + ", got length=" + b.length);
|
|
638
|
+
}
|
|
639
|
+
function aexists(instance2, checkFinished = true) {
|
|
640
|
+
if (instance2.destroyed)
|
|
641
|
+
throw new Error("Hash instance has been destroyed");
|
|
642
|
+
if (checkFinished && instance2.finished)
|
|
643
|
+
throw new Error("Hash#digest() has already been called");
|
|
644
|
+
}
|
|
645
|
+
function aoutput(out, instance2) {
|
|
646
|
+
abytes2(out);
|
|
647
|
+
const min = instance2.outputLen;
|
|
648
|
+
if (out.length < min) {
|
|
649
|
+
throw new Error("digestInto() expects output buffer of length at least " + min);
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
function clean(...arrays) {
|
|
653
|
+
for (let i = 0; i < arrays.length; i++) {
|
|
654
|
+
arrays[i].fill(0);
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
function createView(arr) {
|
|
658
|
+
return new DataView(arr.buffer, arr.byteOffset, arr.byteLength);
|
|
659
|
+
}
|
|
660
|
+
function rotr(word, shift) {
|
|
661
|
+
return word << 32 - shift | word >>> shift;
|
|
662
|
+
}
|
|
663
|
+
function utf8ToBytes(str) {
|
|
664
|
+
if (typeof str !== "string")
|
|
665
|
+
throw new Error("string expected");
|
|
666
|
+
return new Uint8Array(new TextEncoder().encode(str));
|
|
667
|
+
}
|
|
668
|
+
function toBytes(data) {
|
|
669
|
+
if (typeof data === "string")
|
|
670
|
+
data = utf8ToBytes(data);
|
|
671
|
+
abytes2(data);
|
|
672
|
+
return data;
|
|
673
|
+
}
|
|
674
|
+
var Hash = class {
|
|
675
|
+
};
|
|
676
|
+
function createHasher(hashCons) {
|
|
677
|
+
const hashC = (msg) => hashCons().update(toBytes(msg)).digest();
|
|
678
|
+
const tmp = hashCons();
|
|
679
|
+
hashC.outputLen = tmp.outputLen;
|
|
680
|
+
hashC.blockLen = tmp.blockLen;
|
|
681
|
+
hashC.create = () => hashCons();
|
|
682
|
+
return hashC;
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
// ../../node_modules/.pnpm/@noble+hashes@1.8.0/node_modules/@noble/hashes/esm/_md.js
|
|
686
|
+
function setBigUint64(view, byteOffset, value, isLE) {
|
|
687
|
+
if (typeof view.setBigUint64 === "function")
|
|
688
|
+
return view.setBigUint64(byteOffset, value, isLE);
|
|
689
|
+
const _32n2 = BigInt(32);
|
|
690
|
+
const _u32_max = BigInt(4294967295);
|
|
691
|
+
const wh = Number(value >> _32n2 & _u32_max);
|
|
692
|
+
const wl = Number(value & _u32_max);
|
|
693
|
+
const h2 = isLE ? 4 : 0;
|
|
694
|
+
const l = isLE ? 0 : 4;
|
|
695
|
+
view.setUint32(byteOffset + h2, wh, isLE);
|
|
696
|
+
view.setUint32(byteOffset + l, wl, isLE);
|
|
697
|
+
}
|
|
698
|
+
function Chi(a, b, c) {
|
|
699
|
+
return a & b ^ ~a & c;
|
|
700
|
+
}
|
|
701
|
+
function Maj(a, b, c) {
|
|
702
|
+
return a & b ^ a & c ^ b & c;
|
|
703
|
+
}
|
|
704
|
+
var HashMD = class extends Hash {
|
|
705
|
+
constructor(blockLen, outputLen, padOffset, isLE) {
|
|
706
|
+
super();
|
|
707
|
+
this.finished = false;
|
|
708
|
+
this.length = 0;
|
|
709
|
+
this.pos = 0;
|
|
710
|
+
this.destroyed = false;
|
|
711
|
+
this.blockLen = blockLen;
|
|
712
|
+
this.outputLen = outputLen;
|
|
713
|
+
this.padOffset = padOffset;
|
|
714
|
+
this.isLE = isLE;
|
|
715
|
+
this.buffer = new Uint8Array(blockLen);
|
|
716
|
+
this.view = createView(this.buffer);
|
|
717
|
+
}
|
|
718
|
+
update(data) {
|
|
719
|
+
aexists(this);
|
|
720
|
+
data = toBytes(data);
|
|
721
|
+
abytes2(data);
|
|
722
|
+
const { view, buffer, blockLen } = this;
|
|
723
|
+
const len = data.length;
|
|
724
|
+
for (let pos = 0; pos < len; ) {
|
|
725
|
+
const take = Math.min(blockLen - this.pos, len - pos);
|
|
726
|
+
if (take === blockLen) {
|
|
727
|
+
const dataView = createView(data);
|
|
728
|
+
for (; blockLen <= len - pos; pos += blockLen)
|
|
729
|
+
this.process(dataView, pos);
|
|
730
|
+
continue;
|
|
731
|
+
}
|
|
732
|
+
buffer.set(data.subarray(pos, pos + take), this.pos);
|
|
733
|
+
this.pos += take;
|
|
734
|
+
pos += take;
|
|
735
|
+
if (this.pos === blockLen) {
|
|
736
|
+
this.process(view, 0);
|
|
737
|
+
this.pos = 0;
|
|
738
|
+
}
|
|
739
|
+
}
|
|
740
|
+
this.length += data.length;
|
|
741
|
+
this.roundClean();
|
|
742
|
+
return this;
|
|
743
|
+
}
|
|
744
|
+
digestInto(out) {
|
|
745
|
+
aexists(this);
|
|
746
|
+
aoutput(out, this);
|
|
747
|
+
this.finished = true;
|
|
748
|
+
const { buffer, view, blockLen, isLE } = this;
|
|
749
|
+
let { pos } = this;
|
|
750
|
+
buffer[pos++] = 128;
|
|
751
|
+
clean(this.buffer.subarray(pos));
|
|
752
|
+
if (this.padOffset > blockLen - pos) {
|
|
753
|
+
this.process(view, 0);
|
|
754
|
+
pos = 0;
|
|
755
|
+
}
|
|
756
|
+
for (let i = pos; i < blockLen; i++)
|
|
757
|
+
buffer[i] = 0;
|
|
758
|
+
setBigUint64(view, blockLen - 8, BigInt(this.length * 8), isLE);
|
|
759
|
+
this.process(view, 0);
|
|
760
|
+
const oview = createView(out);
|
|
761
|
+
const len = this.outputLen;
|
|
762
|
+
if (len % 4)
|
|
763
|
+
throw new Error("_sha2: outputLen should be aligned to 32bit");
|
|
764
|
+
const outLen = len / 4;
|
|
765
|
+
const state = this.get();
|
|
766
|
+
if (outLen > state.length)
|
|
767
|
+
throw new Error("_sha2: outputLen bigger than state");
|
|
768
|
+
for (let i = 0; i < outLen; i++)
|
|
769
|
+
oview.setUint32(4 * i, state[i], isLE);
|
|
770
|
+
}
|
|
771
|
+
digest() {
|
|
772
|
+
const { buffer, outputLen } = this;
|
|
773
|
+
this.digestInto(buffer);
|
|
774
|
+
const res = buffer.slice(0, outputLen);
|
|
775
|
+
this.destroy();
|
|
776
|
+
return res;
|
|
777
|
+
}
|
|
778
|
+
_cloneInto(to) {
|
|
779
|
+
to || (to = new this.constructor());
|
|
780
|
+
to.set(...this.get());
|
|
781
|
+
const { blockLen, buffer, length, finished, destroyed, pos } = this;
|
|
782
|
+
to.destroyed = destroyed;
|
|
783
|
+
to.finished = finished;
|
|
784
|
+
to.length = length;
|
|
785
|
+
to.pos = pos;
|
|
786
|
+
if (length % blockLen)
|
|
787
|
+
to.buffer.set(buffer);
|
|
788
|
+
return to;
|
|
789
|
+
}
|
|
790
|
+
clone() {
|
|
791
|
+
return this._cloneInto();
|
|
792
|
+
}
|
|
793
|
+
};
|
|
794
|
+
var SHA256_IV = /* @__PURE__ */ Uint32Array.from([
|
|
795
|
+
1779033703,
|
|
796
|
+
3144134277,
|
|
797
|
+
1013904242,
|
|
798
|
+
2773480762,
|
|
799
|
+
1359893119,
|
|
800
|
+
2600822924,
|
|
801
|
+
528734635,
|
|
802
|
+
1541459225
|
|
803
|
+
]);
|
|
804
|
+
var SHA512_IV = /* @__PURE__ */ Uint32Array.from([
|
|
805
|
+
1779033703,
|
|
806
|
+
4089235720,
|
|
807
|
+
3144134277,
|
|
808
|
+
2227873595,
|
|
809
|
+
1013904242,
|
|
810
|
+
4271175723,
|
|
811
|
+
2773480762,
|
|
812
|
+
1595750129,
|
|
813
|
+
1359893119,
|
|
814
|
+
2917565137,
|
|
815
|
+
2600822924,
|
|
816
|
+
725511199,
|
|
817
|
+
528734635,
|
|
818
|
+
4215389547,
|
|
819
|
+
1541459225,
|
|
820
|
+
327033209
|
|
821
|
+
]);
|
|
822
|
+
|
|
823
|
+
// ../../node_modules/.pnpm/@noble+hashes@1.8.0/node_modules/@noble/hashes/esm/_u64.js
|
|
824
|
+
var U32_MASK64 = /* @__PURE__ */ BigInt(2 ** 32 - 1);
|
|
825
|
+
var _32n = /* @__PURE__ */ BigInt(32);
|
|
826
|
+
function fromBig(n, le = false) {
|
|
827
|
+
if (le)
|
|
828
|
+
return { h: Number(n & U32_MASK64), l: Number(n >> _32n & U32_MASK64) };
|
|
829
|
+
return { h: Number(n >> _32n & U32_MASK64) | 0, l: Number(n & U32_MASK64) | 0 };
|
|
830
|
+
}
|
|
831
|
+
function split(lst, le = false) {
|
|
832
|
+
const len = lst.length;
|
|
833
|
+
let Ah = new Uint32Array(len);
|
|
834
|
+
let Al = new Uint32Array(len);
|
|
835
|
+
for (let i = 0; i < len; i++) {
|
|
836
|
+
const { h: h2, l } = fromBig(lst[i], le);
|
|
837
|
+
[Ah[i], Al[i]] = [h2, l];
|
|
838
|
+
}
|
|
839
|
+
return [Ah, Al];
|
|
840
|
+
}
|
|
841
|
+
var shrSH = (h2, _l, s) => h2 >>> s;
|
|
842
|
+
var shrSL = (h2, l, s) => h2 << 32 - s | l >>> s;
|
|
843
|
+
var rotrSH = (h2, l, s) => h2 >>> s | l << 32 - s;
|
|
844
|
+
var rotrSL = (h2, l, s) => h2 << 32 - s | l >>> s;
|
|
845
|
+
var rotrBH = (h2, l, s) => h2 << 64 - s | l >>> s - 32;
|
|
846
|
+
var rotrBL = (h2, l, s) => h2 >>> s - 32 | l << 64 - s;
|
|
847
|
+
function add(Ah, Al, Bh, Bl) {
|
|
848
|
+
const l = (Al >>> 0) + (Bl >>> 0);
|
|
849
|
+
return { h: Ah + Bh + (l / 2 ** 32 | 0) | 0, l: l | 0 };
|
|
850
|
+
}
|
|
851
|
+
var add3L = (Al, Bl, Cl) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0);
|
|
852
|
+
var add3H = (low, Ah, Bh, Ch) => Ah + Bh + Ch + (low / 2 ** 32 | 0) | 0;
|
|
853
|
+
var add4L = (Al, Bl, Cl, Dl) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0) + (Dl >>> 0);
|
|
854
|
+
var add4H = (low, Ah, Bh, Ch, Dh) => Ah + Bh + Ch + Dh + (low / 2 ** 32 | 0) | 0;
|
|
855
|
+
var add5L = (Al, Bl, Cl, Dl, El) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0) + (Dl >>> 0) + (El >>> 0);
|
|
856
|
+
var add5H = (low, Ah, Bh, Ch, Dh, Eh) => Ah + Bh + Ch + Dh + Eh + (low / 2 ** 32 | 0) | 0;
|
|
857
|
+
|
|
858
|
+
// ../../node_modules/.pnpm/@noble+hashes@1.8.0/node_modules/@noble/hashes/esm/sha2.js
|
|
859
|
+
var SHA256_K = /* @__PURE__ */ Uint32Array.from([
|
|
860
|
+
1116352408,
|
|
861
|
+
1899447441,
|
|
862
|
+
3049323471,
|
|
863
|
+
3921009573,
|
|
864
|
+
961987163,
|
|
865
|
+
1508970993,
|
|
866
|
+
2453635748,
|
|
867
|
+
2870763221,
|
|
868
|
+
3624381080,
|
|
869
|
+
310598401,
|
|
870
|
+
607225278,
|
|
871
|
+
1426881987,
|
|
872
|
+
1925078388,
|
|
873
|
+
2162078206,
|
|
874
|
+
2614888103,
|
|
875
|
+
3248222580,
|
|
876
|
+
3835390401,
|
|
877
|
+
4022224774,
|
|
878
|
+
264347078,
|
|
879
|
+
604807628,
|
|
880
|
+
770255983,
|
|
881
|
+
1249150122,
|
|
882
|
+
1555081692,
|
|
883
|
+
1996064986,
|
|
884
|
+
2554220882,
|
|
885
|
+
2821834349,
|
|
886
|
+
2952996808,
|
|
887
|
+
3210313671,
|
|
888
|
+
3336571891,
|
|
889
|
+
3584528711,
|
|
890
|
+
113926993,
|
|
891
|
+
338241895,
|
|
892
|
+
666307205,
|
|
893
|
+
773529912,
|
|
894
|
+
1294757372,
|
|
895
|
+
1396182291,
|
|
896
|
+
1695183700,
|
|
897
|
+
1986661051,
|
|
898
|
+
2177026350,
|
|
899
|
+
2456956037,
|
|
900
|
+
2730485921,
|
|
901
|
+
2820302411,
|
|
902
|
+
3259730800,
|
|
903
|
+
3345764771,
|
|
904
|
+
3516065817,
|
|
905
|
+
3600352804,
|
|
906
|
+
4094571909,
|
|
907
|
+
275423344,
|
|
908
|
+
430227734,
|
|
909
|
+
506948616,
|
|
910
|
+
659060556,
|
|
911
|
+
883997877,
|
|
912
|
+
958139571,
|
|
913
|
+
1322822218,
|
|
914
|
+
1537002063,
|
|
915
|
+
1747873779,
|
|
916
|
+
1955562222,
|
|
917
|
+
2024104815,
|
|
918
|
+
2227730452,
|
|
919
|
+
2361852424,
|
|
920
|
+
2428436474,
|
|
921
|
+
2756734187,
|
|
922
|
+
3204031479,
|
|
923
|
+
3329325298
|
|
924
|
+
]);
|
|
925
|
+
var SHA256_W = /* @__PURE__ */ new Uint32Array(64);
|
|
926
|
+
var SHA256 = class extends HashMD {
|
|
927
|
+
constructor(outputLen = 32) {
|
|
928
|
+
super(64, outputLen, 8, false);
|
|
929
|
+
this.A = SHA256_IV[0] | 0;
|
|
930
|
+
this.B = SHA256_IV[1] | 0;
|
|
931
|
+
this.C = SHA256_IV[2] | 0;
|
|
932
|
+
this.D = SHA256_IV[3] | 0;
|
|
933
|
+
this.E = SHA256_IV[4] | 0;
|
|
934
|
+
this.F = SHA256_IV[5] | 0;
|
|
935
|
+
this.G = SHA256_IV[6] | 0;
|
|
936
|
+
this.H = SHA256_IV[7] | 0;
|
|
937
|
+
}
|
|
938
|
+
get() {
|
|
939
|
+
const { A, B, C: C2, D, E, F: F4, G: G2, H } = this;
|
|
940
|
+
return [A, B, C2, D, E, F4, G2, H];
|
|
941
|
+
}
|
|
942
|
+
// prettier-ignore
|
|
943
|
+
set(A, B, C2, D, E, F4, G2, H) {
|
|
944
|
+
this.A = A | 0;
|
|
945
|
+
this.B = B | 0;
|
|
946
|
+
this.C = C2 | 0;
|
|
947
|
+
this.D = D | 0;
|
|
948
|
+
this.E = E | 0;
|
|
949
|
+
this.F = F4 | 0;
|
|
950
|
+
this.G = G2 | 0;
|
|
951
|
+
this.H = H | 0;
|
|
952
|
+
}
|
|
953
|
+
process(view, offset) {
|
|
954
|
+
for (let i = 0; i < 16; i++, offset += 4)
|
|
955
|
+
SHA256_W[i] = view.getUint32(offset, false);
|
|
956
|
+
for (let i = 16; i < 64; i++) {
|
|
957
|
+
const W15 = SHA256_W[i - 15];
|
|
958
|
+
const W2 = SHA256_W[i - 2];
|
|
959
|
+
const s0 = rotr(W15, 7) ^ rotr(W15, 18) ^ W15 >>> 3;
|
|
960
|
+
const s1 = rotr(W2, 17) ^ rotr(W2, 19) ^ W2 >>> 10;
|
|
961
|
+
SHA256_W[i] = s1 + SHA256_W[i - 7] + s0 + SHA256_W[i - 16] | 0;
|
|
962
|
+
}
|
|
963
|
+
let { A, B, C: C2, D, E, F: F4, G: G2, H } = this;
|
|
964
|
+
for (let i = 0; i < 64; i++) {
|
|
965
|
+
const sigma1 = rotr(E, 6) ^ rotr(E, 11) ^ rotr(E, 25);
|
|
966
|
+
const T1 = H + sigma1 + Chi(E, F4, G2) + SHA256_K[i] + SHA256_W[i] | 0;
|
|
967
|
+
const sigma0 = rotr(A, 2) ^ rotr(A, 13) ^ rotr(A, 22);
|
|
968
|
+
const T2 = sigma0 + Maj(A, B, C2) | 0;
|
|
969
|
+
H = G2;
|
|
970
|
+
G2 = F4;
|
|
971
|
+
F4 = E;
|
|
972
|
+
E = D + T1 | 0;
|
|
973
|
+
D = C2;
|
|
974
|
+
C2 = B;
|
|
975
|
+
B = A;
|
|
976
|
+
A = T1 + T2 | 0;
|
|
977
|
+
}
|
|
978
|
+
A = A + this.A | 0;
|
|
979
|
+
B = B + this.B | 0;
|
|
980
|
+
C2 = C2 + this.C | 0;
|
|
981
|
+
D = D + this.D | 0;
|
|
982
|
+
E = E + this.E | 0;
|
|
983
|
+
F4 = F4 + this.F | 0;
|
|
984
|
+
G2 = G2 + this.G | 0;
|
|
985
|
+
H = H + this.H | 0;
|
|
986
|
+
this.set(A, B, C2, D, E, F4, G2, H);
|
|
987
|
+
}
|
|
988
|
+
roundClean() {
|
|
989
|
+
clean(SHA256_W);
|
|
990
|
+
}
|
|
991
|
+
destroy() {
|
|
992
|
+
this.set(0, 0, 0, 0, 0, 0, 0, 0);
|
|
993
|
+
clean(this.buffer);
|
|
994
|
+
}
|
|
995
|
+
};
|
|
996
|
+
var K512 = /* @__PURE__ */ (() => split([
|
|
997
|
+
"0x428a2f98d728ae22",
|
|
998
|
+
"0x7137449123ef65cd",
|
|
999
|
+
"0xb5c0fbcfec4d3b2f",
|
|
1000
|
+
"0xe9b5dba58189dbbc",
|
|
1001
|
+
"0x3956c25bf348b538",
|
|
1002
|
+
"0x59f111f1b605d019",
|
|
1003
|
+
"0x923f82a4af194f9b",
|
|
1004
|
+
"0xab1c5ed5da6d8118",
|
|
1005
|
+
"0xd807aa98a3030242",
|
|
1006
|
+
"0x12835b0145706fbe",
|
|
1007
|
+
"0x243185be4ee4b28c",
|
|
1008
|
+
"0x550c7dc3d5ffb4e2",
|
|
1009
|
+
"0x72be5d74f27b896f",
|
|
1010
|
+
"0x80deb1fe3b1696b1",
|
|
1011
|
+
"0x9bdc06a725c71235",
|
|
1012
|
+
"0xc19bf174cf692694",
|
|
1013
|
+
"0xe49b69c19ef14ad2",
|
|
1014
|
+
"0xefbe4786384f25e3",
|
|
1015
|
+
"0x0fc19dc68b8cd5b5",
|
|
1016
|
+
"0x240ca1cc77ac9c65",
|
|
1017
|
+
"0x2de92c6f592b0275",
|
|
1018
|
+
"0x4a7484aa6ea6e483",
|
|
1019
|
+
"0x5cb0a9dcbd41fbd4",
|
|
1020
|
+
"0x76f988da831153b5",
|
|
1021
|
+
"0x983e5152ee66dfab",
|
|
1022
|
+
"0xa831c66d2db43210",
|
|
1023
|
+
"0xb00327c898fb213f",
|
|
1024
|
+
"0xbf597fc7beef0ee4",
|
|
1025
|
+
"0xc6e00bf33da88fc2",
|
|
1026
|
+
"0xd5a79147930aa725",
|
|
1027
|
+
"0x06ca6351e003826f",
|
|
1028
|
+
"0x142929670a0e6e70",
|
|
1029
|
+
"0x27b70a8546d22ffc",
|
|
1030
|
+
"0x2e1b21385c26c926",
|
|
1031
|
+
"0x4d2c6dfc5ac42aed",
|
|
1032
|
+
"0x53380d139d95b3df",
|
|
1033
|
+
"0x650a73548baf63de",
|
|
1034
|
+
"0x766a0abb3c77b2a8",
|
|
1035
|
+
"0x81c2c92e47edaee6",
|
|
1036
|
+
"0x92722c851482353b",
|
|
1037
|
+
"0xa2bfe8a14cf10364",
|
|
1038
|
+
"0xa81a664bbc423001",
|
|
1039
|
+
"0xc24b8b70d0f89791",
|
|
1040
|
+
"0xc76c51a30654be30",
|
|
1041
|
+
"0xd192e819d6ef5218",
|
|
1042
|
+
"0xd69906245565a910",
|
|
1043
|
+
"0xf40e35855771202a",
|
|
1044
|
+
"0x106aa07032bbd1b8",
|
|
1045
|
+
"0x19a4c116b8d2d0c8",
|
|
1046
|
+
"0x1e376c085141ab53",
|
|
1047
|
+
"0x2748774cdf8eeb99",
|
|
1048
|
+
"0x34b0bcb5e19b48a8",
|
|
1049
|
+
"0x391c0cb3c5c95a63",
|
|
1050
|
+
"0x4ed8aa4ae3418acb",
|
|
1051
|
+
"0x5b9cca4f7763e373",
|
|
1052
|
+
"0x682e6ff3d6b2b8a3",
|
|
1053
|
+
"0x748f82ee5defb2fc",
|
|
1054
|
+
"0x78a5636f43172f60",
|
|
1055
|
+
"0x84c87814a1f0ab72",
|
|
1056
|
+
"0x8cc702081a6439ec",
|
|
1057
|
+
"0x90befffa23631e28",
|
|
1058
|
+
"0xa4506cebde82bde9",
|
|
1059
|
+
"0xbef9a3f7b2c67915",
|
|
1060
|
+
"0xc67178f2e372532b",
|
|
1061
|
+
"0xca273eceea26619c",
|
|
1062
|
+
"0xd186b8c721c0c207",
|
|
1063
|
+
"0xeada7dd6cde0eb1e",
|
|
1064
|
+
"0xf57d4f7fee6ed178",
|
|
1065
|
+
"0x06f067aa72176fba",
|
|
1066
|
+
"0x0a637dc5a2c898a6",
|
|
1067
|
+
"0x113f9804bef90dae",
|
|
1068
|
+
"0x1b710b35131c471b",
|
|
1069
|
+
"0x28db77f523047d84",
|
|
1070
|
+
"0x32caab7b40c72493",
|
|
1071
|
+
"0x3c9ebe0a15c9bebc",
|
|
1072
|
+
"0x431d67c49c100d4c",
|
|
1073
|
+
"0x4cc5d4becb3e42b6",
|
|
1074
|
+
"0x597f299cfc657e2a",
|
|
1075
|
+
"0x5fcb6fab3ad6faec",
|
|
1076
|
+
"0x6c44198c4a475817"
|
|
1077
|
+
].map((n) => BigInt(n))))();
|
|
1078
|
+
var SHA512_Kh = /* @__PURE__ */ (() => K512[0])();
|
|
1079
|
+
var SHA512_Kl = /* @__PURE__ */ (() => K512[1])();
|
|
1080
|
+
var SHA512_W_H = /* @__PURE__ */ new Uint32Array(80);
|
|
1081
|
+
var SHA512_W_L = /* @__PURE__ */ new Uint32Array(80);
|
|
1082
|
+
var SHA512 = class extends HashMD {
|
|
1083
|
+
constructor(outputLen = 64) {
|
|
1084
|
+
super(128, outputLen, 16, false);
|
|
1085
|
+
this.Ah = SHA512_IV[0] | 0;
|
|
1086
|
+
this.Al = SHA512_IV[1] | 0;
|
|
1087
|
+
this.Bh = SHA512_IV[2] | 0;
|
|
1088
|
+
this.Bl = SHA512_IV[3] | 0;
|
|
1089
|
+
this.Ch = SHA512_IV[4] | 0;
|
|
1090
|
+
this.Cl = SHA512_IV[5] | 0;
|
|
1091
|
+
this.Dh = SHA512_IV[6] | 0;
|
|
1092
|
+
this.Dl = SHA512_IV[7] | 0;
|
|
1093
|
+
this.Eh = SHA512_IV[8] | 0;
|
|
1094
|
+
this.El = SHA512_IV[9] | 0;
|
|
1095
|
+
this.Fh = SHA512_IV[10] | 0;
|
|
1096
|
+
this.Fl = SHA512_IV[11] | 0;
|
|
1097
|
+
this.Gh = SHA512_IV[12] | 0;
|
|
1098
|
+
this.Gl = SHA512_IV[13] | 0;
|
|
1099
|
+
this.Hh = SHA512_IV[14] | 0;
|
|
1100
|
+
this.Hl = SHA512_IV[15] | 0;
|
|
1101
|
+
}
|
|
1102
|
+
// prettier-ignore
|
|
1103
|
+
get() {
|
|
1104
|
+
const { Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl } = this;
|
|
1105
|
+
return [Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl];
|
|
1106
|
+
}
|
|
1107
|
+
// prettier-ignore
|
|
1108
|
+
set(Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl) {
|
|
1109
|
+
this.Ah = Ah | 0;
|
|
1110
|
+
this.Al = Al | 0;
|
|
1111
|
+
this.Bh = Bh | 0;
|
|
1112
|
+
this.Bl = Bl | 0;
|
|
1113
|
+
this.Ch = Ch | 0;
|
|
1114
|
+
this.Cl = Cl | 0;
|
|
1115
|
+
this.Dh = Dh | 0;
|
|
1116
|
+
this.Dl = Dl | 0;
|
|
1117
|
+
this.Eh = Eh | 0;
|
|
1118
|
+
this.El = El | 0;
|
|
1119
|
+
this.Fh = Fh | 0;
|
|
1120
|
+
this.Fl = Fl | 0;
|
|
1121
|
+
this.Gh = Gh | 0;
|
|
1122
|
+
this.Gl = Gl | 0;
|
|
1123
|
+
this.Hh = Hh | 0;
|
|
1124
|
+
this.Hl = Hl | 0;
|
|
1125
|
+
}
|
|
1126
|
+
process(view, offset) {
|
|
1127
|
+
for (let i = 0; i < 16; i++, offset += 4) {
|
|
1128
|
+
SHA512_W_H[i] = view.getUint32(offset);
|
|
1129
|
+
SHA512_W_L[i] = view.getUint32(offset += 4);
|
|
1130
|
+
}
|
|
1131
|
+
for (let i = 16; i < 80; i++) {
|
|
1132
|
+
const W15h = SHA512_W_H[i - 15] | 0;
|
|
1133
|
+
const W15l = SHA512_W_L[i - 15] | 0;
|
|
1134
|
+
const s0h = rotrSH(W15h, W15l, 1) ^ rotrSH(W15h, W15l, 8) ^ shrSH(W15h, W15l, 7);
|
|
1135
|
+
const s0l = rotrSL(W15h, W15l, 1) ^ rotrSL(W15h, W15l, 8) ^ shrSL(W15h, W15l, 7);
|
|
1136
|
+
const W2h = SHA512_W_H[i - 2] | 0;
|
|
1137
|
+
const W2l = SHA512_W_L[i - 2] | 0;
|
|
1138
|
+
const s1h = rotrSH(W2h, W2l, 19) ^ rotrBH(W2h, W2l, 61) ^ shrSH(W2h, W2l, 6);
|
|
1139
|
+
const s1l = rotrSL(W2h, W2l, 19) ^ rotrBL(W2h, W2l, 61) ^ shrSL(W2h, W2l, 6);
|
|
1140
|
+
const SUMl = add4L(s0l, s1l, SHA512_W_L[i - 7], SHA512_W_L[i - 16]);
|
|
1141
|
+
const SUMh = add4H(SUMl, s0h, s1h, SHA512_W_H[i - 7], SHA512_W_H[i - 16]);
|
|
1142
|
+
SHA512_W_H[i] = SUMh | 0;
|
|
1143
|
+
SHA512_W_L[i] = SUMl | 0;
|
|
1144
|
+
}
|
|
1145
|
+
let { Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl } = this;
|
|
1146
|
+
for (let i = 0; i < 80; i++) {
|
|
1147
|
+
const sigma1h = rotrSH(Eh, El, 14) ^ rotrSH(Eh, El, 18) ^ rotrBH(Eh, El, 41);
|
|
1148
|
+
const sigma1l = rotrSL(Eh, El, 14) ^ rotrSL(Eh, El, 18) ^ rotrBL(Eh, El, 41);
|
|
1149
|
+
const CHIh = Eh & Fh ^ ~Eh & Gh;
|
|
1150
|
+
const CHIl = El & Fl ^ ~El & Gl;
|
|
1151
|
+
const T1ll = add5L(Hl, sigma1l, CHIl, SHA512_Kl[i], SHA512_W_L[i]);
|
|
1152
|
+
const T1h = add5H(T1ll, Hh, sigma1h, CHIh, SHA512_Kh[i], SHA512_W_H[i]);
|
|
1153
|
+
const T1l = T1ll | 0;
|
|
1154
|
+
const sigma0h = rotrSH(Ah, Al, 28) ^ rotrBH(Ah, Al, 34) ^ rotrBH(Ah, Al, 39);
|
|
1155
|
+
const sigma0l = rotrSL(Ah, Al, 28) ^ rotrBL(Ah, Al, 34) ^ rotrBL(Ah, Al, 39);
|
|
1156
|
+
const MAJh = Ah & Bh ^ Ah & Ch ^ Bh & Ch;
|
|
1157
|
+
const MAJl = Al & Bl ^ Al & Cl ^ Bl & Cl;
|
|
1158
|
+
Hh = Gh | 0;
|
|
1159
|
+
Hl = Gl | 0;
|
|
1160
|
+
Gh = Fh | 0;
|
|
1161
|
+
Gl = Fl | 0;
|
|
1162
|
+
Fh = Eh | 0;
|
|
1163
|
+
Fl = El | 0;
|
|
1164
|
+
({ h: Eh, l: El } = add(Dh | 0, Dl | 0, T1h | 0, T1l | 0));
|
|
1165
|
+
Dh = Ch | 0;
|
|
1166
|
+
Dl = Cl | 0;
|
|
1167
|
+
Ch = Bh | 0;
|
|
1168
|
+
Cl = Bl | 0;
|
|
1169
|
+
Bh = Ah | 0;
|
|
1170
|
+
Bl = Al | 0;
|
|
1171
|
+
const All = add3L(T1l, sigma0l, MAJl);
|
|
1172
|
+
Ah = add3H(All, T1h, sigma0h, MAJh);
|
|
1173
|
+
Al = All | 0;
|
|
1174
|
+
}
|
|
1175
|
+
({ h: Ah, l: Al } = add(this.Ah | 0, this.Al | 0, Ah | 0, Al | 0));
|
|
1176
|
+
({ h: Bh, l: Bl } = add(this.Bh | 0, this.Bl | 0, Bh | 0, Bl | 0));
|
|
1177
|
+
({ h: Ch, l: Cl } = add(this.Ch | 0, this.Cl | 0, Ch | 0, Cl | 0));
|
|
1178
|
+
({ h: Dh, l: Dl } = add(this.Dh | 0, this.Dl | 0, Dh | 0, Dl | 0));
|
|
1179
|
+
({ h: Eh, l: El } = add(this.Eh | 0, this.El | 0, Eh | 0, El | 0));
|
|
1180
|
+
({ h: Fh, l: Fl } = add(this.Fh | 0, this.Fl | 0, Fh | 0, Fl | 0));
|
|
1181
|
+
({ h: Gh, l: Gl } = add(this.Gh | 0, this.Gl | 0, Gh | 0, Gl | 0));
|
|
1182
|
+
({ h: Hh, l: Hl } = add(this.Hh | 0, this.Hl | 0, Hh | 0, Hl | 0));
|
|
1183
|
+
this.set(Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl);
|
|
1184
|
+
}
|
|
1185
|
+
roundClean() {
|
|
1186
|
+
clean(SHA512_W_H, SHA512_W_L);
|
|
1187
|
+
}
|
|
1188
|
+
destroy() {
|
|
1189
|
+
clean(this.buffer);
|
|
1190
|
+
this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
|
|
1191
|
+
}
|
|
1192
|
+
};
|
|
1193
|
+
var sha256 = /* @__PURE__ */ createHasher(() => new SHA256());
|
|
1194
|
+
var sha512 = /* @__PURE__ */ createHasher(() => new SHA512());
|
|
1195
|
+
|
|
1196
|
+
// ../../node_modules/.pnpm/@noble+hashes@1.8.0/node_modules/@noble/hashes/esm/sha512.js
|
|
1197
|
+
var sha5122 = sha512;
|
|
1198
|
+
|
|
1199
|
+
// ../../node_modules/.pnpm/@noble+hashes@1.8.0/node_modules/@noble/hashes/esm/sha256.js
|
|
1200
|
+
var sha2562 = sha256;
|
|
1201
|
+
|
|
1202
|
+
// ../artifact-core/dist/signing.js
|
|
1203
|
+
etc.sha512Sync = (...m) => sha5122(etc.concatBytes(...m));
|
|
1204
|
+
function fromBase64Url(b64url) {
|
|
1205
|
+
const b64 = b64url.replace(/-/g, "+").replace(/_/g, "/");
|
|
1206
|
+
const padded = b64 + "=".repeat((4 - b64.length % 4) % 4);
|
|
1207
|
+
const binary = atob(padded);
|
|
1208
|
+
const bytes = new Uint8Array(binary.length);
|
|
1209
|
+
for (let i = 0; i < binary.length; i++) {
|
|
1210
|
+
bytes[i] = binary.charCodeAt(i);
|
|
1211
|
+
}
|
|
1212
|
+
return bytes;
|
|
1213
|
+
}
|
|
1214
|
+
function verify2(document, signatureEnvelope, publicKeyB64Url) {
|
|
1215
|
+
let signatureBytes;
|
|
1216
|
+
let publicKeyBytes;
|
|
1217
|
+
try {
|
|
1218
|
+
signatureBytes = fromBase64Url(signatureEnvelope.signature);
|
|
1219
|
+
publicKeyBytes = fromBase64Url(publicKeyB64Url);
|
|
1220
|
+
} catch {
|
|
1221
|
+
return false;
|
|
1222
|
+
}
|
|
1223
|
+
for (const canonFn of [canonical, canonicalLegacy]) {
|
|
1224
|
+
try {
|
|
1225
|
+
const canonicalStr = canonFn(document);
|
|
1226
|
+
const hashBytes = sha2562(new TextEncoder().encode(canonicalStr));
|
|
1227
|
+
if (verify(signatureBytes, hashBytes, publicKeyBytes)) {
|
|
1228
|
+
return true;
|
|
1229
|
+
}
|
|
1230
|
+
} catch {
|
|
1231
|
+
}
|
|
1232
|
+
}
|
|
1233
|
+
return false;
|
|
1234
|
+
}
|
|
1235
|
+
|
|
1236
|
+
// ../../node_modules/.pnpm/@zkpassport+poseidon2@0.6.2/node_modules/@zkpassport/poseidon2/dist/esm/core/field.js
|
|
1237
|
+
var F1Field = class {
|
|
1238
|
+
constructor(prime) {
|
|
1239
|
+
this.zero = BigInt(0);
|
|
1240
|
+
this.one = BigInt(1);
|
|
1241
|
+
this.prime = prime;
|
|
1242
|
+
}
|
|
1243
|
+
e(x) {
|
|
1244
|
+
if (typeof x === "bigint") {
|
|
1245
|
+
return x % this.prime;
|
|
1246
|
+
} else {
|
|
1247
|
+
return BigInt(x) % this.prime;
|
|
1248
|
+
}
|
|
1249
|
+
}
|
|
1250
|
+
add(x, y) {
|
|
1251
|
+
return (x + y) % this.prime;
|
|
1252
|
+
}
|
|
1253
|
+
sub(x, y) {
|
|
1254
|
+
return (this.prime + x - y) % this.prime;
|
|
1255
|
+
}
|
|
1256
|
+
mul(x, y) {
|
|
1257
|
+
return x * y % this.prime;
|
|
1258
|
+
}
|
|
1259
|
+
square(x) {
|
|
1260
|
+
return x * x % this.prime;
|
|
1261
|
+
}
|
|
1262
|
+
div(x, y) {
|
|
1263
|
+
return x / y % this.prime;
|
|
1264
|
+
}
|
|
1265
|
+
};
|
|
1266
|
+
|
|
1267
|
+
// ../../node_modules/.pnpm/@zkpassport+poseidon2@0.6.2/node_modules/@zkpassport/poseidon2/dist/esm/core/poseidon2.js
|
|
1268
|
+
var Poseidon2 = class {
|
|
1269
|
+
constructor(params, primeField) {
|
|
1270
|
+
this.params = params;
|
|
1271
|
+
this.primeField = primeField;
|
|
1272
|
+
}
|
|
1273
|
+
getT() {
|
|
1274
|
+
return this.params.t;
|
|
1275
|
+
}
|
|
1276
|
+
sbox(input) {
|
|
1277
|
+
return input.map((x) => this.sboxP(x));
|
|
1278
|
+
}
|
|
1279
|
+
sboxP(input) {
|
|
1280
|
+
const input2 = this.primeField.square(input);
|
|
1281
|
+
if (this.params.d == 3) {
|
|
1282
|
+
return this.primeField.mul(input2, input);
|
|
1283
|
+
} else if (this.params.d == 5) {
|
|
1284
|
+
return this.primeField.mul(this.primeField.square(input2), input);
|
|
1285
|
+
} else if (this.params.d == 7) {
|
|
1286
|
+
return this.primeField.mul(this.primeField.square(input2), this.primeField.mul(input2, input));
|
|
1287
|
+
} else {
|
|
1288
|
+
throw new Error("Invalid d paramter, must be 3, 5 or 7");
|
|
1289
|
+
}
|
|
1290
|
+
}
|
|
1291
|
+
matmulExternal(input) {
|
|
1292
|
+
const t = this.params.t;
|
|
1293
|
+
if (t == 2) {
|
|
1294
|
+
const sum = this.primeField.add(input[0], input[1]);
|
|
1295
|
+
input[0] = this.primeField.add(input[0], sum);
|
|
1296
|
+
input[1] = this.primeField.add(input[1], sum);
|
|
1297
|
+
} else if (t == 3) {
|
|
1298
|
+
const sum = this.primeField.add(this.primeField.add(input[0], input[1]), input[2]);
|
|
1299
|
+
input[0] = this.primeField.add(input[0], sum);
|
|
1300
|
+
input[1] = this.primeField.add(input[1], sum);
|
|
1301
|
+
input[2] = this.primeField.add(input[2], sum);
|
|
1302
|
+
} else if (t == 4 || t == 8 || t == 12 || t == 16 || t == 20 || t == 24) {
|
|
1303
|
+
const t4 = t / 4;
|
|
1304
|
+
for (let i = 0; i < t4; i++) {
|
|
1305
|
+
const startIndex = i * 4;
|
|
1306
|
+
let t_0 = input[startIndex];
|
|
1307
|
+
t_0 = this.primeField.add(t_0, input[startIndex + 1]);
|
|
1308
|
+
let t_1 = input[startIndex + 2];
|
|
1309
|
+
t_1 = this.primeField.add(t_1, input[startIndex + 3]);
|
|
1310
|
+
let t_2 = input[startIndex + 1];
|
|
1311
|
+
t_2 = this.primeField.add(t_2, t_2);
|
|
1312
|
+
t_2 = this.primeField.add(t_2, t_1);
|
|
1313
|
+
let t_3 = input[startIndex + 3];
|
|
1314
|
+
t_3 = this.primeField.add(t_3, t_3);
|
|
1315
|
+
t_3 = this.primeField.add(t_3, t_0);
|
|
1316
|
+
let t_4 = t_1;
|
|
1317
|
+
t_4 = this.primeField.add(t_4, t_4);
|
|
1318
|
+
t_4 = this.primeField.add(t_4, t_4);
|
|
1319
|
+
t_4 = this.primeField.add(t_4, t_3);
|
|
1320
|
+
let t_5 = t_0;
|
|
1321
|
+
t_5 = this.primeField.add(t_5, t_5);
|
|
1322
|
+
t_5 = this.primeField.add(t_5, t_5);
|
|
1323
|
+
t_5 = this.primeField.add(t_5, t_2);
|
|
1324
|
+
let t_6 = t_3;
|
|
1325
|
+
t_6 = this.primeField.add(t_6, t_5);
|
|
1326
|
+
let t_7 = t_2;
|
|
1327
|
+
t_7 = this.primeField.add(t_7, t_4);
|
|
1328
|
+
input[startIndex] = t_6;
|
|
1329
|
+
input[startIndex + 1] = t_5;
|
|
1330
|
+
input[startIndex + 2] = t_7;
|
|
1331
|
+
input[startIndex + 3] = t_4;
|
|
1332
|
+
}
|
|
1333
|
+
if (t > 4) {
|
|
1334
|
+
const stored = [
|
|
1335
|
+
this.primeField.zero,
|
|
1336
|
+
this.primeField.zero,
|
|
1337
|
+
this.primeField.zero,
|
|
1338
|
+
this.primeField.zero
|
|
1339
|
+
];
|
|
1340
|
+
for (let l = 0; l < 4; l++) {
|
|
1341
|
+
stored[l] = input[l];
|
|
1342
|
+
for (let j = 1; j < t4; j++) {
|
|
1343
|
+
stored[l] = this.primeField.add(stored[l], input[4 * j + l]);
|
|
1344
|
+
}
|
|
1345
|
+
}
|
|
1346
|
+
for (let i = 0; i < input.length; i++) {
|
|
1347
|
+
input[i] = this.primeField.add(input[i], stored[i % 4]);
|
|
1348
|
+
}
|
|
1349
|
+
}
|
|
1350
|
+
} else {
|
|
1351
|
+
throw new Error("Invalid t parameter, must be 2, 3, 4, 8, 12, 16, 20 or 24");
|
|
1352
|
+
}
|
|
1353
|
+
return input;
|
|
1354
|
+
}
|
|
1355
|
+
matmulInternal(input) {
|
|
1356
|
+
const t = this.params.t;
|
|
1357
|
+
if (t == 2) {
|
|
1358
|
+
const sum = this.primeField.add(input[0], input[1]);
|
|
1359
|
+
input[0] = this.primeField.add(input[0], sum);
|
|
1360
|
+
input[1] = this.primeField.add(this.primeField.add(input[1], input[1]), sum);
|
|
1361
|
+
} else if (t == 3) {
|
|
1362
|
+
const sum = this.primeField.add(this.primeField.add(input[0], input[1]), input[2]);
|
|
1363
|
+
input[0] = this.primeField.add(input[0], sum);
|
|
1364
|
+
input[1] = this.primeField.add(input[1], sum);
|
|
1365
|
+
input[2] = this.primeField.add(this.primeField.add(input[2], input[2]), sum);
|
|
1366
|
+
} else if (t == 4 || t == 8 || t == 12 || t == 16 || t == 20 || t == 24) {
|
|
1367
|
+
let sum = input[0];
|
|
1368
|
+
for (let i = 1; i < t; i++) {
|
|
1369
|
+
sum = this.primeField.add(sum, input[i]);
|
|
1370
|
+
}
|
|
1371
|
+
for (let i = 0; i < input.length; i++) {
|
|
1372
|
+
input[i] = this.primeField.add(this.primeField.mul(this.params.mat_internal_diag_m_1[i], input[i]), sum);
|
|
1373
|
+
}
|
|
1374
|
+
} else {
|
|
1375
|
+
throw new Error("Invalid t parameter, must be 2, 3, 4, 8, 12, 16, 20 or 24");
|
|
1376
|
+
}
|
|
1377
|
+
return input;
|
|
1378
|
+
}
|
|
1379
|
+
permute(input) {
|
|
1380
|
+
const t = this.params.t;
|
|
1381
|
+
if (input.length != t) {
|
|
1382
|
+
throw new Error("Invalid input length");
|
|
1383
|
+
}
|
|
1384
|
+
let current_state = input;
|
|
1385
|
+
this.matmulExternal(current_state);
|
|
1386
|
+
for (let r = 0; r < this.params.rounds_f_beginning; r++) {
|
|
1387
|
+
current_state = this.addRc(current_state, this.params.round_constants[r]);
|
|
1388
|
+
current_state = this.sbox(current_state);
|
|
1389
|
+
this.matmulExternal(current_state);
|
|
1390
|
+
}
|
|
1391
|
+
const p_end = this.params.rounds_f_beginning + this.params.rounds_p;
|
|
1392
|
+
for (let r = this.params.rounds_f_beginning; r < p_end; r++) {
|
|
1393
|
+
current_state[0] = this.primeField.add(current_state[0], this.params.round_constants[r][0]);
|
|
1394
|
+
current_state[0] = this.sboxP(current_state[0]);
|
|
1395
|
+
this.matmulInternal(current_state);
|
|
1396
|
+
}
|
|
1397
|
+
for (let r = p_end; r < this.params.rounds; r++) {
|
|
1398
|
+
current_state = this.addRc(current_state, this.params.round_constants[r]);
|
|
1399
|
+
current_state = this.sbox(current_state);
|
|
1400
|
+
this.matmulExternal(current_state);
|
|
1401
|
+
}
|
|
1402
|
+
return current_state;
|
|
1403
|
+
}
|
|
1404
|
+
addRc(input, rc) {
|
|
1405
|
+
return input.map((a, i) => this.primeField.add(a, rc[i]));
|
|
1406
|
+
}
|
|
1407
|
+
};
|
|
1408
|
+
|
|
1409
|
+
// ../../node_modules/.pnpm/@zkpassport+poseidon2@0.6.2/node_modules/@zkpassport/poseidon2/dist/esm/core/poseidon2params.js
|
|
1410
|
+
function getPoseidon2Params(t, d, rounds_f, rounds_p, mat_internal_diag_m_1, mat_internal, round_constants) {
|
|
1411
|
+
const r = rounds_f / 2;
|
|
1412
|
+
const rounds = rounds_f + rounds_p;
|
|
1413
|
+
return {
|
|
1414
|
+
t,
|
|
1415
|
+
d,
|
|
1416
|
+
rounds_f_beginning: r,
|
|
1417
|
+
rounds_p,
|
|
1418
|
+
rounds_f_end: r,
|
|
1419
|
+
rounds,
|
|
1420
|
+
mat_internal_diag_m_1,
|
|
1421
|
+
_mat_internal: mat_internal,
|
|
1422
|
+
round_constants
|
|
1423
|
+
};
|
|
1424
|
+
}
|
|
1425
|
+
|
|
1426
|
+
// ../../node_modules/.pnpm/@zkpassport+poseidon2@0.6.2/node_modules/@zkpassport/poseidon2/dist/esm/bn254/constants.js
|
|
1427
|
+
var MAT_DIAG4_M_1 = [
|
|
1428
|
+
BigInt("0x10dc6e9c006ea38b04b1e03b4bd9490c0d03f98929ca1d7fb56821fd19d3b6e7"),
|
|
1429
|
+
BigInt("0x0c28145b6a44df3e0149b3d0a30b3bb599df9756d4dd9b84a86b38cfb45a740b"),
|
|
1430
|
+
BigInt("0x00544b8338791518b2c7645a50392798b21f75bb60e3596170067d00141cac15"),
|
|
1431
|
+
BigInt("0x222c01175718386f2e2e82eb122789e352e105a3b8fa852613bc534433ee428b")
|
|
1432
|
+
];
|
|
1433
|
+
var MAT_INTERNAL4 = [
|
|
1434
|
+
[
|
|
1435
|
+
BigInt("0x10dc6e9c006ea38b04b1e03b4bd9490c0d03f98929ca1d7fb56821fd19d3b6e8"),
|
|
1436
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000001"),
|
|
1437
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000001"),
|
|
1438
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000001")
|
|
1439
|
+
],
|
|
1440
|
+
[
|
|
1441
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000001"),
|
|
1442
|
+
BigInt("0x0c28145b6a44df3e0149b3d0a30b3bb599df9756d4dd9b84a86b38cfb45a740c"),
|
|
1443
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000001"),
|
|
1444
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000001")
|
|
1445
|
+
],
|
|
1446
|
+
[
|
|
1447
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000001"),
|
|
1448
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000001"),
|
|
1449
|
+
BigInt("0x00544b8338791518b2c7645a50392798b21f75bb60e3596170067d00141cac16"),
|
|
1450
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000001")
|
|
1451
|
+
],
|
|
1452
|
+
[
|
|
1453
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000001"),
|
|
1454
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000001"),
|
|
1455
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000001"),
|
|
1456
|
+
BigInt("0x222c01175718386f2e2e82eb122789e352e105a3b8fa852613bc534433ee428c")
|
|
1457
|
+
]
|
|
1458
|
+
];
|
|
1459
|
+
var RC4 = [
|
|
1460
|
+
[
|
|
1461
|
+
BigInt("0x19b849f69450b06848da1d39bd5e4a4302bb86744edc26238b0878e269ed23e5"),
|
|
1462
|
+
BigInt("0x265ddfe127dd51bd7239347b758f0a1320eb2cc7450acc1dad47f80c8dcf34d6"),
|
|
1463
|
+
BigInt("0x199750ec472f1809e0f66a545e1e51624108ac845015c2aa3dfc36bab497d8aa"),
|
|
1464
|
+
BigInt("0x157ff3fe65ac7208110f06a5f74302b14d743ea25067f0ffd032f787c7f1cdf8")
|
|
1465
|
+
],
|
|
1466
|
+
[
|
|
1467
|
+
BigInt("0x2e49c43c4569dd9c5fd35ac45fca33f10b15c590692f8beefe18f4896ac94902"),
|
|
1468
|
+
BigInt("0x0e35fb89981890520d4aef2b6d6506c3cb2f0b6973c24fa82731345ffa2d1f1e"),
|
|
1469
|
+
BigInt("0x251ad47cb15c4f1105f109ae5e944f1ba9d9e7806d667ffec6fe723002e0b996"),
|
|
1470
|
+
BigInt("0x13da07dc64d428369873e97160234641f8beb56fdd05e5f3563fa39d9c22df4e")
|
|
1471
|
+
],
|
|
1472
|
+
[
|
|
1473
|
+
BigInt("0x0c009b84e650e6d23dc00c7dccef7483a553939689d350cd46e7b89055fd4738"),
|
|
1474
|
+
BigInt("0x011f16b1c63a854f01992e3956f42d8b04eb650c6d535eb0203dec74befdca06"),
|
|
1475
|
+
BigInt("0x0ed69e5e383a688f209d9a561daa79612f3f78d0467ad45485df07093f367549"),
|
|
1476
|
+
BigInt("0x04dba94a7b0ce9e221acad41472b6bbe3aec507f5eb3d33f463672264c9f789b")
|
|
1477
|
+
],
|
|
1478
|
+
[
|
|
1479
|
+
BigInt("0x0a3f2637d840f3a16eb094271c9d237b6036757d4bb50bf7ce732ff1d4fa28e8"),
|
|
1480
|
+
BigInt("0x259a666f129eea198f8a1c502fdb38fa39b1f075569564b6e54a485d1182323f"),
|
|
1481
|
+
BigInt("0x28bf7459c9b2f4c6d8e7d06a4ee3a47f7745d4271038e5157a32fdf7ede0d6a1"),
|
|
1482
|
+
BigInt("0x0a1ca941f057037526ea200f489be8d4c37c85bbcce6a2aeec91bd6941432447")
|
|
1483
|
+
],
|
|
1484
|
+
[
|
|
1485
|
+
BigInt("0x0c6f8f958be0e93053d7fd4fc54512855535ed1539f051dcb43a26fd926361cf"),
|
|
1486
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
|
1487
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
|
1488
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")
|
|
1489
|
+
],
|
|
1490
|
+
[
|
|
1491
|
+
BigInt("0x123106a93cd17578d426e8128ac9d90aa9e8a00708e296e084dd57e69caaf811"),
|
|
1492
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
|
1493
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
|
1494
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")
|
|
1495
|
+
],
|
|
1496
|
+
[
|
|
1497
|
+
BigInt("0x26e1ba52ad9285d97dd3ab52f8e840085e8fa83ff1e8f1877b074867cd2dee75"),
|
|
1498
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
|
1499
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
|
1500
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")
|
|
1501
|
+
],
|
|
1502
|
+
[
|
|
1503
|
+
BigInt("0x1cb55cad7bd133de18a64c5c47b9c97cbe4d8b7bf9e095864471537e6a4ae2c5"),
|
|
1504
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
|
1505
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
|
1506
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")
|
|
1507
|
+
],
|
|
1508
|
+
[
|
|
1509
|
+
BigInt("0x1dcd73e46acd8f8e0e2c7ce04bde7f6d2a53043d5060a41c7143f08e6e9055d0"),
|
|
1510
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
|
1511
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
|
1512
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")
|
|
1513
|
+
],
|
|
1514
|
+
[
|
|
1515
|
+
BigInt("0x011003e32f6d9c66f5852f05474a4def0cda294a0eb4e9b9b12b9bb4512e5574"),
|
|
1516
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
|
1517
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
|
1518
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")
|
|
1519
|
+
],
|
|
1520
|
+
[
|
|
1521
|
+
BigInt("0x2b1e809ac1d10ab29ad5f20d03a57dfebadfe5903f58bafed7c508dd2287ae8c"),
|
|
1522
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
|
1523
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
|
1524
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")
|
|
1525
|
+
],
|
|
1526
|
+
[
|
|
1527
|
+
BigInt("0x2539de1785b735999fb4dac35ee17ed0ef995d05ab2fc5faeaa69ae87bcec0a5"),
|
|
1528
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
|
1529
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
|
1530
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")
|
|
1531
|
+
],
|
|
1532
|
+
[
|
|
1533
|
+
BigInt("0x0c246c5a2ef8ee0126497f222b3e0a0ef4e1c3d41c86d46e43982cb11d77951d"),
|
|
1534
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
|
1535
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
|
1536
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")
|
|
1537
|
+
],
|
|
1538
|
+
[
|
|
1539
|
+
BigInt("0x192089c4974f68e95408148f7c0632edbb09e6a6ad1a1c2f3f0305f5d03b527b"),
|
|
1540
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
|
1541
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
|
1542
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")
|
|
1543
|
+
],
|
|
1544
|
+
[
|
|
1545
|
+
BigInt("0x1eae0ad8ab68b2f06a0ee36eeb0d0c058529097d91096b756d8fdc2fb5a60d85"),
|
|
1546
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
|
1547
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
|
1548
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")
|
|
1549
|
+
],
|
|
1550
|
+
[
|
|
1551
|
+
BigInt("0x179190e5d0e22179e46f8282872abc88db6e2fdc0dee99e69768bd98c5d06bfb"),
|
|
1552
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
|
1553
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
|
1554
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")
|
|
1555
|
+
],
|
|
1556
|
+
[
|
|
1557
|
+
BigInt("0x29bb9e2c9076732576e9a81c7ac4b83214528f7db00f31bf6cafe794a9b3cd1c"),
|
|
1558
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
|
1559
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
|
1560
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")
|
|
1561
|
+
],
|
|
1562
|
+
[
|
|
1563
|
+
BigInt("0x225d394e42207599403efd0c2464a90d52652645882aac35b10e590e6e691e08"),
|
|
1564
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
|
1565
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
|
1566
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")
|
|
1567
|
+
],
|
|
1568
|
+
[
|
|
1569
|
+
BigInt("0x064760623c25c8cf753d238055b444532be13557451c087de09efd454b23fd59"),
|
|
1570
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
|
1571
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
|
1572
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")
|
|
1573
|
+
],
|
|
1574
|
+
[
|
|
1575
|
+
BigInt("0x10ba3a0e01df92e87f301c4b716d8a394d67f4bf42a75c10922910a78f6b5b87"),
|
|
1576
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
|
1577
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
|
1578
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")
|
|
1579
|
+
],
|
|
1580
|
+
[
|
|
1581
|
+
BigInt("0x0e070bf53f8451b24f9c6e96b0c2a801cb511bc0c242eb9d361b77693f21471c"),
|
|
1582
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
|
1583
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
|
1584
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")
|
|
1585
|
+
],
|
|
1586
|
+
[
|
|
1587
|
+
BigInt("0x1b94cd61b051b04dd39755ff93821a73ccd6cb11d2491d8aa7f921014de252fb"),
|
|
1588
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
|
1589
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
|
1590
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")
|
|
1591
|
+
],
|
|
1592
|
+
[
|
|
1593
|
+
BigInt("0x1d7cb39bafb8c744e148787a2e70230f9d4e917d5713bb050487b5aa7d74070b"),
|
|
1594
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
|
1595
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
|
1596
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")
|
|
1597
|
+
],
|
|
1598
|
+
[
|
|
1599
|
+
BigInt("0x2ec93189bd1ab4f69117d0fe980c80ff8785c2961829f701bb74ac1f303b17db"),
|
|
1600
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
|
1601
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
|
1602
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")
|
|
1603
|
+
],
|
|
1604
|
+
[
|
|
1605
|
+
BigInt("0x2db366bfdd36d277a692bb825b86275beac404a19ae07a9082ea46bd83517926"),
|
|
1606
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
|
1607
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
|
1608
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")
|
|
1609
|
+
],
|
|
1610
|
+
[
|
|
1611
|
+
BigInt("0x062100eb485db06269655cf186a68532985275428450359adc99cec6960711b8"),
|
|
1612
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
|
1613
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
|
1614
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")
|
|
1615
|
+
],
|
|
1616
|
+
[
|
|
1617
|
+
BigInt("0x0761d33c66614aaa570e7f1e8244ca1120243f92fa59e4f900c567bf41f5a59b"),
|
|
1618
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
|
1619
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
|
1620
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")
|
|
1621
|
+
],
|
|
1622
|
+
[
|
|
1623
|
+
BigInt("0x20fc411a114d13992c2705aa034e3f315d78608a0f7de4ccf7a72e494855ad0d"),
|
|
1624
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
|
1625
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
|
1626
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")
|
|
1627
|
+
],
|
|
1628
|
+
[
|
|
1629
|
+
BigInt("0x25b5c004a4bdfcb5add9ec4e9ab219ba102c67e8b3effb5fc3a30f317250bc5a"),
|
|
1630
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
|
1631
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
|
1632
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")
|
|
1633
|
+
],
|
|
1634
|
+
[
|
|
1635
|
+
BigInt("0x23b1822d278ed632a494e58f6df6f5ed038b186d8474155ad87e7dff62b37f4b"),
|
|
1636
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
|
1637
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
|
1638
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")
|
|
1639
|
+
],
|
|
1640
|
+
[
|
|
1641
|
+
BigInt("0x22734b4c5c3f9493606c4ba9012499bf0f14d13bfcfcccaa16102a29cc2f69e0"),
|
|
1642
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
|
1643
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
|
1644
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")
|
|
1645
|
+
],
|
|
1646
|
+
[
|
|
1647
|
+
BigInt("0x26c0c8fe09eb30b7e27a74dc33492347e5bdff409aa3610254413d3fad795ce5"),
|
|
1648
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
|
1649
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
|
1650
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")
|
|
1651
|
+
],
|
|
1652
|
+
[
|
|
1653
|
+
BigInt("0x070dd0ccb6bd7bbae88eac03fa1fbb26196be3083a809829bbd626df348ccad9"),
|
|
1654
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
|
1655
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
|
1656
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")
|
|
1657
|
+
],
|
|
1658
|
+
[
|
|
1659
|
+
BigInt("0x12b6595bdb329b6fb043ba78bb28c3bec2c0a6de46d8c5ad6067c4ebfd4250da"),
|
|
1660
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
|
1661
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
|
1662
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")
|
|
1663
|
+
],
|
|
1664
|
+
[
|
|
1665
|
+
BigInt("0x248d97d7f76283d63bec30e7a5876c11c06fca9b275c671c5e33d95bb7e8d729"),
|
|
1666
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
|
1667
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
|
1668
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")
|
|
1669
|
+
],
|
|
1670
|
+
[
|
|
1671
|
+
BigInt("0x1a306d439d463b0816fc6fd64cc939318b45eb759ddde4aa106d15d9bd9baaaa"),
|
|
1672
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
|
1673
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
|
1674
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")
|
|
1675
|
+
],
|
|
1676
|
+
[
|
|
1677
|
+
BigInt("0x28a8f8372e3c38daced7c00421cb4621f4f1b54ddc27821b0d62d3d6ec7c56cf"),
|
|
1678
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
|
1679
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
|
1680
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")
|
|
1681
|
+
],
|
|
1682
|
+
[
|
|
1683
|
+
BigInt("0x0094975717f9a8a8bb35152f24d43294071ce320c829f388bc852183e1e2ce7e"),
|
|
1684
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
|
1685
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
|
1686
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")
|
|
1687
|
+
],
|
|
1688
|
+
[
|
|
1689
|
+
BigInt("0x04d5ee4c3aa78f7d80fde60d716480d3593f74d4f653ae83f4103246db2e8d65"),
|
|
1690
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
|
1691
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
|
1692
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")
|
|
1693
|
+
],
|
|
1694
|
+
[
|
|
1695
|
+
BigInt("0x2a6cf5e9aa03d4336349ad6fb8ed2269c7bef54b8822cc76d08495c12efde187"),
|
|
1696
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
|
1697
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
|
1698
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")
|
|
1699
|
+
],
|
|
1700
|
+
[
|
|
1701
|
+
BigInt("0x2304d31eaab960ba9274da43e19ddeb7f792180808fd6e43baae48d7efcba3f3"),
|
|
1702
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
|
1703
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
|
1704
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")
|
|
1705
|
+
],
|
|
1706
|
+
[
|
|
1707
|
+
BigInt("0x03fd9ac865a4b2a6d5e7009785817249bff08a7e0726fcb4e1c11d39d199f0b0"),
|
|
1708
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
|
1709
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
|
1710
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")
|
|
1711
|
+
],
|
|
1712
|
+
[
|
|
1713
|
+
BigInt("0x00b7258ded52bbda2248404d55ee5044798afc3a209193073f7954d4d63b0b64"),
|
|
1714
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
|
1715
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
|
1716
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")
|
|
1717
|
+
],
|
|
1718
|
+
[
|
|
1719
|
+
BigInt("0x159f81ada0771799ec38fca2d4bf65ebb13d3a74f3298db36272c5ca65e92d9a"),
|
|
1720
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
|
1721
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
|
1722
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")
|
|
1723
|
+
],
|
|
1724
|
+
[
|
|
1725
|
+
BigInt("0x1ef90e67437fbc8550237a75bc28e3bb9000130ea25f0c5471e144cf4264431f"),
|
|
1726
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
|
1727
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
|
1728
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")
|
|
1729
|
+
],
|
|
1730
|
+
[
|
|
1731
|
+
BigInt("0x1e65f838515e5ff0196b49aa41a2d2568df739bc176b08ec95a79ed82932e30d"),
|
|
1732
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
|
1733
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
|
1734
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")
|
|
1735
|
+
],
|
|
1736
|
+
[
|
|
1737
|
+
BigInt("0x2b1b045def3a166cec6ce768d079ba74b18c844e570e1f826575c1068c94c33f"),
|
|
1738
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
|
1739
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
|
1740
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")
|
|
1741
|
+
],
|
|
1742
|
+
[
|
|
1743
|
+
BigInt("0x0832e5753ceb0ff6402543b1109229c165dc2d73bef715e3f1c6e07c168bb173"),
|
|
1744
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
|
1745
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
|
1746
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")
|
|
1747
|
+
],
|
|
1748
|
+
[
|
|
1749
|
+
BigInt("0x02f614e9cedfb3dc6b762ae0a37d41bab1b841c2e8b6451bc5a8e3c390b6ad16"),
|
|
1750
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
|
1751
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
|
1752
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")
|
|
1753
|
+
],
|
|
1754
|
+
[
|
|
1755
|
+
BigInt("0x0e2427d38bd46a60dd640b8e362cad967370ebb777bedff40f6a0be27e7ed705"),
|
|
1756
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
|
1757
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
|
1758
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")
|
|
1759
|
+
],
|
|
1760
|
+
[
|
|
1761
|
+
BigInt("0x0493630b7c670b6deb7c84d414e7ce79049f0ec098c3c7c50768bbe29214a53a"),
|
|
1762
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
|
1763
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
|
1764
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")
|
|
1765
|
+
],
|
|
1766
|
+
[
|
|
1767
|
+
BigInt("0x22ead100e8e482674decdab17066c5a26bb1515355d5461a3dc06cc85327cea9"),
|
|
1768
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
|
1769
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
|
1770
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")
|
|
1771
|
+
],
|
|
1772
|
+
[
|
|
1773
|
+
BigInt("0x25b3e56e655b42cdaae2626ed2554d48583f1ae35626d04de5084e0b6d2a6f16"),
|
|
1774
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
|
1775
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
|
1776
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")
|
|
1777
|
+
],
|
|
1778
|
+
[
|
|
1779
|
+
BigInt("0x1e32752ada8836ef5837a6cde8ff13dbb599c336349e4c584b4fdc0a0cf6f9d0"),
|
|
1780
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
|
1781
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
|
1782
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")
|
|
1783
|
+
],
|
|
1784
|
+
[
|
|
1785
|
+
BigInt("0x2fa2a871c15a387cc50f68f6f3c3455b23c00995f05078f672a9864074d412e5"),
|
|
1786
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
|
1787
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
|
1788
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")
|
|
1789
|
+
],
|
|
1790
|
+
[
|
|
1791
|
+
BigInt("0x2f569b8a9a4424c9278e1db7311e889f54ccbf10661bab7fcd18e7c7a7d83505"),
|
|
1792
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
|
1793
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
|
1794
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")
|
|
1795
|
+
],
|
|
1796
|
+
[
|
|
1797
|
+
BigInt("0x044cb455110a8fdd531ade530234c518a7df93f7332ffd2144165374b246b43d"),
|
|
1798
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
|
1799
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
|
1800
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")
|
|
1801
|
+
],
|
|
1802
|
+
[
|
|
1803
|
+
BigInt("0x227808de93906d5d420246157f2e42b191fe8c90adfe118178ddc723a5319025"),
|
|
1804
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
|
1805
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
|
1806
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")
|
|
1807
|
+
],
|
|
1808
|
+
[
|
|
1809
|
+
BigInt("0x02fcca2934e046bc623adead873579865d03781ae090ad4a8579d2e7a6800355"),
|
|
1810
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
|
1811
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
|
1812
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")
|
|
1813
|
+
],
|
|
1814
|
+
[
|
|
1815
|
+
BigInt("0x0ef915f0ac120b876abccceb344a1d36bad3f3c5ab91a8ddcbec2e060d8befac"),
|
|
1816
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
|
1817
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
|
1818
|
+
BigInt("0x0000000000000000000000000000000000000000000000000000000000000000")
|
|
1819
|
+
],
|
|
1820
|
+
[
|
|
1821
|
+
BigInt("0x1797130f4b7a3e1777eb757bc6f287f6ab0fb85f6be63b09f3b16ef2b1405d38"),
|
|
1822
|
+
BigInt("0x0a76225dc04170ae3306c85abab59e608c7f497c20156d4d36c668555decc6e5"),
|
|
1823
|
+
BigInt("0x1fffb9ec1992d66ba1e77a7b93209af6f8fa76d48acb664796174b5326a31a5c"),
|
|
1824
|
+
BigInt("0x25721c4fc15a3f2853b57c338fa538d85f8fbba6c6b9c6090611889b797b9c5f")
|
|
1825
|
+
],
|
|
1826
|
+
[
|
|
1827
|
+
BigInt("0x0c817fd42d5f7a41215e3d07ba197216adb4c3790705da95eb63b982bfcaf75a"),
|
|
1828
|
+
BigInt("0x13abe3f5239915d39f7e13c2c24970b6df8cf86ce00a22002bc15866e52b5a96"),
|
|
1829
|
+
BigInt("0x2106feea546224ea12ef7f39987a46c85c1bc3dc29bdbd7a92cd60acb4d391ce"),
|
|
1830
|
+
BigInt("0x21ca859468a746b6aaa79474a37dab49f1ca5a28c748bc7157e1b3345bb0f959")
|
|
1831
|
+
],
|
|
1832
|
+
[
|
|
1833
|
+
BigInt("0x05ccd6255c1e6f0c5cf1f0df934194c62911d14d0321662a8f1a48999e34185b"),
|
|
1834
|
+
BigInt("0x0f0e34a64b70a626e464d846674c4c8816c4fb267fe44fe6ea28678cb09490a4"),
|
|
1835
|
+
BigInt("0x0558531a4e25470c6157794ca36d0e9647dbfcfe350d64838f5b1a8a2de0d4bf"),
|
|
1836
|
+
BigInt("0x09d3dca9173ed2faceea125157683d18924cadad3f655a60b72f5864961f1455")
|
|
1837
|
+
],
|
|
1838
|
+
[
|
|
1839
|
+
BigInt("0x0328cbd54e8c0913493f866ed03d218bf23f92d68aaec48617d4c722e5bd4335"),
|
|
1840
|
+
BigInt("0x2bf07216e2aff0a223a487b1a7094e07e79e7bcc9798c648ee3347dd5329d34b"),
|
|
1841
|
+
BigInt("0x1daf345a58006b736499c583cb76c316d6f78ed6a6dffc82111e11a63fe412df"),
|
|
1842
|
+
BigInt("0x176563472456aaa746b694c60e1823611ef39039b2edc7ff391e6f2293d2c404")
|
|
1843
|
+
]
|
|
1844
|
+
];
|
|
1845
|
+
|
|
1846
|
+
// ../../node_modules/.pnpm/@zkpassport+poseidon2@0.6.2/node_modules/@zkpassport/poseidon2/dist/esm/bn254/instance.js
|
|
1847
|
+
var bn254Field = new F1Field(BigInt("21888242871839275222246405745257275088548364400416034343698204186575808495617"));
|
|
1848
|
+
var instance = null;
|
|
1849
|
+
function getPoseidon2BN254() {
|
|
1850
|
+
if (!instance) {
|
|
1851
|
+
instance = new Poseidon2(getPoseidon2Params(4, 5, 8, 56, MAT_DIAG4_M_1, MAT_INTERNAL4, RC4), bn254Field);
|
|
1852
|
+
}
|
|
1853
|
+
return instance;
|
|
1854
|
+
}
|
|
1855
|
+
|
|
1856
|
+
// ../../node_modules/.pnpm/@zkpassport+poseidon2@0.6.2/node_modules/@zkpassport/poseidon2/dist/esm/bn254/hash.js
|
|
1857
|
+
var F = getPoseidon2BN254().primeField;
|
|
1858
|
+
var permute = getPoseidon2BN254().permute.bind(getPoseidon2BN254());
|
|
1859
|
+
var Mode;
|
|
1860
|
+
(function(Mode3) {
|
|
1861
|
+
Mode3[Mode3["ABSORB"] = 0] = "ABSORB";
|
|
1862
|
+
Mode3[Mode3["SQUEEZE"] = 1] = "SQUEEZE";
|
|
1863
|
+
})(Mode || (Mode = {}));
|
|
1864
|
+
var FieldSponge = class _FieldSponge {
|
|
1865
|
+
constructor(domainIv = 0n) {
|
|
1866
|
+
this.rate = getPoseidon2BN254().getT() - 1;
|
|
1867
|
+
this.t = getPoseidon2BN254().getT();
|
|
1868
|
+
this.state = new Array(this.t).fill(0n);
|
|
1869
|
+
this.state[this.rate] = domainIv;
|
|
1870
|
+
this.cache = new Array(this.rate).fill(0n);
|
|
1871
|
+
this.cacheSize = 0;
|
|
1872
|
+
this.mode = Mode.ABSORB;
|
|
1873
|
+
}
|
|
1874
|
+
performDuplex() {
|
|
1875
|
+
for (let i = this.cacheSize; i < this.rate; i++) {
|
|
1876
|
+
this.cache[i] = 0n;
|
|
1877
|
+
}
|
|
1878
|
+
for (let i = 0; i < this.rate; i++) {
|
|
1879
|
+
this.state[i] = F.add(this.state[i], this.cache[i]);
|
|
1880
|
+
}
|
|
1881
|
+
this.state = permute(this.state);
|
|
1882
|
+
return this.state.slice(0, this.rate);
|
|
1883
|
+
}
|
|
1884
|
+
absorb(input) {
|
|
1885
|
+
if (this.mode === Mode.ABSORB && this.cacheSize === this.rate) {
|
|
1886
|
+
this.performDuplex();
|
|
1887
|
+
this.cache[0] = input;
|
|
1888
|
+
this.cacheSize = 1;
|
|
1889
|
+
} else if (this.mode === Mode.ABSORB && this.cacheSize < this.rate) {
|
|
1890
|
+
this.cache[this.cacheSize] = input;
|
|
1891
|
+
this.cacheSize += 1;
|
|
1892
|
+
} else if (this.mode === Mode.SQUEEZE) {
|
|
1893
|
+
this.cache[0] = input;
|
|
1894
|
+
this.cacheSize = 1;
|
|
1895
|
+
this.mode = Mode.ABSORB;
|
|
1896
|
+
}
|
|
1897
|
+
}
|
|
1898
|
+
squeeze() {
|
|
1899
|
+
if (this.mode === Mode.SQUEEZE && this.cacheSize === 0) {
|
|
1900
|
+
this.mode = Mode.ABSORB;
|
|
1901
|
+
this.cacheSize = 0;
|
|
1902
|
+
}
|
|
1903
|
+
if (this.mode === Mode.ABSORB) {
|
|
1904
|
+
const newOutputElements = this.performDuplex();
|
|
1905
|
+
this.mode = Mode.SQUEEZE;
|
|
1906
|
+
for (let i = 0; i < this.rate; i++) {
|
|
1907
|
+
this.cache[i] = newOutputElements[i];
|
|
1908
|
+
}
|
|
1909
|
+
this.cacheSize = this.rate;
|
|
1910
|
+
}
|
|
1911
|
+
const result = this.cache[0];
|
|
1912
|
+
for (let i = 1; i < this.cacheSize; i++) {
|
|
1913
|
+
this.cache[i - 1] = this.cache[i];
|
|
1914
|
+
}
|
|
1915
|
+
this.cacheSize -= 1;
|
|
1916
|
+
this.cache[this.cacheSize] = 0n;
|
|
1917
|
+
return result;
|
|
1918
|
+
}
|
|
1919
|
+
static hashInternal(input, outLen, isVariableLength) {
|
|
1920
|
+
const iv = (BigInt(input.length) << BigInt(64n)) + BigInt(outLen - 1);
|
|
1921
|
+
const sponge = new _FieldSponge(iv);
|
|
1922
|
+
for (let i = 0; i < input.length; i++) {
|
|
1923
|
+
sponge.absorb(input[i]);
|
|
1924
|
+
}
|
|
1925
|
+
if (isVariableLength) {
|
|
1926
|
+
sponge.absorb(1n);
|
|
1927
|
+
}
|
|
1928
|
+
const output = [];
|
|
1929
|
+
for (let i = 0; i < outLen; i++) {
|
|
1930
|
+
output.push(sponge.squeeze());
|
|
1931
|
+
}
|
|
1932
|
+
return output;
|
|
1933
|
+
}
|
|
1934
|
+
static hashFixedLength(input, outLen = 1) {
|
|
1935
|
+
return this.hashInternal(input, outLen, false);
|
|
1936
|
+
}
|
|
1937
|
+
static hashVariableLength(input, outLen = 1) {
|
|
1938
|
+
return this.hashInternal(input, outLen, true);
|
|
1939
|
+
}
|
|
1940
|
+
};
|
|
1941
|
+
function hashToField(input) {
|
|
1942
|
+
return FieldSponge.hashFixedLength(input)[0];
|
|
1943
|
+
}
|
|
1944
|
+
|
|
1945
|
+
// ../../node_modules/.pnpm/@zkpassport+poseidon2@0.6.2/node_modules/@zkpassport/poseidon2/dist/esm/bn254/hash-async.js
|
|
1946
|
+
var F2 = getPoseidon2BN254().primeField;
|
|
1947
|
+
var permute2 = getPoseidon2BN254().permute.bind(getPoseidon2BN254());
|
|
1948
|
+
var Mode2;
|
|
1949
|
+
(function(Mode3) {
|
|
1950
|
+
Mode3[Mode3["ABSORB"] = 0] = "ABSORB";
|
|
1951
|
+
Mode3[Mode3["SQUEEZE"] = 1] = "SQUEEZE";
|
|
1952
|
+
})(Mode2 || (Mode2 = {}));
|
|
1953
|
+
|
|
1954
|
+
// ../../node_modules/.pnpm/@zkpassport+poseidon2@0.6.2/node_modules/@zkpassport/poseidon2/dist/esm/bn254/index.js
|
|
1955
|
+
var F3 = getPoseidon2BN254().primeField;
|
|
1956
|
+
|
|
1957
|
+
// ../artifact-core/dist/commitment.js
|
|
1958
|
+
var BN254_MODULUS = 21888242871839275222246405745257275088548364400416034343698204186575808495617n;
|
|
1959
|
+
|
|
1960
|
+
// ../artifact-core/dist/validate-artifact.js
|
|
1961
|
+
var PROOF_LEVELS = [
|
|
1962
|
+
"mathematical",
|
|
1963
|
+
"verifiable_inference",
|
|
1964
|
+
"operator_bound",
|
|
1965
|
+
"execution",
|
|
1966
|
+
"witnessed",
|
|
1967
|
+
"attestation"
|
|
1968
|
+
];
|
|
1969
|
+
var GAP_TYPES = /* @__PURE__ */ new Set([
|
|
1970
|
+
// Original runtime-governance set (migration 019)
|
|
1971
|
+
"admission_gate_override",
|
|
1972
|
+
"check_degraded",
|
|
1973
|
+
"check_not_executed",
|
|
1974
|
+
"check_timing_suspect",
|
|
1975
|
+
"deterministic_consistency_violation",
|
|
1976
|
+
"enforcement_override",
|
|
1977
|
+
"engine_error",
|
|
1978
|
+
"external_boundary_traversal",
|
|
1979
|
+
"lineage_token_missing",
|
|
1980
|
+
"policy_config_drift",
|
|
1981
|
+
"reviewer_credential_invalid",
|
|
1982
|
+
"skip_rationale_missing",
|
|
1983
|
+
"witnessed_display_missing",
|
|
1984
|
+
"witnessed_rationale_missing",
|
|
1985
|
+
"zkml_proof_failed",
|
|
1986
|
+
"zkml_proof_pending_timeout",
|
|
1987
|
+
// Server-emitted during run enrichment / VPEC assembly (migration 076)
|
|
1988
|
+
"archetype_unmapped",
|
|
1989
|
+
"bias_audit_missing",
|
|
1990
|
+
"bounded_inference_downgrade",
|
|
1991
|
+
"explanation_missing",
|
|
1992
|
+
"manifest_metadata_missing",
|
|
1993
|
+
"model_profile_missing",
|
|
1994
|
+
"nesting_depth_exceeded",
|
|
1995
|
+
"orphan_run_gap",
|
|
1996
|
+
"parent_run_invalid",
|
|
1997
|
+
"partial_submission",
|
|
1998
|
+
"proof_level_floor_breach",
|
|
1999
|
+
"provable_surface_invariant_violation",
|
|
2000
|
+
"queue_drain_exhausted",
|
|
2001
|
+
"record_count_mismatch",
|
|
2002
|
+
"run_expired_without_close",
|
|
2003
|
+
"sla_breach",
|
|
2004
|
+
"stage_type_unresolved",
|
|
2005
|
+
"subagent_identity_ambiguous",
|
|
2006
|
+
"system_error",
|
|
2007
|
+
"system_unavailable",
|
|
2008
|
+
"witnessed_timestamp_invalid",
|
|
2009
|
+
// Upstream VPEC verification failures
|
|
2010
|
+
"upstream_vpec_insufficient_proof_level",
|
|
2011
|
+
"upstream_vpec_invalid_signature",
|
|
2012
|
+
"upstream_vpec_issuer_mismatch",
|
|
2013
|
+
"upstream_vpec_key_revoked",
|
|
2014
|
+
"upstream_vpec_missing",
|
|
2015
|
+
"upstream_vpec_missing_claim",
|
|
2016
|
+
"upstream_vpec_sandbox",
|
|
2017
|
+
// Connector adapter errors (per-vendor allowlist)
|
|
2018
|
+
"actimize_api_error",
|
|
2019
|
+
"actimize_auth_failure",
|
|
2020
|
+
"blaze_api_error",
|
|
2021
|
+
"blaze_auth_failure",
|
|
2022
|
+
"complyadvantage_api_error",
|
|
2023
|
+
"complyadvantage_auth_failure",
|
|
2024
|
+
"falcon_api_error",
|
|
2025
|
+
"falcon_auth_failure",
|
|
2026
|
+
"guidewire_api_error",
|
|
2027
|
+
"guidewire_auth_failure",
|
|
2028
|
+
"odm_api_error",
|
|
2029
|
+
"odm_auth_failure",
|
|
2030
|
+
"pega_api_error",
|
|
2031
|
+
"pega_auth_failure",
|
|
2032
|
+
"wolters_kluwer_api_error",
|
|
2033
|
+
"wolters_kluwer_auth_failure",
|
|
2034
|
+
// Migration-tool error categories
|
|
2035
|
+
"migration_auth_failed",
|
|
2036
|
+
"migration_record_unmigratable",
|
|
2037
|
+
// Control-plan binding gaps (not yet in migration 076 but emitted by runs.py / auto_dispatcher)
|
|
2038
|
+
"control_plan_binding_missing",
|
|
2039
|
+
"control_plan_hash_mismatch",
|
|
2040
|
+
"control_plan_system_mismatch",
|
|
2041
|
+
// GRT / signing gaps
|
|
2042
|
+
"grt_signing_failed",
|
|
2043
|
+
"signing_delayed",
|
|
2044
|
+
// Action-level gaps (ungoverned action discovery)
|
|
2045
|
+
"ungoverned_action",
|
|
2046
|
+
"consequential_ungoverned_action",
|
|
2047
|
+
"missing_executor",
|
|
2048
|
+
// Phase 6 bridge taxonomy (migration 134; docs/v29/ZK_BRIDGE_BUILD_PLAN.md §3)
|
|
2049
|
+
"proof_dispatch_failure",
|
|
2050
|
+
"proof_timeout",
|
|
2051
|
+
"proof_verification_failure",
|
|
2052
|
+
"circuit_not_green_yellow_quarantined",
|
|
2053
|
+
"circuit_not_green_red_quarantined",
|
|
2054
|
+
"witness_build_failure",
|
|
2055
|
+
// Pre-bridge proof-failed webhook emits this; was missing from earlier allowlists
|
|
2056
|
+
"proof_generation_failed"
|
|
2057
|
+
]);
|
|
2058
|
+
var GAP_SEVERITIES = /* @__PURE__ */ new Set(["Critical", "High", "Medium", "Low", "Informational"]);
|
|
2059
|
+
var PUBLIC_KEY_URL_PATTERN = /^https:\/\/(?:primust|keys\.primust)\.com\/\.well-known\/primust-pubkeys\/.+\.pem$/;
|
|
2060
|
+
function validateArtifact(artifact) {
|
|
2061
|
+
const errors = [];
|
|
2062
|
+
if ("reliance_mode" in artifact) {
|
|
2063
|
+
errors.push({
|
|
2064
|
+
code: "RELIANCE_MODE_FORBIDDEN",
|
|
2065
|
+
message: "reliance_mode field is forbidden in VPEC artifacts",
|
|
2066
|
+
path: "reliance_mode"
|
|
2067
|
+
});
|
|
2068
|
+
}
|
|
2069
|
+
checkNestedRelianceMode(artifact, "", errors);
|
|
2070
|
+
if (artifact.schema_version !== "4.0.0") {
|
|
2071
|
+
errors.push({
|
|
2072
|
+
code: "INVALID_SCHEMA_VERSION",
|
|
2073
|
+
message: `schema_version must be "4.0.0", got "${artifact.schema_version}"`,
|
|
2074
|
+
path: "schema_version"
|
|
2075
|
+
});
|
|
2076
|
+
}
|
|
2077
|
+
const proofDist = artifact.proof_distribution;
|
|
2078
|
+
if (proofDist && artifact.proof_level !== proofDist.weakest_link) {
|
|
2079
|
+
errors.push({
|
|
2080
|
+
code: "PROOF_LEVEL_MISMATCH",
|
|
2081
|
+
message: `proof_level "${artifact.proof_level}" does not match proof_distribution.weakest_link "${proofDist.weakest_link}"`,
|
|
2082
|
+
path: "proof_level"
|
|
2083
|
+
});
|
|
2084
|
+
}
|
|
2085
|
+
if (artifact.proof_level && !PROOF_LEVELS.includes(artifact.proof_level)) {
|
|
2086
|
+
errors.push({
|
|
2087
|
+
code: "INVALID_PROOF_LEVEL",
|
|
2088
|
+
message: `proof_level "${artifact.proof_level}" is not a valid proof level`,
|
|
2089
|
+
path: "proof_level"
|
|
2090
|
+
});
|
|
2091
|
+
}
|
|
2092
|
+
if (Array.isArray(artifact.manifest_hashes)) {
|
|
2093
|
+
errors.push({
|
|
2094
|
+
code: "MANIFEST_HASHES_NOT_MAP",
|
|
2095
|
+
message: "manifest_hashes must be an object (map), not an array",
|
|
2096
|
+
path: "manifest_hashes"
|
|
2097
|
+
});
|
|
2098
|
+
}
|
|
2099
|
+
const gaps = artifact.gaps;
|
|
2100
|
+
if (Array.isArray(gaps)) {
|
|
2101
|
+
for (let i = 0; i < gaps.length; i++) {
|
|
2102
|
+
const gap = gaps[i];
|
|
2103
|
+
if (typeof gap === "string") {
|
|
2104
|
+
errors.push({
|
|
2105
|
+
code: "GAP_BARE_STRING",
|
|
2106
|
+
message: `gaps[${i}] is a bare string \u2014 must be an object with gap_type and severity`,
|
|
2107
|
+
path: `gaps[${i}]`
|
|
2108
|
+
});
|
|
2109
|
+
continue;
|
|
2110
|
+
}
|
|
2111
|
+
if (typeof gap !== "object" || gap === null) {
|
|
2112
|
+
errors.push({
|
|
2113
|
+
code: "GAP_INVALID_TYPE",
|
|
2114
|
+
message: `gaps[${i}] must be an object with gap_type and severity`,
|
|
2115
|
+
path: `gaps[${i}]`
|
|
2116
|
+
});
|
|
2117
|
+
continue;
|
|
2118
|
+
}
|
|
2119
|
+
if (!gap.gap_type || !gap.severity) {
|
|
2120
|
+
errors.push({
|
|
2121
|
+
code: "GAP_MISSING_FIELDS",
|
|
2122
|
+
message: `gaps[${i}] must have gap_type and severity fields`,
|
|
2123
|
+
path: `gaps[${i}]`
|
|
2124
|
+
});
|
|
2125
|
+
}
|
|
2126
|
+
if (gap.gap_type && !GAP_TYPES.has(gap.gap_type)) {
|
|
2127
|
+
errors.push({
|
|
2128
|
+
code: "GAP_INVALID_TYPE_VALUE",
|
|
2129
|
+
message: `gaps[${i}].gap_type "${gap.gap_type}" is not a valid gap type`,
|
|
2130
|
+
path: `gaps[${i}].gap_type`
|
|
2131
|
+
});
|
|
2132
|
+
}
|
|
2133
|
+
if (gap.severity && !GAP_SEVERITIES.has(gap.severity)) {
|
|
2134
|
+
errors.push({
|
|
2135
|
+
code: "GAP_INVALID_SEVERITY",
|
|
2136
|
+
message: `gaps[${i}].severity "${gap.severity}" is not a valid severity`,
|
|
2137
|
+
path: `gaps[${i}].severity`
|
|
2138
|
+
});
|
|
2139
|
+
}
|
|
2140
|
+
}
|
|
2141
|
+
}
|
|
2142
|
+
const coverage = artifact.coverage;
|
|
2143
|
+
if (artifact.partial === true && coverage) {
|
|
2144
|
+
if (typeof coverage.policy_coverage_pct === "number" && coverage.policy_coverage_pct !== 0) {
|
|
2145
|
+
errors.push({
|
|
2146
|
+
code: "PARTIAL_COVERAGE_NOT_ZERO",
|
|
2147
|
+
message: `partial: true requires policy_coverage_pct to be 0, got ${coverage.policy_coverage_pct}`,
|
|
2148
|
+
path: "coverage.policy_coverage_pct"
|
|
2149
|
+
});
|
|
2150
|
+
}
|
|
2151
|
+
}
|
|
2152
|
+
const issuer = artifact.issuer;
|
|
2153
|
+
if (issuer && typeof issuer.public_key_url === "string") {
|
|
2154
|
+
if (!PUBLIC_KEY_URL_PATTERN.test(issuer.public_key_url)) {
|
|
2155
|
+
errors.push({
|
|
2156
|
+
code: "ISSUER_URL_INVALID",
|
|
2157
|
+
message: `issuer.public_key_url must match https://primust.com/.well-known/primust-pubkeys/*.pem or https://keys.primust.com/.well-known/primust-pubkeys/*.pem, got "${issuer.public_key_url}"`,
|
|
2158
|
+
path: "issuer.public_key_url"
|
|
2159
|
+
});
|
|
2160
|
+
}
|
|
2161
|
+
}
|
|
2162
|
+
return { valid: errors.length === 0, errors };
|
|
2163
|
+
}
|
|
2164
|
+
function checkNestedRelianceMode(obj, path, errors) {
|
|
2165
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
2166
|
+
const currentPath = path ? `${path}.${key}` : key;
|
|
2167
|
+
if (key === "reliance_mode" && currentPath !== "reliance_mode") {
|
|
2168
|
+
errors.push({
|
|
2169
|
+
code: "RELIANCE_MODE_FORBIDDEN",
|
|
2170
|
+
message: `reliance_mode field is forbidden in VPEC artifacts (found at ${currentPath})`,
|
|
2171
|
+
path: currentPath
|
|
2172
|
+
});
|
|
2173
|
+
}
|
|
2174
|
+
if (value && typeof value === "object" && !Array.isArray(value)) {
|
|
2175
|
+
checkNestedRelianceMode(value, currentPath, errors);
|
|
2176
|
+
}
|
|
2177
|
+
}
|
|
2178
|
+
}
|
|
2179
|
+
|
|
2180
|
+
// src/verifier.ts
|
|
2181
|
+
function hasRelianceMode(obj, path = "") {
|
|
2182
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
2183
|
+
const currentPath = path ? `${path}.${key}` : key;
|
|
2184
|
+
if (key === "reliance_mode") {
|
|
2185
|
+
return currentPath;
|
|
2186
|
+
}
|
|
2187
|
+
if (value && typeof value === "object" && !Array.isArray(value)) {
|
|
2188
|
+
const found = hasRelianceMode(value, currentPath);
|
|
2189
|
+
if (found) return found;
|
|
2190
|
+
}
|
|
2191
|
+
}
|
|
2192
|
+
return null;
|
|
2193
|
+
}
|
|
2194
|
+
function baseResult(artifact) {
|
|
2195
|
+
const sig = artifact.signature;
|
|
2196
|
+
const issuer = artifact.issuer;
|
|
2197
|
+
const proofDist = artifact.proof_distribution;
|
|
2198
|
+
const coverage = artifact.coverage;
|
|
2199
|
+
const gaps = Array.isArray(artifact.gaps) ? artifact.gaps : [];
|
|
2200
|
+
return {
|
|
2201
|
+
vpec_id: artifact.vpec_id ?? "",
|
|
2202
|
+
valid: false,
|
|
2203
|
+
schema_version: artifact.schema_version ?? "",
|
|
2204
|
+
proof_level: artifact.proof_level ?? "",
|
|
2205
|
+
proof_distribution: proofDist ?? {},
|
|
2206
|
+
org_id: artifact.org_id ?? "",
|
|
2207
|
+
workflow_id: artifact.workflow_id ?? "",
|
|
2208
|
+
process_context_hash: artifact.process_context_hash ?? null,
|
|
2209
|
+
partial: artifact.partial ?? false,
|
|
2210
|
+
test_mode: artifact.test_mode ?? false,
|
|
2211
|
+
signer_id: issuer?.signer_id ?? sig?.signer_id ?? "",
|
|
2212
|
+
kid: issuer?.kid ?? sig?.kid ?? "",
|
|
2213
|
+
signed_at: sig?.signed_at ?? "",
|
|
2214
|
+
timestamp_anchor_valid: null,
|
|
2215
|
+
rekor_status: "skipped",
|
|
2216
|
+
zk_proof_valid: null,
|
|
2217
|
+
commitment_root_valid: null,
|
|
2218
|
+
manifest_hashes: {},
|
|
2219
|
+
gaps: gaps.map((g) => ({
|
|
2220
|
+
gap_id: g.gap_id ?? "",
|
|
2221
|
+
gap_type: g.gap_type ?? "",
|
|
2222
|
+
severity: g.severity ?? ""
|
|
2223
|
+
})),
|
|
2224
|
+
violations_present: false,
|
|
2225
|
+
violation_count: 0,
|
|
2226
|
+
coverage: coverage ?? {},
|
|
2227
|
+
errors: [],
|
|
2228
|
+
warnings: []
|
|
2229
|
+
};
|
|
2230
|
+
}
|
|
2231
|
+
function signatureBody(artifact) {
|
|
2232
|
+
const { signature: _sig, ...documentBody } = artifact;
|
|
2233
|
+
void _sig;
|
|
2234
|
+
return documentBody;
|
|
2235
|
+
}
|
|
2236
|
+
function timestampBody(artifact) {
|
|
2237
|
+
const { signature: _sig, timestamp_anchor: _ts, ...documentBody } = artifact;
|
|
2238
|
+
void _sig;
|
|
2239
|
+
void _ts;
|
|
2240
|
+
return documentBody;
|
|
2241
|
+
}
|
|
2242
|
+
async function verify3(artifact, options = {}, upstreamRootResolver) {
|
|
2243
|
+
const result = baseResult(artifact);
|
|
2244
|
+
const { production = false, skip_network = false, trust_root } = options;
|
|
2245
|
+
const schemaResult = validateArtifact(artifact);
|
|
2246
|
+
if (!schemaResult.valid) {
|
|
2247
|
+
for (const err2 of schemaResult.errors) {
|
|
2248
|
+
if (err2.code === "RELIANCE_MODE_FORBIDDEN") {
|
|
2249
|
+
result.errors.push("banned_field_reliance_mode");
|
|
2250
|
+
} else if (err2.code === "MANIFEST_HASHES_NOT_MAP") {
|
|
2251
|
+
result.errors.push("manifest_hashes_not_object");
|
|
2252
|
+
} else {
|
|
2253
|
+
result.errors.push(`schema_validation_failed: ${err2.code}`);
|
|
2254
|
+
}
|
|
2255
|
+
}
|
|
2256
|
+
return result;
|
|
2257
|
+
}
|
|
2258
|
+
const reliancePath = hasRelianceMode(artifact);
|
|
2259
|
+
if (reliancePath) {
|
|
2260
|
+
result.errors.push("banned_field_reliance_mode");
|
|
2261
|
+
return result;
|
|
2262
|
+
}
|
|
2263
|
+
const issuer = artifact.issuer;
|
|
2264
|
+
const sig = artifact.signature;
|
|
2265
|
+
if (!issuer || !sig) {
|
|
2266
|
+
result.errors.push("missing_issuer_or_signature");
|
|
2267
|
+
return result;
|
|
2268
|
+
}
|
|
2269
|
+
if (issuer.kid !== sig.kid) {
|
|
2270
|
+
result.errors.push("kid_mismatch");
|
|
2271
|
+
return result;
|
|
2272
|
+
}
|
|
2273
|
+
const documentBody = signatureBody(artifact);
|
|
2274
|
+
let publicKeyB64Url;
|
|
2275
|
+
try {
|
|
2276
|
+
const pem = await getKey(
|
|
2277
|
+
sig.kid,
|
|
2278
|
+
issuer.public_key_url,
|
|
2279
|
+
trust_root
|
|
2280
|
+
);
|
|
2281
|
+
publicKeyB64Url = extractKeyFromPem(pem);
|
|
2282
|
+
} catch (err2) {
|
|
2283
|
+
result.errors.push(err2.message);
|
|
2284
|
+
return result;
|
|
2285
|
+
}
|
|
2286
|
+
const signatureEnvelope = {
|
|
2287
|
+
signer_id: sig.signer_id,
|
|
2288
|
+
kid: sig.kid,
|
|
2289
|
+
algorithm: sig.algorithm,
|
|
2290
|
+
signature: sig.signature,
|
|
2291
|
+
signed_at: sig.signed_at
|
|
2292
|
+
};
|
|
2293
|
+
const sigValid = verify2(documentBody, signatureEnvelope, publicKeyB64Url);
|
|
2294
|
+
if (!sigValid) {
|
|
2295
|
+
result.errors.push("integrity_check_failed");
|
|
2296
|
+
return result;
|
|
2297
|
+
}
|
|
2298
|
+
if (skip_network) {
|
|
2299
|
+
result.rekor_status = "skipped";
|
|
2300
|
+
} else {
|
|
2301
|
+
result.rekor_status = await checkRekor(publicKeyB64Url, sig.kid);
|
|
2302
|
+
if (result.rekor_status === "unavailable") {
|
|
2303
|
+
result.warnings.push("rekor_check_unavailable");
|
|
2304
|
+
} else if (result.rekor_status === "revoked") {
|
|
2305
|
+
result.errors.push("signer_key_revoked");
|
|
2306
|
+
return result;
|
|
2307
|
+
}
|
|
2308
|
+
}
|
|
2309
|
+
const tsAnchor = artifact.timestamp_anchor;
|
|
2310
|
+
if (tsAnchor && tsAnchor.type === "rfc3161" && typeof tsAnchor.value === "string") {
|
|
2311
|
+
result.timestamp_anchor_valid = verifyTimestampImprint(
|
|
2312
|
+
tsAnchor.value,
|
|
2313
|
+
timestampBody(artifact)
|
|
2314
|
+
);
|
|
2315
|
+
if (result.timestamp_anchor_valid === false) {
|
|
2316
|
+
result.warnings.push("rfc3161_imprint_mismatch");
|
|
2317
|
+
} else if (result.timestamp_anchor_valid === true) {
|
|
2318
|
+
result.warnings.push("rfc3161_tsa_cert_chain_not_verified");
|
|
2319
|
+
}
|
|
2320
|
+
} else {
|
|
2321
|
+
result.timestamp_anchor_valid = null;
|
|
2322
|
+
}
|
|
2323
|
+
const proofDist = artifact.proof_distribution;
|
|
2324
|
+
if (artifact.proof_level !== proofDist.weakest_link) {
|
|
2325
|
+
result.errors.push("proof_level_mismatch");
|
|
2326
|
+
return result;
|
|
2327
|
+
}
|
|
2328
|
+
const manifestHashes = artifact.manifest_hashes;
|
|
2329
|
+
result.manifest_hashes = manifestHashes;
|
|
2330
|
+
if (artifact.commitment_root != null) {
|
|
2331
|
+
const commitmentRoot = artifact.commitment_root;
|
|
2332
|
+
const checkRecords = artifact.check_execution_records;
|
|
2333
|
+
const hashes = [];
|
|
2334
|
+
if (Array.isArray(checkRecords)) {
|
|
2335
|
+
for (const rec of checkRecords) {
|
|
2336
|
+
const h2 = rec.commitment_hash ?? rec.input_commitment_hash;
|
|
2337
|
+
if (h2) hashes.push(h2);
|
|
2338
|
+
}
|
|
2339
|
+
}
|
|
2340
|
+
if (hashes.length > 0) {
|
|
2341
|
+
const recomputed = computeMerkleRoot(hashes);
|
|
2342
|
+
if (recomputed === commitmentRoot) {
|
|
2343
|
+
result.commitment_root_valid = true;
|
|
2344
|
+
} else {
|
|
2345
|
+
result.commitment_root_valid = false;
|
|
2346
|
+
result.errors.push("commitment_root_mismatch");
|
|
2347
|
+
return result;
|
|
2348
|
+
}
|
|
2349
|
+
} else {
|
|
2350
|
+
result.commitment_root_valid = null;
|
|
2351
|
+
result.warnings.push("commitment_root_no_hashes_to_verify");
|
|
2352
|
+
}
|
|
2353
|
+
} else {
|
|
2354
|
+
result.commitment_root_valid = null;
|
|
2355
|
+
result.warnings.push("no_commitment_root");
|
|
2356
|
+
}
|
|
2357
|
+
const skipAnchorResult = verifySkipConditionProofAnchoring(artifact);
|
|
2358
|
+
if (skipAnchorResult === "mismatch") {
|
|
2359
|
+
result.errors.push("skip_condition_proof_root_mismatch");
|
|
2360
|
+
return result;
|
|
2361
|
+
}
|
|
2362
|
+
if (skipAnchorResult === "no_proof_artifact_for_multi_record_artifact") {
|
|
2363
|
+
result.errors.push(
|
|
2364
|
+
"skip_condition_proof_no_proof_artifact_for_multi_record_artifact"
|
|
2365
|
+
);
|
|
2366
|
+
return result;
|
|
2367
|
+
}
|
|
2368
|
+
if (skipAnchorResult === "unanchored") {
|
|
2369
|
+
result.warnings.push("skip_condition_proof_no_skipped_record_to_anchor");
|
|
2370
|
+
}
|
|
2371
|
+
const upstreamAnchorResult = verifyUpstreamVpecInclusionAnchoring(
|
|
2372
|
+
artifact,
|
|
2373
|
+
upstreamRootResolver
|
|
2374
|
+
);
|
|
2375
|
+
if (upstreamAnchorResult === "mismatch") {
|
|
2376
|
+
result.errors.push("upstream_vpec_proof_root_mismatch");
|
|
2377
|
+
return result;
|
|
2378
|
+
}
|
|
2379
|
+
if (upstreamAnchorResult === "no_proof_artifact_for_multi_record_artifact") {
|
|
2380
|
+
result.errors.push(
|
|
2381
|
+
"upstream_vpec_inclusion_no_proof_artifact_for_multi_record_artifact"
|
|
2382
|
+
);
|
|
2383
|
+
return result;
|
|
2384
|
+
}
|
|
2385
|
+
if (upstreamAnchorResult === "unanchored") {
|
|
2386
|
+
result.warnings.push("upstream_vpec_proof_no_anchor_root_in_artifact");
|
|
2387
|
+
}
|
|
2388
|
+
const pendingFlags = artifact.pending_flags;
|
|
2389
|
+
const proofPending = pendingFlags?.proof_pending === true;
|
|
2390
|
+
const proofArtifacts = Array.isArray(artifact.proof_artifacts) ? artifact.proof_artifacts : [];
|
|
2391
|
+
if (artifact.zk_proof && !proofPending) {
|
|
2392
|
+
const zkProof = artifact.zk_proof;
|
|
2393
|
+
const provingSystem = zkProof.prover_system ?? zkProof.proving_system;
|
|
2394
|
+
if (provingSystem === "ultrahonk") {
|
|
2395
|
+
result.zk_proof_valid = await verifyUltraHonk(zkProof);
|
|
2396
|
+
if (result.zk_proof_valid === false) {
|
|
2397
|
+
result.errors.push("zk_proof_invalid");
|
|
2398
|
+
}
|
|
2399
|
+
} else if (provingSystem === "ezkl") {
|
|
2400
|
+
result.zk_proof_valid = null;
|
|
2401
|
+
result.warnings.push("ezkl_verification_not_implemented");
|
|
2402
|
+
} else {
|
|
2403
|
+
result.zk_proof_valid = null;
|
|
2404
|
+
result.warnings.push(`unknown_proving_system: ${provingSystem ?? "none"}`);
|
|
2405
|
+
}
|
|
2406
|
+
} else if (proofPending) {
|
|
2407
|
+
result.zk_proof_valid = null;
|
|
2408
|
+
result.warnings.push("proof_pending");
|
|
2409
|
+
} else {
|
|
2410
|
+
result.zk_proof_valid = null;
|
|
2411
|
+
}
|
|
2412
|
+
if (result.zk_proof_valid === false) {
|
|
2413
|
+
result.errors.push("zk_proof_verification_failed");
|
|
2414
|
+
return result;
|
|
2415
|
+
}
|
|
2416
|
+
if (artifact.zk_proof && result.zk_proof_valid === null) {
|
|
2417
|
+
result.warnings.push("zk_proof_verifier_unavailable");
|
|
2418
|
+
}
|
|
2419
|
+
if (proofArtifacts.length > 0) {
|
|
2420
|
+
const pendingArtifacts = proofArtifacts.filter(
|
|
2421
|
+
(artifactEntry) => artifactEntry.verification_status === "pending"
|
|
2422
|
+
).length;
|
|
2423
|
+
const failedArtifacts = proofArtifacts.filter(
|
|
2424
|
+
(artifactEntry) => artifactEntry.verification_status === "failed"
|
|
2425
|
+
).length;
|
|
2426
|
+
const verifiedArtifacts = proofArtifacts.filter(
|
|
2427
|
+
(artifactEntry) => artifactEntry.verification_status === "verified"
|
|
2428
|
+
).length;
|
|
2429
|
+
if (pendingArtifacts > 0) {
|
|
2430
|
+
result.warnings.push(`proof_artifacts_pending:${pendingArtifacts}`);
|
|
2431
|
+
}
|
|
2432
|
+
if (failedArtifacts > 0) {
|
|
2433
|
+
result.warnings.push(`proof_artifacts_failed:${failedArtifacts}`);
|
|
2434
|
+
}
|
|
2435
|
+
if (!artifact.zk_proof) {
|
|
2436
|
+
result.warnings.push(`proof_artifacts_present:${verifiedArtifacts}`);
|
|
2437
|
+
}
|
|
2438
|
+
}
|
|
2439
|
+
if (artifact.test_mode === true) {
|
|
2440
|
+
if (production) {
|
|
2441
|
+
result.errors.push("test_mode_rejected_in_production");
|
|
2442
|
+
return result;
|
|
2443
|
+
}
|
|
2444
|
+
result.warnings.push("test_credential");
|
|
2445
|
+
}
|
|
2446
|
+
const violations = artifact.violations;
|
|
2447
|
+
if (Array.isArray(violations) && violations.length > 0) {
|
|
2448
|
+
result.violations_present = true;
|
|
2449
|
+
result.violation_count = violations.length;
|
|
2450
|
+
} else {
|
|
2451
|
+
result.violations_present = false;
|
|
2452
|
+
result.violation_count = 0;
|
|
2453
|
+
}
|
|
2454
|
+
const gdSummary = artifact.governance_decision_summary;
|
|
2455
|
+
if (gdSummary && typeof gdSummary === "object") {
|
|
2456
|
+
if (!("deferred" in gdSummary)) {
|
|
2457
|
+
result.warnings.push("governance_decision_summary_missing_deferred");
|
|
2458
|
+
}
|
|
2459
|
+
}
|
|
2460
|
+
if (artifact.envelope_version != null && (artifact.run_header || artifact.records)) {
|
|
2461
|
+
try {
|
|
2462
|
+
const { verifyV29 } = await import("./v29-envelope-GFVVA2S6.js");
|
|
2463
|
+
const shapeEnvelope = {
|
|
2464
|
+
envelope_version: artifact.envelope_version,
|
|
2465
|
+
run_header: artifact.run_header ?? {},
|
|
2466
|
+
// Mirror the Py CLI's read-side fallback (envelope_records shim
|
|
2467
|
+
// for envelopes signed before the legacy records → envelope.records
|
|
2468
|
+
// rename landed).
|
|
2469
|
+
records: artifact.records ?? artifact.envelope_records ?? [],
|
|
2470
|
+
aggregations: artifact.aggregations ?? {}
|
|
2471
|
+
};
|
|
2472
|
+
const rh = shapeEnvelope.run_header ?? {};
|
|
2473
|
+
const rb = rh.runtime_binding;
|
|
2474
|
+
const v29Result = verifyV29({
|
|
2475
|
+
envelope: shapeEnvelope,
|
|
2476
|
+
runtimeBinding: rb
|
|
2477
|
+
// Pubkey resolver wiring is deferred — when the trust-root path
|
|
2478
|
+
// is wired the CLI will pass one, and require_signatures: true
|
|
2479
|
+
// will then enforce the strict-mode preconditions.
|
|
2480
|
+
});
|
|
2481
|
+
if (!v29Result.ok) {
|
|
2482
|
+
result.errors.push(`v29_conformance_failed:${v29Result.reasonCode}`);
|
|
2483
|
+
}
|
|
2484
|
+
} catch (e) {
|
|
2485
|
+
result.warnings.push(`v29_conformance_error:${e.message}`);
|
|
2486
|
+
}
|
|
2487
|
+
}
|
|
2488
|
+
result.valid = result.errors.length === 0;
|
|
2489
|
+
return result;
|
|
2490
|
+
}
|
|
2491
|
+
function computeMerkleRoot(hashes) {
|
|
2492
|
+
let leaves = hashes.map((h2) => {
|
|
2493
|
+
const hex = h2.startsWith("sha256:") ? h2.slice(7) : h2;
|
|
2494
|
+
return Buffer.from(hex, "hex");
|
|
2495
|
+
});
|
|
2496
|
+
while (leaves.length > 1) {
|
|
2497
|
+
if (leaves.length % 2 !== 0) {
|
|
2498
|
+
leaves.push(leaves[leaves.length - 1]);
|
|
2499
|
+
}
|
|
2500
|
+
const next = [];
|
|
2501
|
+
for (let i = 0; i < leaves.length; i += 2) {
|
|
2502
|
+
const combined = Buffer.concat([leaves[i], leaves[i + 1]]);
|
|
2503
|
+
next.push(createHash("sha256").update(combined).digest());
|
|
2504
|
+
}
|
|
2505
|
+
leaves = next;
|
|
2506
|
+
}
|
|
2507
|
+
return "sha256:" + leaves[0].toString("hex");
|
|
2508
|
+
}
|
|
2509
|
+
function parsePoseidon2HashToField(hash) {
|
|
2510
|
+
if (typeof hash !== "string") return null;
|
|
2511
|
+
const colonIdx = hash.indexOf(":");
|
|
2512
|
+
if (colonIdx === -1) return null;
|
|
2513
|
+
const algorithm = hash.slice(0, colonIdx);
|
|
2514
|
+
if (algorithm !== "poseidon2") return null;
|
|
2515
|
+
const hex = hash.slice(colonIdx + 1);
|
|
2516
|
+
if (!/^[0-9a-f]+$/i.test(hex)) return null;
|
|
2517
|
+
try {
|
|
2518
|
+
return BigInt("0x" + hex) % BN254_MODULUS;
|
|
2519
|
+
} catch {
|
|
2520
|
+
return null;
|
|
2521
|
+
}
|
|
2522
|
+
}
|
|
2523
|
+
function extractSkipConditionPublicInputs(zkProof) {
|
|
2524
|
+
const inputs = zkProof.public_inputs;
|
|
2525
|
+
if (!Array.isArray(inputs) || inputs.length < 2) return null;
|
|
2526
|
+
const skipConditionHash = inputs[0];
|
|
2527
|
+
const commitmentRoot = inputs[1];
|
|
2528
|
+
if (typeof skipConditionHash !== "string" || typeof commitmentRoot !== "string") {
|
|
2529
|
+
return null;
|
|
2530
|
+
}
|
|
2531
|
+
return { skipConditionHash, commitmentRoot };
|
|
2532
|
+
}
|
|
2533
|
+
function recomputeSkipConditionModifiedRoot(skipConditionField, leaves, skippedIndex) {
|
|
2534
|
+
if (leaves.length === 0) return null;
|
|
2535
|
+
if (skippedIndex < 0 || skippedIndex >= leaves.length) return null;
|
|
2536
|
+
const overrideLeaf = hashToField([
|
|
2537
|
+
skipConditionField,
|
|
2538
|
+
leaves[skippedIndex]
|
|
2539
|
+
]);
|
|
2540
|
+
if (leaves.length === 1) return overrideLeaf;
|
|
2541
|
+
let layer = leaves.map(
|
|
2542
|
+
(leaf, i) => i === skippedIndex ? overrideLeaf : leaf
|
|
2543
|
+
);
|
|
2544
|
+
while (layer.length > 1) {
|
|
2545
|
+
const next = [];
|
|
2546
|
+
for (let i = 0; i < layer.length; i += 2) {
|
|
2547
|
+
const left = layer[i];
|
|
2548
|
+
const right = i + 1 < layer.length ? layer[i + 1] : layer[i];
|
|
2549
|
+
next.push(hashToField([left, right]));
|
|
2550
|
+
}
|
|
2551
|
+
layer = next;
|
|
2552
|
+
}
|
|
2553
|
+
return layer[0];
|
|
2554
|
+
}
|
|
2555
|
+
function verifySkipConditionProofAnchoring(artifact) {
|
|
2556
|
+
const checkRecords = artifact.check_execution_records;
|
|
2557
|
+
const recordCount = Array.isArray(checkRecords) ? checkRecords.length : 0;
|
|
2558
|
+
const proofs = collectMatchingProofs(artifact, ["skip_condition_proof"]);
|
|
2559
|
+
if (recordCount > 1 && proofs.fromArray.length === 0) {
|
|
2560
|
+
if (proofs.legacy !== null) {
|
|
2561
|
+
return "no_proof_artifact_for_multi_record_artifact";
|
|
2562
|
+
}
|
|
2563
|
+
}
|
|
2564
|
+
const candidates = [...proofs.fromArray];
|
|
2565
|
+
if (proofs.legacy && (recordCount <= 1 || proofs.fromArray.length > 0)) {
|
|
2566
|
+
candidates.push(proofs.legacy);
|
|
2567
|
+
}
|
|
2568
|
+
if (candidates.length === 0) return "not_applicable";
|
|
2569
|
+
if (recordCount === 0) return "unanchored";
|
|
2570
|
+
const allLeafFields = (checkRecords ?? []).map((rec) => {
|
|
2571
|
+
const h2 = rec.commitment_hash;
|
|
2572
|
+
return typeof h2 === "string" ? parsePoseidon2HashToField(h2) : null;
|
|
2573
|
+
});
|
|
2574
|
+
const fullyParsed = allLeafFields.every((f) => f !== null);
|
|
2575
|
+
let sawSkippedRecord = false;
|
|
2576
|
+
for (const proof of candidates) {
|
|
2577
|
+
const inputs = extractSkipConditionPublicInputs(proof);
|
|
2578
|
+
if (!inputs) return "not_applicable";
|
|
2579
|
+
const skipConditionField = parsePoseidon2HashToField(inputs.skipConditionHash);
|
|
2580
|
+
if (skipConditionField === null) return "not_applicable";
|
|
2581
|
+
const proofRootField = parsePoseidon2HashToField(inputs.commitmentRoot);
|
|
2582
|
+
if (proofRootField === null) return "not_applicable";
|
|
2583
|
+
let matched = false;
|
|
2584
|
+
for (let i = 0; i < (checkRecords ?? []).length; i++) {
|
|
2585
|
+
const rec = (checkRecords ?? [])[i];
|
|
2586
|
+
if (rec.check_result !== "skipped") continue;
|
|
2587
|
+
sawSkippedRecord = true;
|
|
2588
|
+
const skippedLeafField = allLeafFields[i];
|
|
2589
|
+
if (skippedLeafField === null) continue;
|
|
2590
|
+
if (fullyParsed && (checkRecords ?? []).length > 1) {
|
|
2591
|
+
const modifiedRoot = recomputeSkipConditionModifiedRoot(
|
|
2592
|
+
skipConditionField,
|
|
2593
|
+
allLeafFields,
|
|
2594
|
+
i
|
|
2595
|
+
);
|
|
2596
|
+
if (modifiedRoot !== null && modifiedRoot === proofRootField) {
|
|
2597
|
+
matched = true;
|
|
2598
|
+
break;
|
|
2599
|
+
}
|
|
2600
|
+
}
|
|
2601
|
+
const overrideLeaf = hashToField([
|
|
2602
|
+
skipConditionField,
|
|
2603
|
+
skippedLeafField
|
|
2604
|
+
]);
|
|
2605
|
+
if (overrideLeaf === proofRootField) {
|
|
2606
|
+
matched = true;
|
|
2607
|
+
break;
|
|
2608
|
+
}
|
|
2609
|
+
}
|
|
2610
|
+
if (!matched) {
|
|
2611
|
+
if (!sawSkippedRecord) return "unanchored";
|
|
2612
|
+
return "mismatch";
|
|
2613
|
+
}
|
|
2614
|
+
}
|
|
2615
|
+
if (!sawSkippedRecord) return "unanchored";
|
|
2616
|
+
return "ok";
|
|
2617
|
+
}
|
|
2618
|
+
function parseStringToFieldLocal(s) {
|
|
2619
|
+
const bytes = new TextEncoder().encode(s);
|
|
2620
|
+
const digest = sha2562(bytes);
|
|
2621
|
+
let n = 0n;
|
|
2622
|
+
for (let i = 0; i < 32; i++) {
|
|
2623
|
+
n = n << 8n | BigInt(digest[i]);
|
|
2624
|
+
}
|
|
2625
|
+
return n % BN254_MODULUS;
|
|
2626
|
+
}
|
|
2627
|
+
function computeLineageCommitmentLocal(runId, upstreamVpecIds) {
|
|
2628
|
+
const inputs = [
|
|
2629
|
+
parseStringToFieldLocal(runId),
|
|
2630
|
+
...upstreamVpecIds.map(parseStringToFieldLocal)
|
|
2631
|
+
];
|
|
2632
|
+
return hashToField(inputs);
|
|
2633
|
+
}
|
|
2634
|
+
function readCircuitName(entry) {
|
|
2635
|
+
const cn = entry.circuit_name;
|
|
2636
|
+
if (typeof cn === "string" && cn.length > 0) return cn;
|
|
2637
|
+
const c = entry.circuit;
|
|
2638
|
+
if (typeof c === "string" && c.length > 0) return c;
|
|
2639
|
+
return null;
|
|
2640
|
+
}
|
|
2641
|
+
function collectMatchingProofs(artifact, circuitNames) {
|
|
2642
|
+
const wanted = new Set(circuitNames);
|
|
2643
|
+
const fromArray = [];
|
|
2644
|
+
const proofArtifacts = Array.isArray(artifact.proof_artifacts) ? artifact.proof_artifacts : [];
|
|
2645
|
+
for (const entry of proofArtifacts) {
|
|
2646
|
+
if (!entry || typeof entry !== "object") continue;
|
|
2647
|
+
const status = entry.verification_status;
|
|
2648
|
+
if (typeof status === "string" && status !== "verified") continue;
|
|
2649
|
+
const name = readCircuitName(entry);
|
|
2650
|
+
if (name && wanted.has(name)) {
|
|
2651
|
+
fromArray.push(entry);
|
|
2652
|
+
}
|
|
2653
|
+
}
|
|
2654
|
+
let legacy = null;
|
|
2655
|
+
const zkProof = artifact.zk_proof;
|
|
2656
|
+
if (zkProof && typeof zkProof === "object") {
|
|
2657
|
+
const name = readCircuitName(zkProof);
|
|
2658
|
+
if (name && wanted.has(name)) legacy = zkProof;
|
|
2659
|
+
}
|
|
2660
|
+
return { fromArray, legacy };
|
|
2661
|
+
}
|
|
2662
|
+
function matchCandidatesAgainstExpectedRoot(candidates, expectedRootField) {
|
|
2663
|
+
for (const proof of candidates) {
|
|
2664
|
+
const inputs = proof.public_inputs;
|
|
2665
|
+
let proofMerkleRoot = null;
|
|
2666
|
+
if (Array.isArray(inputs) && inputs.length > 0) {
|
|
2667
|
+
const root = inputs[0];
|
|
2668
|
+
if (typeof root === "string") proofMerkleRoot = root;
|
|
2669
|
+
}
|
|
2670
|
+
if (typeof proof.merkle_root === "string") {
|
|
2671
|
+
proofMerkleRoot = proof.merkle_root;
|
|
2672
|
+
}
|
|
2673
|
+
if (proofMerkleRoot === null) return "mismatch";
|
|
2674
|
+
const proofRootField = parsePoseidon2HashToField(proofMerkleRoot);
|
|
2675
|
+
if (proofRootField === null) return "mismatch";
|
|
2676
|
+
if (proofRootField !== expectedRootField) {
|
|
2677
|
+
return "mismatch";
|
|
2678
|
+
}
|
|
2679
|
+
}
|
|
2680
|
+
return "ok";
|
|
2681
|
+
}
|
|
2682
|
+
function verifyUpstreamVpecInclusionAnchoring(artifact, upstreamRootResolver) {
|
|
2683
|
+
const checkRecords = artifact.check_execution_records;
|
|
2684
|
+
const recordCount = Array.isArray(checkRecords) ? checkRecords.length : 0;
|
|
2685
|
+
const proofs = collectMatchingProofs(artifact, [
|
|
2686
|
+
"governance_upstream_vpec_inclusion",
|
|
2687
|
+
"merkle_inclusion"
|
|
2688
|
+
]);
|
|
2689
|
+
if (recordCount > 1 && proofs.fromArray.length === 0) {
|
|
2690
|
+
if (proofs.legacy !== null) {
|
|
2691
|
+
return "no_proof_artifact_for_multi_record_artifact";
|
|
2692
|
+
}
|
|
2693
|
+
}
|
|
2694
|
+
const candidates = [...proofs.fromArray];
|
|
2695
|
+
if (proofs.legacy && (recordCount <= 1 || proofs.fromArray.length > 0)) {
|
|
2696
|
+
candidates.push(proofs.legacy);
|
|
2697
|
+
}
|
|
2698
|
+
if (candidates.length === 0) return "not_applicable";
|
|
2699
|
+
const VERIFIER_MAX_CHAIN_DEPTH = 8;
|
|
2700
|
+
const upstreamVpecIdsRaw = artifact.upstream_vpec_ids;
|
|
2701
|
+
const upstreamVpecIds = Array.isArray(upstreamVpecIdsRaw) ? upstreamVpecIdsRaw.filter((x) => typeof x === "string") : [];
|
|
2702
|
+
const chainRootsRaw = artifact.upstream_vpec_chain_roots;
|
|
2703
|
+
const hasArtifactChainRoots = Array.isArray(chainRootsRaw) && chainRootsRaw.length > 0;
|
|
2704
|
+
if (upstreamVpecIds.length > 0 && hasArtifactChainRoots) {
|
|
2705
|
+
if (chainRootsRaw.length !== upstreamVpecIds.length) {
|
|
2706
|
+
return "mismatch";
|
|
2707
|
+
}
|
|
2708
|
+
if (chainRootsRaw.length > VERIFIER_MAX_CHAIN_DEPTH) {
|
|
2709
|
+
return "unanchored";
|
|
2710
|
+
}
|
|
2711
|
+
const chainFields = [];
|
|
2712
|
+
for (const raw of chainRootsRaw) {
|
|
2713
|
+
if (typeof raw !== "string" || raw.length === 0) return "unanchored";
|
|
2714
|
+
const field = parsePoseidon2HashToField(raw);
|
|
2715
|
+
if (field === null) return "unanchored";
|
|
2716
|
+
chainFields.push(field);
|
|
2717
|
+
}
|
|
2718
|
+
const runId = typeof artifact.run_id === "string" ? artifact.run_id : "";
|
|
2719
|
+
const lineage = computeLineageCommitmentLocal(runId, upstreamVpecIds);
|
|
2720
|
+
let node = lineage;
|
|
2721
|
+
for (const ancestorField of chainFields) {
|
|
2722
|
+
node = hashToField([node, ancestorField]);
|
|
2723
|
+
}
|
|
2724
|
+
return matchCandidatesAgainstExpectedRoot(candidates, node);
|
|
2725
|
+
}
|
|
2726
|
+
if (upstreamRootResolver && upstreamVpecIds.length > 0) {
|
|
2727
|
+
if (upstreamVpecIds.length > VERIFIER_MAX_CHAIN_DEPTH) {
|
|
2728
|
+
return "unanchored";
|
|
2729
|
+
}
|
|
2730
|
+
const runId = typeof artifact.run_id === "string" ? artifact.run_id : "";
|
|
2731
|
+
const lineage = computeLineageCommitmentLocal(runId, upstreamVpecIds);
|
|
2732
|
+
let expectedRootField;
|
|
2733
|
+
if (upstreamVpecIds.length === 1) {
|
|
2734
|
+
const directParentId = upstreamVpecIds[0];
|
|
2735
|
+
const parentRoot = upstreamRootResolver(directParentId);
|
|
2736
|
+
if (typeof parentRoot !== "string" || parentRoot.length === 0) {
|
|
2737
|
+
return "unanchored";
|
|
2738
|
+
}
|
|
2739
|
+
const parentRootField = parsePoseidon2HashToField(parentRoot);
|
|
2740
|
+
if (parentRootField === null) return "unanchored";
|
|
2741
|
+
expectedRootField = hashToField([lineage, parentRootField]);
|
|
2742
|
+
} else {
|
|
2743
|
+
let node = lineage;
|
|
2744
|
+
for (const ancestorId of upstreamVpecIds) {
|
|
2745
|
+
const root = upstreamRootResolver(ancestorId);
|
|
2746
|
+
if (typeof root !== "string" || root.length === 0) {
|
|
2747
|
+
return "unanchored";
|
|
2748
|
+
}
|
|
2749
|
+
const rootField = parsePoseidon2HashToField(root);
|
|
2750
|
+
if (rootField === null) return "unanchored";
|
|
2751
|
+
node = hashToField([node, rootField]);
|
|
2752
|
+
}
|
|
2753
|
+
expectedRootField = node;
|
|
2754
|
+
}
|
|
2755
|
+
return matchCandidatesAgainstExpectedRoot(candidates, expectedRootField);
|
|
2756
|
+
}
|
|
2757
|
+
const hasArtifactRoot = typeof artifact.commitment_root_poseidon2 === "string" && artifact.commitment_root_poseidon2.length > 0;
|
|
2758
|
+
const hasPerEntryRoot = candidates.some(
|
|
2759
|
+
(p) => typeof p.merkle_root === "string"
|
|
2760
|
+
);
|
|
2761
|
+
if (!hasArtifactRoot && !hasPerEntryRoot) return "unanchored";
|
|
2762
|
+
const artifactRootField = parsePoseidon2HashToField(
|
|
2763
|
+
typeof artifact.commitment_root_poseidon2 === "string" ? artifact.commitment_root_poseidon2 : ""
|
|
2764
|
+
);
|
|
2765
|
+
for (const proof of candidates) {
|
|
2766
|
+
const inputs = proof.public_inputs;
|
|
2767
|
+
let proofMerkleRoot = null;
|
|
2768
|
+
if (Array.isArray(inputs) && inputs.length > 0) {
|
|
2769
|
+
const root = inputs[0];
|
|
2770
|
+
if (typeof root === "string") proofMerkleRoot = root;
|
|
2771
|
+
}
|
|
2772
|
+
if (typeof proof.merkle_root === "string") {
|
|
2773
|
+
proofMerkleRoot = proof.merkle_root;
|
|
2774
|
+
}
|
|
2775
|
+
if (proofMerkleRoot === null) return "mismatch";
|
|
2776
|
+
const proofRootField = parsePoseidon2HashToField(proofMerkleRoot);
|
|
2777
|
+
let matched = false;
|
|
2778
|
+
if (artifactRootField !== null && proofRootField !== null && proofRootField === artifactRootField) {
|
|
2779
|
+
matched = true;
|
|
2780
|
+
}
|
|
2781
|
+
if (!matched && typeof proof.merkle_root === "string") {
|
|
2782
|
+
if (proof.merkle_root === proofMerkleRoot) {
|
|
2783
|
+
matched = true;
|
|
2784
|
+
}
|
|
2785
|
+
}
|
|
2786
|
+
if (!matched) return "mismatch";
|
|
2787
|
+
}
|
|
2788
|
+
return "ok";
|
|
2789
|
+
}
|
|
2790
|
+
function extractKeyFromPem(pem) {
|
|
2791
|
+
const cleaned = pem.trim();
|
|
2792
|
+
if (cleaned.includes("-----BEGIN")) {
|
|
2793
|
+
try {
|
|
2794
|
+
const jwk = createPublicKey(cleaned).export({ format: "jwk" });
|
|
2795
|
+
if (jwk.kty === "OKP" && jwk.crv === "Ed25519" && typeof jwk.x === "string") {
|
|
2796
|
+
return jwk.x;
|
|
2797
|
+
}
|
|
2798
|
+
} catch {
|
|
2799
|
+
}
|
|
2800
|
+
const b64 = cleaned.replace(/-----BEGIN [A-Z ]+-----/g, "").replace(/-----END [A-Z ]+-----/g, "").replace(/\s/g, "");
|
|
2801
|
+
return b64.replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
|
2802
|
+
}
|
|
2803
|
+
return cleaned.replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
|
2804
|
+
}
|
|
2805
|
+
function verifyTimestampImprint(tsTokenB64, documentBody) {
|
|
2806
|
+
try {
|
|
2807
|
+
const tsResp = Buffer.from(tsTokenB64, "base64");
|
|
2808
|
+
const sha256Oid = Buffer.from([96, 134, 72, 1, 101, 3, 4, 2, 1]);
|
|
2809
|
+
const oidIdx = findBuffer(tsResp, sha256Oid);
|
|
2810
|
+
if (oidIdx === -1) return null;
|
|
2811
|
+
const searchStart = oidIdx + sha256Oid.length;
|
|
2812
|
+
for (let i = searchStart; i < Math.min(searchStart + 20, tsResp.length - 33); i++) {
|
|
2813
|
+
if (tsResp[i] === 4 && tsResp[i + 1] === 32) {
|
|
2814
|
+
const extractedHash = tsResp.subarray(i + 2, i + 2 + 32);
|
|
2815
|
+
const canonicalDoc = canonical(documentBody);
|
|
2816
|
+
const expectedHash = createHash("sha256").update(canonicalDoc).digest();
|
|
2817
|
+
return extractedHash.equals(expectedHash);
|
|
2818
|
+
}
|
|
2819
|
+
}
|
|
2820
|
+
return null;
|
|
2821
|
+
} catch {
|
|
2822
|
+
return null;
|
|
2823
|
+
}
|
|
2824
|
+
}
|
|
2825
|
+
function findBuffer(haystack, needle) {
|
|
2826
|
+
for (let i = 0; i <= haystack.length - needle.length; i++) {
|
|
2827
|
+
if (haystack.subarray(i, i + needle.length).equals(needle)) return i;
|
|
2828
|
+
}
|
|
2829
|
+
return -1;
|
|
2830
|
+
}
|
|
2831
|
+
var REKOR_API = "https://rekor.sigstore.dev/api/v1";
|
|
2832
|
+
async function checkRekor(publicKeyB64Url, kid) {
|
|
2833
|
+
try {
|
|
2834
|
+
const keyBytes = fromBase64Url(publicKeyB64Url);
|
|
2835
|
+
const fingerprint = createHash("sha256").update(Buffer.from(keyBytes)).digest("hex");
|
|
2836
|
+
const resp = await fetch(`${REKOR_API}/index/retrieve`, {
|
|
2837
|
+
method: "POST",
|
|
2838
|
+
headers: { "Content-Type": "application/json" },
|
|
2839
|
+
body: JSON.stringify({ hash: `sha256:${fingerprint}` }),
|
|
2840
|
+
signal: AbortSignal.timeout(5e3)
|
|
2841
|
+
});
|
|
2842
|
+
if (!resp.ok) {
|
|
2843
|
+
return "unavailable";
|
|
2844
|
+
}
|
|
2845
|
+
const entries = await resp.json();
|
|
2846
|
+
if (!entries || entries.length === 0) {
|
|
2847
|
+
return "not_found";
|
|
2848
|
+
}
|
|
2849
|
+
return "active";
|
|
2850
|
+
} catch {
|
|
2851
|
+
return "unavailable";
|
|
2852
|
+
}
|
|
2853
|
+
}
|
|
2854
|
+
async function verifyUltraHonk(zkProof) {
|
|
2855
|
+
try {
|
|
2856
|
+
const bb = await import("@aztec/bb.js").catch(() => null);
|
|
2857
|
+
if (!bb) {
|
|
2858
|
+
return null;
|
|
2859
|
+
}
|
|
2860
|
+
const proofB64 = zkProof.proof;
|
|
2861
|
+
const publicInputs = zkProof.public_inputs;
|
|
2862
|
+
const vkB64 = zkProof.verification_key;
|
|
2863
|
+
if (!proofB64 || !publicInputs || !vkB64) {
|
|
2864
|
+
return false;
|
|
2865
|
+
}
|
|
2866
|
+
const proofBytes = Buffer.from(proofB64, "base64");
|
|
2867
|
+
const vkBytes = Buffer.from(vkB64, "base64");
|
|
2868
|
+
const api = await bb.newBarretenbergApiAsync();
|
|
2869
|
+
const valid = await api.acirVerifyUltraHonk(proofBytes, vkBytes);
|
|
2870
|
+
return valid;
|
|
2871
|
+
} catch {
|
|
2872
|
+
return null;
|
|
2873
|
+
}
|
|
2874
|
+
}
|
|
2875
|
+
|
|
2876
|
+
// src/upstream_resolver.ts
|
|
2877
|
+
import { createRequire } from "module";
|
|
2878
|
+
var _sqliteMissingWarned = false;
|
|
2879
|
+
function warnSqliteMissingOnce(err2) {
|
|
2880
|
+
if (_sqliteMissingWarned) return;
|
|
2881
|
+
_sqliteMissingWarned = true;
|
|
2882
|
+
console.warn(
|
|
2883
|
+
"@primust/verifier: better-sqlite3 not installed in this environment; upstream root resolver via SqliteStore is disabled and resolution falls back to the envelopes Map (or null when none provided). Install with: npm install better-sqlite3",
|
|
2884
|
+
err2 instanceof Error ? err2.message : err2
|
|
2885
|
+
);
|
|
2886
|
+
}
|
|
2887
|
+
function openDbHandle(dbPath) {
|
|
2888
|
+
let Database;
|
|
2889
|
+
try {
|
|
2890
|
+
const require_ = createRequire(import.meta.url);
|
|
2891
|
+
Database = require_("better-sqlite3");
|
|
2892
|
+
} catch (err2) {
|
|
2893
|
+
warnSqliteMissingOnce(err2);
|
|
2894
|
+
return null;
|
|
2895
|
+
}
|
|
2896
|
+
try {
|
|
2897
|
+
const db = new Database(dbPath, { readonly: true, fileMustExist: true });
|
|
2898
|
+
return {
|
|
2899
|
+
vpecStmt: db.prepare(
|
|
2900
|
+
`SELECT root FROM vpec_commitment_roots WHERE key = ? AND kind = 'vpec'`
|
|
2901
|
+
),
|
|
2902
|
+
runStmt: db.prepare(
|
|
2903
|
+
`SELECT root FROM vpec_commitment_roots WHERE key = ? AND kind = 'run'`
|
|
2904
|
+
),
|
|
2905
|
+
close: () => db.close()
|
|
2906
|
+
};
|
|
2907
|
+
} catch (err2) {
|
|
2908
|
+
console.warn(
|
|
2909
|
+
"[primust-verify] upstream resolver: cannot open SQLite store at",
|
|
2910
|
+
dbPath,
|
|
2911
|
+
err2
|
|
2912
|
+
);
|
|
2913
|
+
return null;
|
|
2914
|
+
}
|
|
2915
|
+
}
|
|
2916
|
+
function createUpstreamRootResolver(opts) {
|
|
2917
|
+
const envelopes = opts.envelopes ?? null;
|
|
2918
|
+
let dbHandle;
|
|
2919
|
+
return function resolveUpstreamRoot(vpecId) {
|
|
2920
|
+
if (!vpecId) return null;
|
|
2921
|
+
if (envelopes) {
|
|
2922
|
+
const fromMap = envelopes.get(vpecId);
|
|
2923
|
+
if (fromMap) return fromMap;
|
|
2924
|
+
}
|
|
2925
|
+
if (opts.dbPath) {
|
|
2926
|
+
if (dbHandle === void 0) {
|
|
2927
|
+
dbHandle = openDbHandle(opts.dbPath);
|
|
2928
|
+
}
|
|
2929
|
+
if (dbHandle) {
|
|
2930
|
+
try {
|
|
2931
|
+
const vpecRow = dbHandle.vpecStmt.get(vpecId);
|
|
2932
|
+
if (vpecRow?.root) return vpecRow.root;
|
|
2933
|
+
const runRow = dbHandle.runStmt.get(vpecId);
|
|
2934
|
+
if (runRow?.root) return runRow.root;
|
|
2935
|
+
} catch (err2) {
|
|
2936
|
+
console.warn(
|
|
2937
|
+
`[primust-verify] upstream resolver: query failed for ${vpecId}:`,
|
|
2938
|
+
err2
|
|
2939
|
+
);
|
|
2940
|
+
}
|
|
2941
|
+
}
|
|
2942
|
+
}
|
|
2943
|
+
return null;
|
|
2944
|
+
};
|
|
2945
|
+
}
|
|
2946
|
+
function closeResolver(resolver) {
|
|
2947
|
+
void resolver;
|
|
2948
|
+
}
|
|
2949
|
+
|
|
2950
|
+
export {
|
|
2951
|
+
seedKeyCache,
|
|
2952
|
+
verify3 as verify,
|
|
2953
|
+
createUpstreamRootResolver,
|
|
2954
|
+
closeResolver
|
|
2955
|
+
};
|
|
2956
|
+
/*! Bundled license information:
|
|
2957
|
+
|
|
2958
|
+
@noble/ed25519/index.js:
|
|
2959
|
+
(*! noble-ed25519 - MIT License (c) 2019 Paul Miller (paulmillr.com) *)
|
|
2960
|
+
|
|
2961
|
+
@noble/hashes/esm/utils.js:
|
|
2962
|
+
(*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
2963
|
+
*/
|