@zkproofport-app/sdk 0.2.12 → 0.2.13
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 +31 -0
- package/dist/circuits.d.ts +14 -0
- package/dist/circuits.esm.js +23 -1
- package/dist/circuits.esm.js.map +1 -1
- package/dist/circuits.js +23 -0
- package/dist/circuits.js.map +1 -1
- package/dist/circuits.mjs +23 -1
- package/dist/circuits.mjs.map +1 -1
- package/dist/constants.d.ts +7 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.esm.js +418 -147
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +419 -146
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +418 -147
- package/dist/index.mjs.map +1 -1
- package/dist/offChainVerifier.d.ts +73 -0
- package/package.json +8 -3
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Off-chain proof verification — checking a proof against its verification key,
|
|
3
|
+
* with no chain, no RPC, and no gas.
|
|
4
|
+
*
|
|
5
|
+
* WHY THIS EXISTS. The SDK had only `verifyProofOnChain`, and every caller that
|
|
6
|
+
* wanted an off-chain check called that instead and relabelled the result. The
|
|
7
|
+
* demo page did exactly this from its first commit: pressing "Off-Chain Verify"
|
|
8
|
+
* ran an on-chain verification and printed "Off-Chain Verification Passed!".
|
|
9
|
+
* The answer was true and the label was a lie, which is the worst combination —
|
|
10
|
+
* nothing looked broken. The mobile app has always verified off-chain properly
|
|
11
|
+
* (through mopro's native Barretenberg); it was only the JavaScript side that
|
|
12
|
+
* had no such thing.
|
|
13
|
+
*
|
|
14
|
+
* HOW IT WORKS. `bb` proofs are checked by `acirVerifyUltraKeccakHonk(proof,
|
|
15
|
+
* vk)` — the keccak variant, matching how these proofs are produced. Two things
|
|
16
|
+
* have to line up:
|
|
17
|
+
*
|
|
18
|
+
* The version. The verification key format is not stable across bb releases:
|
|
19
|
+
* the pinned build emits a 1816-byte key where bb 0.87.0 and 1.2.0 emit 1760.
|
|
20
|
+
* `@aztec/bb.js@1.0.0-nightly.20250723` is the WASM build of the same bb the
|
|
21
|
+
* circuits were compiled with. A different one will reject valid proofs.
|
|
22
|
+
*
|
|
23
|
+
* The oracle hash. Proofs are generated with `--oracle_hash keccak` so the
|
|
24
|
+
* Solidity verifiers can check them, so the poseidon-flavoured verify — which
|
|
25
|
+
* is what `BarretenbergVerifier.verifyUltraHonkProof` uses — says false for a
|
|
26
|
+
* perfectly good proof.
|
|
27
|
+
*
|
|
28
|
+
* THE PROOF ARRIVES IN TWO PIECES. The mobile app splits what Barretenberg
|
|
29
|
+
* produced into `proof` and `publicInputs` before sending it, because the
|
|
30
|
+
* Solidity verifier takes them separately. Verifying needs them joined back, in
|
|
31
|
+
* that order, which is what `reconstructHonkProof` does.
|
|
32
|
+
*/
|
|
33
|
+
import { type CircuitId } from './circuits';
|
|
34
|
+
export interface OffChainVerifyResult {
|
|
35
|
+
valid: boolean;
|
|
36
|
+
error?: string;
|
|
37
|
+
}
|
|
38
|
+
export interface OffChainVerifyOptions {
|
|
39
|
+
/**
|
|
40
|
+
* Verification key bytes, if the caller already has them. Skips the fetch —
|
|
41
|
+
* useful offline, in tests, and for anyone who would rather pin the key they
|
|
42
|
+
* checked than trust a download.
|
|
43
|
+
*/
|
|
44
|
+
verificationKey?: Uint8Array;
|
|
45
|
+
/** Milliseconds before the fetch is abandoned. Default 30000. */
|
|
46
|
+
timeoutMs?: number;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Verify a proof off-chain, against its verification key.
|
|
50
|
+
*
|
|
51
|
+
* Needs `@aztec/bb.js` at the pinned version. It is an optional peer dependency
|
|
52
|
+
* — the WASM is large and most callers verify on-chain — so the failure to have
|
|
53
|
+
* it installed says so plainly rather than surfacing as a module-not-found.
|
|
54
|
+
*
|
|
55
|
+
* @param circuit - Canonical circuit identifier
|
|
56
|
+
* @param proof - Proof bytes as hex, WITHOUT public inputs (as the relay sends it)
|
|
57
|
+
* @param publicInputs - Public inputs as hex strings, in circuit order
|
|
58
|
+
* @param options - Optional verification key and timeout
|
|
59
|
+
* @returns `{ valid }`, or `{ valid: false, error }` when the check could not run
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* ```typescript
|
|
63
|
+
* const result = await verifyProofOffChain(
|
|
64
|
+
* 'coinbase_attestation',
|
|
65
|
+
* response.proof,
|
|
66
|
+
* response.publicInputs
|
|
67
|
+
* );
|
|
68
|
+
* if (result.valid) console.log('Proof is valid, no chain involved');
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
71
|
+
export declare function verifyProofOffChain(circuit: CircuitId, proof: string, publicInputs: string[], options?: OffChainVerifyOptions): Promise<OffChainVerifyResult>;
|
|
72
|
+
/** @internal Test seam — lets a test start from a known-empty cache. */
|
|
73
|
+
export declare function clearVerificationKeyCache(): void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zkproofport-app/sdk",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.13",
|
|
4
4
|
"description": "ZKProofport SDK for requesting zero-knowledge proofs from the ZKProofport mobile app and verifying them on-chain",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.esm.js",
|
|
@@ -45,14 +45,19 @@
|
|
|
45
45
|
"tslib": "^2.8.1",
|
|
46
46
|
"typedoc": "^0.28.16",
|
|
47
47
|
"typescript": "^5.3.3",
|
|
48
|
-
"vitest": "^4.0.18"
|
|
48
|
+
"vitest": "^4.0.18",
|
|
49
|
+
"@aztec/bb.js": "1.0.0-nightly.20250723"
|
|
49
50
|
},
|
|
50
51
|
"peerDependencies": {
|
|
51
|
-
"ethers": "^5.7.0 || ^6.0.0"
|
|
52
|
+
"ethers": "^5.7.0 || ^6.0.0",
|
|
53
|
+
"@aztec/bb.js": "1.0.0-nightly.20250723"
|
|
52
54
|
},
|
|
53
55
|
"peerDependenciesMeta": {
|
|
54
56
|
"ethers": {
|
|
55
57
|
"optional": true
|
|
58
|
+
},
|
|
59
|
+
"@aztec/bb.js": {
|
|
60
|
+
"optional": true
|
|
56
61
|
}
|
|
57
62
|
},
|
|
58
63
|
"keywords": [
|