@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.js
CHANGED
|
@@ -1615,6 +1615,38 @@ const CIRCUITS_VK_BASE = 'https://raw.githubusercontent.com/zkproofport/circuits
|
|
|
1615
1615
|
/** How long a fetched verification key is reused. Keys change only on a recompile. */
|
|
1616
1616
|
const VK_CACHE_TTL_MS = 60 * 60 * 1000;
|
|
1617
1617
|
const vkCache = new Map();
|
|
1618
|
+
/**
|
|
1619
|
+
* Make sure a Node-shaped `Buffer` exists before Barretenberg is loaded.
|
|
1620
|
+
*
|
|
1621
|
+
* WHY THE SDK DOES THIS RATHER THAN THE CALLER. bb.js's own BROWSER build —
|
|
1622
|
+
* not just its node build — converts field elements through `Buffer.alloc` and
|
|
1623
|
+
* `buf.writeBigUInt64BE`. Browsers have no Buffer, and bundlers stopped
|
|
1624
|
+
* polyfilling Node globals years ago, so in a browser the first verification
|
|
1625
|
+
* dies with "r.writeBigUInt64BE is not a function" — a message that names
|
|
1626
|
+
* nothing a caller could act on. Measured on the demo page, 2026-09-04, against
|
|
1627
|
+
* a real GIWA proof.
|
|
1628
|
+
*
|
|
1629
|
+
* Leaving it to callers would mean every browser customer editing their
|
|
1630
|
+
* bundler config to make an SDK method work, which is the configuration this
|
|
1631
|
+
* SDK promises not to require.
|
|
1632
|
+
*
|
|
1633
|
+
* Deliberately narrow:
|
|
1634
|
+
* - It only fills a GAP. A real Buffer (Node, or a page that already has one)
|
|
1635
|
+
* is left alone, so nothing is shadowed by a lesser implementation.
|
|
1636
|
+
* - It checks for the METHOD, not just the global. A partial Buffer — which is
|
|
1637
|
+
* what several bundlers leave behind, and what the demo page actually had —
|
|
1638
|
+
* passes a `typeof Buffer` test and then fails inside Barretenberg.
|
|
1639
|
+
*/
|
|
1640
|
+
async function ensureBufferForBarretenberg() {
|
|
1641
|
+
const existing = globalThis.Buffer;
|
|
1642
|
+
if (existing?.alloc) {
|
|
1643
|
+
const probe = existing.alloc(8);
|
|
1644
|
+
if (typeof probe.writeBigUInt64BE === 'function')
|
|
1645
|
+
return;
|
|
1646
|
+
}
|
|
1647
|
+
const { Buffer } = await import('buffer/');
|
|
1648
|
+
globalThis.Buffer = Buffer;
|
|
1649
|
+
}
|
|
1618
1650
|
/** @internal Hex string (with or without 0x) to bytes. */
|
|
1619
1651
|
function hexToBytes(hex) {
|
|
1620
1652
|
const clean = hex.startsWith('0x') || hex.startsWith('0X') ? hex.slice(2) : hex;
|
|
@@ -1724,6 +1756,8 @@ async function verifyProofOffChain(circuit, proof, publicInputs, options = {}) {
|
|
|
1724
1756
|
//
|
|
1725
1757
|
// The dynamic import is what keeps the cost off everyone else — a bundler
|
|
1726
1758
|
// splits it out, and a caller who never verifies off-chain never loads it.
|
|
1759
|
+
// Before bb.js, not after: its module-level code already reaches for Buffer.
|
|
1760
|
+
await ensureBufferForBarretenberg();
|
|
1727
1761
|
let bb;
|
|
1728
1762
|
try {
|
|
1729
1763
|
bb = await import('@aztec/bb.js');
|