@zkproofport-app/sdk 0.2.13 → 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/ProofportSDK.d.ts +2 -4
- package/dist/index.esm.js +68 -20
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +68 -20
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +68 -20
- package/dist/index.mjs.map +1 -1
- package/dist/offChainVerifier.d.ts +15 -13
- package/package.json +5 -8
package/dist/ProofportSDK.d.ts
CHANGED
|
@@ -538,10 +538,8 @@ export declare class ProofportSDK {
|
|
|
538
538
|
* chain's own opinion: use {@link verifyResponseOnChain} when the answer has
|
|
539
539
|
* to be one a contract will agree with.
|
|
540
540
|
*
|
|
541
|
-
*
|
|
542
|
-
*
|
|
543
|
-
* verification keys are not portable across bb releases, so a different build
|
|
544
|
-
* rejects valid proofs.
|
|
541
|
+
* Needs no setup: the verifier ships with this SDK. It is loaded on first
|
|
542
|
+
* use, so a caller who only verifies on-chain never pays for it.
|
|
545
543
|
*
|
|
546
544
|
* @param response - Proof response from the relay
|
|
547
545
|
* @param options - Optional verification key (skips the fetch) and timeout
|
package/dist/index.esm.js
CHANGED
|
@@ -4443,19 +4443,22 @@ function getCircuitSupportStatus(circuit) {
|
|
|
4443
4443
|
* (through mopro's native Barretenberg); it was only the JavaScript side that
|
|
4444
4444
|
* had no such thing.
|
|
4445
4445
|
*
|
|
4446
|
-
* HOW IT WORKS.
|
|
4447
|
-
*
|
|
4446
|
+
* HOW IT WORKS. Proofs here are made with `--oracle_hash keccak` and ZK on, so
|
|
4447
|
+
* the matching check is `acirVerifyUltraKeccakZkHonk(proof, vk)`. Two things
|
|
4448
4448
|
* have to line up:
|
|
4449
4449
|
*
|
|
4450
|
-
* The version.
|
|
4451
|
-
*
|
|
4452
|
-
*
|
|
4453
|
-
*
|
|
4450
|
+
* The version. `@aztec/bb.js@1.0.0-nightly.20250723` is the WASM build of the
|
|
4451
|
+
* same bb the circuits are compiled with. Versions are not interchangeable:
|
|
4452
|
+
* measured on the Korea Mobile ID age circuit, the pinned bb writes a 16256-
|
|
4453
|
+
* byte proof where bb 1.2.0 writes 16224 for the identical circuit and
|
|
4454
|
+
* witness — and the verification key comes out the SAME either way, so the
|
|
4455
|
+
* key cannot warn you. A mismatch shows up only as verification failing.
|
|
4454
4456
|
*
|
|
4455
|
-
* The
|
|
4456
|
-
*
|
|
4457
|
-
*
|
|
4458
|
-
*
|
|
4457
|
+
* The flavour. There are four verify entry points and picking the wrong one
|
|
4458
|
+
* is not a polite false. `acirVerifyUltraZKHonk` (poseidon) answers false for
|
|
4459
|
+
* a perfectly good proof, and `acirVerifyUltraKeccakHonk` — keccak without ZK
|
|
4460
|
+
* — TRAPS the WebAssembly with a bare "unreachable", which looks exactly like
|
|
4461
|
+
* a corrupt proof, a mismatched key, or a missing SRS.
|
|
4459
4462
|
*
|
|
4460
4463
|
* THE PROOF ARRIVES IN TWO PIECES. The mobile app splits what Barretenberg
|
|
4461
4464
|
* produced into `proof` and `publicInputs` before sending it, because the
|
|
@@ -4474,6 +4477,38 @@ const CIRCUITS_VK_BASE = 'https://raw.githubusercontent.com/zkproofport/circuits
|
|
|
4474
4477
|
/** How long a fetched verification key is reused. Keys change only on a recompile. */
|
|
4475
4478
|
const VK_CACHE_TTL_MS = 60 * 60 * 1000;
|
|
4476
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
|
+
}
|
|
4477
4512
|
/** @internal Hex string (with or without 0x) to bytes. */
|
|
4478
4513
|
function hexToBytes(hex) {
|
|
4479
4514
|
const clean = hex.startsWith('0x') || hex.startsWith('0X') ? hex.slice(2) : hex;
|
|
@@ -4552,9 +4587,8 @@ async function fetchVerificationKey(circuit, timeoutMs) {
|
|
|
4552
4587
|
/**
|
|
4553
4588
|
* Verify a proof off-chain, against its verification key.
|
|
4554
4589
|
*
|
|
4555
|
-
* Needs
|
|
4556
|
-
*
|
|
4557
|
-
* it installed says so plainly rather than surfacing as a module-not-found.
|
|
4590
|
+
* Needs no setup from the caller: the verifier ships with this SDK and is
|
|
4591
|
+
* loaded on first use.
|
|
4558
4592
|
*
|
|
4559
4593
|
* @param circuit - Canonical circuit identifier
|
|
4560
4594
|
* @param proof - Proof bytes as hex, WITHOUT public inputs (as the relay sends it)
|
|
@@ -4574,15 +4608,31 @@ async function fetchVerificationKey(circuit, timeoutMs) {
|
|
|
4574
4608
|
*/
|
|
4575
4609
|
async function verifyProofOffChain(circuit, proof, publicInputs, options = {}) {
|
|
4576
4610
|
const timeoutMs = options.timeoutMs ?? 30000;
|
|
4611
|
+
// A REQUIRED dependency, loaded lazily.
|
|
4612
|
+
//
|
|
4613
|
+
// It was briefly an optional peer dependency, on the reasoning that the WASM
|
|
4614
|
+
// is 16MB and most callers verify on-chain. That was wrong: it would have
|
|
4615
|
+
// meant a customer calling this method got an error telling them to install
|
|
4616
|
+
// something, and "works with zero customer configuration" is the SDK's rule.
|
|
4617
|
+
// A caller should never have to know this is implemented with Barretenberg.
|
|
4618
|
+
//
|
|
4619
|
+
// The dynamic import is what keeps the cost off everyone else — a bundler
|
|
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();
|
|
4577
4623
|
let bb;
|
|
4578
4624
|
try {
|
|
4579
4625
|
bb = await import('@aztec/bb.js');
|
|
4580
4626
|
}
|
|
4581
|
-
catch {
|
|
4627
|
+
catch (error) {
|
|
4628
|
+
// Reaching here means the install is broken, not that something is missing
|
|
4629
|
+
// by design. Say so, rather than sending the caller off to install a
|
|
4630
|
+
// package they should never have had to hear about.
|
|
4582
4631
|
return {
|
|
4583
4632
|
valid: false,
|
|
4584
|
-
error: '
|
|
4585
|
-
'
|
|
4633
|
+
error: 'Could not load the proof verifier (@aztec/bb.js), which ships with this ' +
|
|
4634
|
+
'SDK. This usually means a broken or partial install — try reinstalling ' +
|
|
4635
|
+
`@zkproofport-app/sdk. Underlying error: ${error instanceof Error ? error.message : String(error)}`,
|
|
4586
4636
|
};
|
|
4587
4637
|
}
|
|
4588
4638
|
let api;
|
|
@@ -5294,10 +5344,8 @@ class ProofportSDK {
|
|
|
5294
5344
|
* chain's own opinion: use {@link verifyResponseOnChain} when the answer has
|
|
5295
5345
|
* to be one a contract will agree with.
|
|
5296
5346
|
*
|
|
5297
|
-
*
|
|
5298
|
-
*
|
|
5299
|
-
* verification keys are not portable across bb releases, so a different build
|
|
5300
|
-
* rejects valid proofs.
|
|
5347
|
+
* Needs no setup: the verifier ships with this SDK. It is loaded on first
|
|
5348
|
+
* use, so a caller who only verifies on-chain never pays for it.
|
|
5301
5349
|
*
|
|
5302
5350
|
* @param response - Proof response from the relay
|
|
5303
5351
|
* @param options - Optional verification key (skips the fetch) and timeout
|