@hyperdag/proof-verifier 0.1.0 → 0.2.0

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/README.md CHANGED
@@ -1,51 +1,54 @@
1
- # @hyperdag/proof-verifier
2
- Verify HyperDAG STARK proofs in your browser or Node app. No server trust.
3
-
4
- ## Why this exists
5
- HyperDAG's zkp-postcard service generates Plonky3 STARK proofs for every agent decision. If you trust HyperDAG's server when it says `verified: true`, you're just trusting a server. With this package, your code verifies the cryptographic proof itself — locally, deterministically, with no network call.
6
-
7
- ## Install
8
- ```bash
9
- npm install @hyperdag/proof-verifier
10
- ```
11
-
12
- ## Usage (3 lines)
13
- ```js
14
- import { verify } from '@hyperdag/proof-verifier';
15
- const result = await verify(proofBytes, statement);
16
- console.log(result.verified); // true | false
17
- ```
18
-
19
- ## End-to-end example with the SDK
20
- ```js
21
- import { TrustShell } from '@hyperdag/trustshell';
22
- import { verify } from '@hyperdag/proof-verifier';
23
-
24
- const trust = new TrustShell({ ...config });
25
- const decision = await trust.report({ ... });
26
- const proof = await trust.getProof(decision.proof_job_id);
27
- const result = await verify(proof.proof_bytes, proof.statement);
28
- if (!result.verified) throw new Error('proof failed verification — DO NOT TRUST');
29
- ```
30
-
31
- ## What gets verified
32
- - The agent had the claimed RepID at the claimed time.
33
- - The RepID fits within the 32-bit range check relative to the threshold.
34
- - The statement claim (score > threshold) is cryptographically consistent with the proof.
35
-
36
- ## Bundle size
37
- | Target | .wasm size |
38
- |---------|-----------|
39
- | bundler | 230 KB |
40
- | nodejs | 230 KB |
41
- | web | 230 KB |
42
-
43
- ## Performance
44
- Verify time (avg on Node 22, Windows): ~110 ms
45
- Verify time (estimated Chrome/M3): ~150 ms
46
-
47
- ## Plonky3 version pinning
48
- This verifier is pinned to the EXACT Plonky3 revisions used by zkp-postcard. Mismatched versions cannot verify. See Cargo.toml.
49
-
50
- ## License
51
- MIT OR Apache-2.0
1
+ # @hyperdag/proof-verifier
2
+
3
+ Verify HyperDAG Plonky3 STARK RepID proofs in your browser or Node app. **Trust math, not a server.**
4
+
5
+ ## Why this exists
6
+ HyperDAG's `zkp-postcard` service generates a Plonky3 STARK proof that an agent's RepID exceeds a threshold. If you trust the server when it says `verified: true`, you're trusting a server. With this package your code verifies the cryptographic proof itself — locally, deterministically, no network call.
7
+
8
+ ## Install
9
+ ```bash
10
+ npm install @hyperdag/proof-verifier
11
+ ```
12
+
13
+ ## Usage (3 lines)
14
+ ```js
15
+ import { verify } from '@hyperdag/proof-verifier';
16
+ const result = await verify(proofBytes, statement); // statement = { agent_id, repid_score, threshold, tier }
17
+ console.log(result.verified); // true | false
18
+ ```
19
+
20
+ ## End-to-end with the SDK
21
+ ```js
22
+ import { TrustShell } from '@hyperdag/trustshell';
23
+ const ts = new TrustShell();
24
+ const proof = await ts.presentProof(agentId, { verify: true }); // fetches the proof + verifies it client-side
25
+ if (!proof.verification?.verified) throw new Error('proof failed verification — DO NOT TRUST');
26
+ ```
27
+
28
+ ## What it PROVES
29
+ The public statement is exactly `{ agent_id, threshold, repid_score }` — **no timestamp, no hidden data beyond the proof witness.** A `verified: true` means, cryptographically:
30
+
31
+ - **Agent-bound.** The proof is bound to `agent_id` (its 16 bytes are public inputs observed into the Fiat-Shamir transcript). A proof minted for agent A **fails** verification under any other agent_id — it cannot be replayed.
32
+ - **Range-sound (16-bit range check).** The circuit proves `repid_score > threshold` by range-checking the gap `repid_score threshold − 1` into **16 bits** (the high 16 bits are constrained to zero). A claim where `repid_score ≤ threshold` has no satisfying witness — including the field-wrap case (`gap = −1 = p−1`), which an earlier 31-bit check would have admitted. (Soundness assumption: `repid_score − threshold < 65536`, always true for RepID where `repid_score ≤ 10000`.)
33
+ - **Value-bound.** An AIR boundary constraint ties the range-checked gap to the public `{threshold, repid_score}` — the proof attests *this* agent's score exceeds *this* threshold, not merely "some 32-bit value exists."
34
+
35
+ ## What it does NOT prove
36
+ - It does **not** hide `repid_score` — the score is part of the public statement. This is a verifiable attestation that the proof is consistent with the stated values, not a zero-knowledge concealment of the score.
37
+ - It carries **no timestamp** — there is no "had RepID X at time T" claim. The statement is timeless `{agent_id, threshold, repid_score}`.
38
+ - It does not re-verify the server's upstream RepID computation — it verifies the proof matches the stated `{agent_id, threshold, repid_score}`.
39
+
40
+ ## Plonky3 version pinning
41
+ Pinned to the EXACT Plonky3 revision used by `zkp-postcard` (`27d59f7350daf6b02d11b01c3a55af453554b515`). A mismatched pin cannot verify. See `Cargo.toml`.
42
+
43
+ ## Bundle size
44
+ | Target | .wasm size |
45
+ |---------|-----------|
46
+ | bundler | ~245 KB |
47
+ | nodejs | ~245 KB |
48
+ | web | ~245 KB |
49
+
50
+ ## Performance
51
+ Verify time (avg, Node 22): ~30 ms per proof (native build; in-browser WASM is comparable).
52
+
53
+ ## License
54
+ Apache-2.0
package/js/index.js CHANGED
@@ -1,38 +1,38 @@
1
- let verifier;
2
-
3
- async function getVerifier() {
4
- if (verifier) return verifier;
5
-
6
- const isNode = typeof process !== 'undefined' && process.versions && process.versions.node;
7
-
8
- if (isNode) {
9
- // Node.js target
10
- verifier = await import('../pkg-node/hyperdag_proof_verifier.js');
11
- } else {
12
- // Browser/Bundler target - assumes WASM is bundled or served
13
- verifier = await import('../pkg/hyperdag_proof_verifier.js');
14
- await verifier.default(); // Initialize WASM
15
- }
16
-
17
- verifier.init_panic_hook();
18
- return verifier;
19
- }
20
-
21
- /**
22
- * Verify a HyperDAG STARK proof locally.
23
- *
24
- * @param {string} proofBytes - Base64 encoded proof bytes
25
- * @param {object} statement - The public statement (agent_id, repid_score, threshold, tier)
26
- * @returns {Promise<object>} - { verified: boolean, error: string | null, proof_size_bytes: number, verifier_version: string }
27
- */
28
- export async function verify(proofBytes, statement) {
29
- const v = await getVerifier();
30
-
31
- const input = {
32
- proof_bytes: proofBytes,
33
- statement: statement
34
- };
35
-
36
- const resultJson = v.verify_proof(JSON.stringify(input));
37
- return JSON.parse(resultJson);
38
- }
1
+ let verifier;
2
+
3
+ async function getVerifier() {
4
+ if (verifier) return verifier;
5
+
6
+ const isNode = typeof process !== 'undefined' && process.versions && process.versions.node;
7
+
8
+ if (isNode) {
9
+ // Node.js target
10
+ verifier = await import('../pkg-node/hyperdag_proof_verifier.js');
11
+ } else {
12
+ // Browser/Bundler target - assumes WASM is bundled or served
13
+ verifier = await import('../pkg/hyperdag_proof_verifier.js');
14
+ await verifier.default(); // Initialize WASM
15
+ }
16
+
17
+ verifier.init_panic_hook();
18
+ return verifier;
19
+ }
20
+
21
+ /**
22
+ * Verify a HyperDAG STARK proof locally.
23
+ *
24
+ * @param {string} proofBytes - Base64 encoded proof bytes
25
+ * @param {object} statement - The public statement (agent_id, repid_score, threshold, tier)
26
+ * @returns {Promise<object>} - { verified: boolean, error: string | null, proof_size_bytes: number, verifier_version: string }
27
+ */
28
+ export async function verify(proofBytes, statement) {
29
+ const v = await getVerifier();
30
+
31
+ const input = {
32
+ proof_bytes: proofBytes,
33
+ statement: statement
34
+ };
35
+
36
+ const resultJson = v.verify_proof(JSON.stringify(input));
37
+ return JSON.parse(resultJson);
38
+ }
package/package.json CHANGED
@@ -1,37 +1,36 @@
1
- {
2
- "name": "@hyperdag/proof-verifier",
3
- "version": "0.1.0",
4
- "description": "Verify HyperDAG Plonky3 STARK proofs client-side. Trust math, not a server.",
5
- "main": "js/index.js",
6
- "types": "js/index.d.ts",
7
- "type": "module",
8
- "files": [
9
- "js/",
10
- "pkg/",
11
- "pkg-node/",
12
- "pkg-web/",
13
- "README.md",
14
- "LICENSE-APACHE",
15
- "LICENSE-MIT"
16
- ],
17
- "keywords": [
18
- "stark",
19
- "plonky3",
20
- "zkp",
21
- "hyperdag",
22
- "wasm",
23
- "verifier"
24
- ],
25
- "license": "MIT OR Apache-2.0",
26
- "repository": "github:DealAppSeo/hyperdag-proof-verifier",
27
- "publishConfig": {
28
- "access": "public"
29
- },
30
- "scripts": {
31
- "build": "wasm-pack build --target bundler --out-dir pkg --release && wasm-pack build --target nodejs --out-dir pkg-node --release && wasm-pack build --target web --out-dir pkg-web --release",
32
- "test": "node --experimental-vm-modules node_modules/jest/bin/jest.js"
33
- },
34
- "devDependencies": {
35
- "jest": "^30.3.0"
36
- }
37
- }
1
+ {
2
+ "name": "@hyperdag/proof-verifier",
3
+ "version": "0.2.0",
4
+ "description": "Verify HyperDAG Plonky3 STARK proofs client-side. Trust math, not a server.",
5
+ "main": "js/index.js",
6
+ "types": "js/index.d.ts",
7
+ "type": "module",
8
+ "files": [
9
+ "js/",
10
+ "pkg/",
11
+ "pkg-node/",
12
+ "pkg-web/",
13
+ "README.md",
14
+ "LICENSE-APACHE"
15
+ ],
16
+ "keywords": [
17
+ "stark",
18
+ "plonky3",
19
+ "zkp",
20
+ "hyperdag",
21
+ "wasm",
22
+ "verifier"
23
+ ],
24
+ "license": "Apache-2.0",
25
+ "repository": "github:DealAppSeo/hyperdag-proof-verifier",
26
+ "publishConfig": {
27
+ "access": "public"
28
+ },
29
+ "scripts": {
30
+ "build": "wasm-pack build --target bundler --out-dir pkg --release && wasm-pack build --target nodejs --out-dir pkg-node --release && wasm-pack build --target web --out-dir pkg-web --release",
31
+ "test": "node --experimental-vm-modules node_modules/jest/bin/jest.js"
32
+ },
33
+ "devDependencies": {
34
+ "jest": "^30.3.0"
35
+ }
36
+ }
package/pkg/README.md CHANGED
@@ -1,50 +1,51 @@
1
- # @hyperdag/proof-verifier
2
- Verify HyperDAG STARK proofs in your browser or Node app. No server trust.
3
-
4
- ## Why this exists
5
- HyperDAG's zkp-postcard service generates Plonky3 STARK proofs for every agent decision. If you trust HyperDAG's server when it says `verified: true`, you're just trusting a server. With this package, your code verifies the cryptographic proof itself — locally, deterministically, with no network call.
6
-
7
- ## Install
8
- ```bash
9
- npm install @hyperdag/proof-verifier
10
- ```
11
-
12
- ## Usage (3 lines)
13
- ```js
14
- import { verify } from '@hyperdag/proof-verifier';
15
- const result = await verify(proofBytes, statement);
16
- console.log(result.verified); // true | false
17
- ```
18
-
19
- ## End-to-end example with the SDK
20
- ```js
21
- import { TrustShell } from '@hyperdag/trustshell';
22
- import { verify } from '@hyperdag/proof-verifier';
23
-
24
- const trust = new TrustShell({ ...config });
25
- const decision = await trust.report({ ... });
26
- const proof = await trust.getProof(decision.proof_job_id);
27
- const result = await verify(proof.proof_bytes, proof.statement);
28
- if (!result.verified) throw new Error('proof failed verification — DO NOT TRUST');
29
- ```
30
-
31
- ## What gets verified
32
- - The agent had the claimed RepID at the claimed time.
33
- - The RepID fits within the 32-bit range check relative to the threshold.
34
- - The statement claim (score > threshold) is cryptographically consistent with the proof.
35
-
36
- ## Bundle size
37
- | Target | .wasm size |
38
- |---------|-----------|
39
- | bundler | TBD |
40
- | nodejs | TBD |
41
- | web | TBD |
42
-
43
- ## Performance
44
- Verify time (10-run avg on Node 20, Windows): TBD ms
45
-
46
- ## Plonky3 version pinning
47
- This verifier is pinned to the EXACT Plonky3 revisions used by zkp-postcard. Mismatched versions cannot verify. See Cargo.toml.
48
-
49
- ## License
50
- MIT OR Apache-2.0
1
+ # @hyperdag/proof-verifier
2
+ Verify HyperDAG STARK proofs in your browser or Node app. No server trust.
3
+
4
+ ## Why this exists
5
+ HyperDAG's zkp-postcard service generates Plonky3 STARK proofs for every agent decision. If you trust HyperDAG's server when it says `verified: true`, you're just trusting a server. With this package, your code verifies the cryptographic proof itself — locally, deterministically, with no network call.
6
+
7
+ ## Install
8
+ ```bash
9
+ npm install @hyperdag/proof-verifier
10
+ ```
11
+
12
+ ## Usage (3 lines)
13
+ ```js
14
+ import { verify } from '@hyperdag/proof-verifier';
15
+ const result = await verify(proofBytes, statement);
16
+ console.log(result.verified); // true | false
17
+ ```
18
+
19
+ ## End-to-end example with the SDK
20
+ ```js
21
+ import { TrustShell } from '@hyperdag/trustshell';
22
+ import { verify } from '@hyperdag/proof-verifier';
23
+
24
+ const trust = new TrustShell({ ...config });
25
+ const decision = await trust.report({ ... });
26
+ const proof = await trust.getProof(decision.proof_job_id);
27
+ const result = await verify(proof.proof_bytes, proof.statement);
28
+ if (!result.verified) throw new Error('proof failed verification — DO NOT TRUST');
29
+ ```
30
+
31
+ ## What gets verified
32
+ - The agent had the claimed RepID at the claimed time.
33
+ - The RepID fits within the 32-bit range check relative to the threshold.
34
+ - The statement claim (score > threshold) is cryptographically consistent with the proof.
35
+
36
+ ## Bundle size
37
+ | Target | .wasm size |
38
+ |---------|-----------|
39
+ | bundler | 230 KB |
40
+ | nodejs | 230 KB |
41
+ | web | 230 KB |
42
+
43
+ ## Performance
44
+ Verify time (avg on Node 22, Windows): ~110 ms
45
+ Verify time (estimated Chrome/M3): ~150 ms
46
+
47
+ ## Plonky3 version pinning
48
+ This verifier is pinned to the EXACT Plonky3 revisions used by zkp-postcard. Mismatched versions cannot verify. See Cargo.toml.
49
+
50
+ ## License
51
+ MIT OR Apache-2.0
@@ -1,6 +1,6 @@
1
- /* tslint:disable */
2
- /* eslint-disable */
3
-
4
- export function init_panic_hook(): void;
5
-
6
- export function verify_proof(input_json: string): string;
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+
4
+ export function init_panic_hook(): void;
5
+
6
+ export function verify_proof(input_json: string): string;
@@ -1,9 +1,9 @@
1
- /* @ts-self-types="./hyperdag_proof_verifier.d.ts" */
2
- import * as wasm from "./hyperdag_proof_verifier_bg.wasm";
3
- import { __wbg_set_wasm } from "./hyperdag_proof_verifier_bg.js";
4
-
5
- __wbg_set_wasm(wasm);
6
-
7
- export {
8
- init_panic_hook, verify_proof
9
- } from "./hyperdag_proof_verifier_bg.js";
1
+ /* @ts-self-types="./hyperdag_proof_verifier.d.ts" */
2
+ import * as wasm from "./hyperdag_proof_verifier_bg.wasm";
3
+ import { __wbg_set_wasm } from "./hyperdag_proof_verifier_bg.js";
4
+
5
+ __wbg_set_wasm(wasm);
6
+
7
+ export {
8
+ init_panic_hook, verify_proof
9
+ } from "./hyperdag_proof_verifier_bg.js";