@zkproofport-app/sdk 0.2.14 → 0.2.15
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/index.esm.js +34 -0
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +34 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +34 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -1
package/dist/index.esm.js
CHANGED
|
@@ -4477,6 +4477,38 @@ const CIRCUITS_VK_BASE = 'https://raw.githubusercontent.com/zkproofport/circuits
|
|
|
4477
4477
|
/** How long a fetched verification key is reused. Keys change only on a recompile. */
|
|
4478
4478
|
const VK_CACHE_TTL_MS = 60 * 60 * 1000;
|
|
4479
4479
|
const vkCache = new Map();
|
|
4480
|
+
/**
|
|
4481
|
+
* Make sure a Node-shaped `Buffer` exists before Barretenberg is loaded.
|
|
4482
|
+
*
|
|
4483
|
+
* WHY THE SDK DOES THIS RATHER THAN THE CALLER. bb.js's own BROWSER build —
|
|
4484
|
+
* not just its node build — converts field elements through `Buffer.alloc` and
|
|
4485
|
+
* `buf.writeBigUInt64BE`. Browsers have no Buffer, and bundlers stopped
|
|
4486
|
+
* polyfilling Node globals years ago, so in a browser the first verification
|
|
4487
|
+
* dies with "r.writeBigUInt64BE is not a function" — a message that names
|
|
4488
|
+
* nothing a caller could act on. Measured on the demo page, 2026-09-04, against
|
|
4489
|
+
* a real GIWA proof.
|
|
4490
|
+
*
|
|
4491
|
+
* Leaving it to callers would mean every browser customer editing their
|
|
4492
|
+
* bundler config to make an SDK method work, which is the configuration this
|
|
4493
|
+
* SDK promises not to require.
|
|
4494
|
+
*
|
|
4495
|
+
* Deliberately narrow:
|
|
4496
|
+
* - It only fills a GAP. A real Buffer (Node, or a page that already has one)
|
|
4497
|
+
* is left alone, so nothing is shadowed by a lesser implementation.
|
|
4498
|
+
* - It checks for the METHOD, not just the global. A partial Buffer — which is
|
|
4499
|
+
* what several bundlers leave behind, and what the demo page actually had —
|
|
4500
|
+
* passes a `typeof Buffer` test and then fails inside Barretenberg.
|
|
4501
|
+
*/
|
|
4502
|
+
async function ensureBufferForBarretenberg() {
|
|
4503
|
+
const existing = globalThis.Buffer;
|
|
4504
|
+
if (existing?.alloc) {
|
|
4505
|
+
const probe = existing.alloc(8);
|
|
4506
|
+
if (typeof probe.writeBigUInt64BE === 'function')
|
|
4507
|
+
return;
|
|
4508
|
+
}
|
|
4509
|
+
const { Buffer } = await import('buffer/');
|
|
4510
|
+
globalThis.Buffer = Buffer;
|
|
4511
|
+
}
|
|
4480
4512
|
/** @internal Hex string (with or without 0x) to bytes. */
|
|
4481
4513
|
function hexToBytes(hex) {
|
|
4482
4514
|
const clean = hex.startsWith('0x') || hex.startsWith('0X') ? hex.slice(2) : hex;
|
|
@@ -4586,6 +4618,8 @@ async function verifyProofOffChain(circuit, proof, publicInputs, options = {}) {
|
|
|
4586
4618
|
//
|
|
4587
4619
|
// The dynamic import is what keeps the cost off everyone else — a bundler
|
|
4588
4620
|
// splits it out, and a caller who never verifies off-chain never loads it.
|
|
4621
|
+
// Before bb.js, not after: its module-level code already reaches for Buffer.
|
|
4622
|
+
await ensureBufferForBarretenberg();
|
|
4589
4623
|
let bb;
|
|
4590
4624
|
try {
|
|
4591
4625
|
bb = await import('@aztec/bb.js');
|