@zkproofport-app/sdk 0.2.12 → 0.2.14
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 +29 -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 +432 -147
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +433 -146
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +432 -147
- package/dist/index.mjs.map +1 -1
- package/dist/offChainVerifier.d.ts +75 -0
- package/package.json +2 -1
|
@@ -0,0 +1,75 @@
|
|
|
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. Proofs here are made with `--oracle_hash keccak` and ZK on, so
|
|
15
|
+
* the matching check is `acirVerifyUltraKeccakZkHonk(proof, vk)`. Two things
|
|
16
|
+
* have to line up:
|
|
17
|
+
*
|
|
18
|
+
* The version. `@aztec/bb.js@1.0.0-nightly.20250723` is the WASM build of the
|
|
19
|
+
* same bb the circuits are compiled with. Versions are not interchangeable:
|
|
20
|
+
* measured on the Korea Mobile ID age circuit, the pinned bb writes a 16256-
|
|
21
|
+
* byte proof where bb 1.2.0 writes 16224 for the identical circuit and
|
|
22
|
+
* witness — and the verification key comes out the SAME either way, so the
|
|
23
|
+
* key cannot warn you. A mismatch shows up only as verification failing.
|
|
24
|
+
*
|
|
25
|
+
* The flavour. There are four verify entry points and picking the wrong one
|
|
26
|
+
* is not a polite false. `acirVerifyUltraZKHonk` (poseidon) answers false for
|
|
27
|
+
* a perfectly good proof, and `acirVerifyUltraKeccakHonk` — keccak without ZK
|
|
28
|
+
* — TRAPS the WebAssembly with a bare "unreachable", which looks exactly like
|
|
29
|
+
* a corrupt proof, a mismatched key, or a missing SRS.
|
|
30
|
+
*
|
|
31
|
+
* THE PROOF ARRIVES IN TWO PIECES. The mobile app splits what Barretenberg
|
|
32
|
+
* produced into `proof` and `publicInputs` before sending it, because the
|
|
33
|
+
* Solidity verifier takes them separately. Verifying needs them joined back, in
|
|
34
|
+
* that order, which is what `reconstructHonkProof` does.
|
|
35
|
+
*/
|
|
36
|
+
import { type CircuitId } from './circuits';
|
|
37
|
+
export interface OffChainVerifyResult {
|
|
38
|
+
valid: boolean;
|
|
39
|
+
error?: string;
|
|
40
|
+
}
|
|
41
|
+
export interface OffChainVerifyOptions {
|
|
42
|
+
/**
|
|
43
|
+
* Verification key bytes, if the caller already has them. Skips the fetch —
|
|
44
|
+
* useful offline, in tests, and for anyone who would rather pin the key they
|
|
45
|
+
* checked than trust a download.
|
|
46
|
+
*/
|
|
47
|
+
verificationKey?: Uint8Array;
|
|
48
|
+
/** Milliseconds before the fetch is abandoned. Default 30000. */
|
|
49
|
+
timeoutMs?: number;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Verify a proof off-chain, against its verification key.
|
|
53
|
+
*
|
|
54
|
+
* Needs no setup from the caller: the verifier ships with this SDK and is
|
|
55
|
+
* loaded on first use.
|
|
56
|
+
*
|
|
57
|
+
* @param circuit - Canonical circuit identifier
|
|
58
|
+
* @param proof - Proof bytes as hex, WITHOUT public inputs (as the relay sends it)
|
|
59
|
+
* @param publicInputs - Public inputs as hex strings, in circuit order
|
|
60
|
+
* @param options - Optional verification key and timeout
|
|
61
|
+
* @returns `{ valid }`, or `{ valid: false, error }` when the check could not run
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* ```typescript
|
|
65
|
+
* const result = await verifyProofOffChain(
|
|
66
|
+
* 'coinbase_attestation',
|
|
67
|
+
* response.proof,
|
|
68
|
+
* response.publicInputs
|
|
69
|
+
* );
|
|
70
|
+
* if (result.valid) console.log('Proof is valid, no chain involved');
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
export declare function verifyProofOffChain(circuit: CircuitId, proof: string, publicInputs: string[], options?: OffChainVerifyOptions): Promise<OffChainVerifyResult>;
|
|
74
|
+
/** @internal Test seam — lets a test start from a known-empty cache. */
|
|
75
|
+
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.14",
|
|
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",
|
|
@@ -32,6 +32,7 @@
|
|
|
32
32
|
"prepublishOnly": "npm run build"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
+
"@aztec/bb.js": "1.0.0-nightly.20250723",
|
|
35
36
|
"qrcode": "^1.5.3",
|
|
36
37
|
"socket.io-client": "^4.8.0"
|
|
37
38
|
},
|