veritaszk-sdk 0.2.0 → 0.3.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 +160 -48
- package/dist/index.d.ts +13 -0
- package/dist/index.js +45 -0
- package/package.json +20 -4
package/README.md
CHANGED
|
@@ -1,77 +1,189 @@
|
|
|
1
1
|
# veritaszk-sdk
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
TypeScript SDK for [VeritasZK](https://veritaszk.vercel.app) — the first
|
|
4
|
+
zero-knowledge proof-of-solvency system on Aleo.
|
|
5
|
+
|
|
6
|
+
Organizations prove assets exceed liabilities via ZK proof without revealing
|
|
7
|
+
amounts, asset types, or wallet addresses. Anyone can verify the result.
|
|
8
|
+
Nobody sees the underlying data. Ever.
|
|
9
|
+
|
|
10
|
+
## Quick Start
|
|
6
11
|
|
|
7
|
-
## Install
|
|
8
12
|
```bash
|
|
9
13
|
npm install veritaszk-sdk
|
|
10
14
|
```
|
|
11
15
|
|
|
16
|
+
```typescript
|
|
17
|
+
import { verifySolvency } from 'veritaszk-sdk'
|
|
18
|
+
|
|
19
|
+
const result = await verifySolvency('aleo1cdmu479q6duu327wgm3vnphqtq2n4q4vcvp66f5742gv5f8f9qxq0w9r00')
|
|
20
|
+
console.log(result.isSolvent) // true — no amounts revealed
|
|
21
|
+
console.log(result.verificationCount) // times verified on-chain
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Architecture
|
|
25
|
+
|
|
26
|
+
VeritasZK runs three Leo programs on Aleo Testnet in a CPI chain:
|
|
27
|
+
|
|
28
|
+
```
|
|
29
|
+
veritaszk_registry.aleo (org identity, credentials, delegation)
|
|
30
|
+
↑
|
|
31
|
+
veritaszk_core.aleo ──→ veritaszk_audit.aleo
|
|
32
|
+
(ZK proof generation) (immutable audit trail)
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
This SDK queries public mappings across all three programs.
|
|
36
|
+
Private financial data is mathematically inaccessible — the amounts
|
|
37
|
+
exist only in encrypted Leo Records.
|
|
38
|
+
|
|
39
|
+
## API Reference
|
|
40
|
+
|
|
41
|
+
### Core Functions
|
|
42
|
+
|
|
43
|
+
| Function | Description | Returns |
|
|
44
|
+
|----------|-------------|---------|
|
|
45
|
+
| `verifySolvency(commitment)` | Full solvency status for one org | `Promise<SolvencyStatus>` |
|
|
46
|
+
| `batchVerify(commitments[])` | Check multiple orgs in parallel | `Promise<BatchVerifyResult[]>` |
|
|
47
|
+
| `isRegistered(commitment)` | Check if org is in registry | `Promise<boolean>` |
|
|
48
|
+
| `getAuditTrail(commitment)` | Proof event history from audit program | `Promise<AuditEvent>` |
|
|
49
|
+
| `getVerificationCount(commitment)` | Number of on-chain verifications | `Promise<number>` |
|
|
50
|
+
| `isProofExpired(commitment)` | Check if proof has expired | `Promise<boolean>` |
|
|
51
|
+
|
|
52
|
+
### React Hooks
|
|
53
|
+
|
|
54
|
+
| Hook | Description |
|
|
55
|
+
|------|-------------|
|
|
56
|
+
| `useSolvencyStatus(commitment)` | Auto-refreshing solvency status (polls every 30s) |
|
|
57
|
+
| `useAuditTrail(commitment)` | Fetches audit event history on mount |
|
|
58
|
+
|
|
59
|
+
### Webhook
|
|
60
|
+
|
|
61
|
+
| Class | Description |
|
|
62
|
+
|-------|-------------|
|
|
63
|
+
| `VeritasZKWebhook` | Polls solvency status and POSTs to your webhook URL on state changes |
|
|
64
|
+
|
|
12
65
|
## Usage
|
|
66
|
+
|
|
67
|
+
### Verify a single organization
|
|
68
|
+
|
|
13
69
|
```typescript
|
|
14
|
-
import {
|
|
70
|
+
import { verifySolvency } from 'veritaszk-sdk'
|
|
71
|
+
|
|
72
|
+
const status = await verifySolvency('aleo1...')
|
|
73
|
+
// {
|
|
74
|
+
// orgCommitment: 'aleo1...',
|
|
75
|
+
// isSolvent: true,
|
|
76
|
+
// timestamp: 142857,
|
|
77
|
+
// expiryBlock: 147857,
|
|
78
|
+
// verificationCount: 12,
|
|
79
|
+
// thresholdLevel: 2,
|
|
80
|
+
// hasMultiWallet: false,
|
|
81
|
+
// isExpired: false,
|
|
82
|
+
// lastProofBlock: 142857
|
|
83
|
+
// }
|
|
84
|
+
```
|
|
15
85
|
|
|
16
|
-
|
|
86
|
+
### Batch verification
|
|
17
87
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
console.log(result.isSolvent) // true
|
|
21
|
-
console.log(result.timestamp) // proof timestamp
|
|
22
|
-
console.log(result.verificationCount) // times verified
|
|
23
|
-
// Note: no amounts, no asset types, no financial data returned
|
|
88
|
+
```typescript
|
|
89
|
+
import { batchVerify } from 'veritaszk-sdk'
|
|
24
90
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
91
|
+
const results = await batchVerify([
|
|
92
|
+
'aleo1abc...',
|
|
93
|
+
'aleo1def...',
|
|
94
|
+
])
|
|
95
|
+
// [{ orgCommitment: 'aleo1abc...', isSolvent: true }, ...]
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### Check registry
|
|
99
|
+
|
|
100
|
+
```typescript
|
|
101
|
+
import { isRegistered } from 'veritaszk-sdk'
|
|
28
102
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
const { isSolvent } = await verifySolvency("aleo1abc...")
|
|
103
|
+
const registered = await isRegistered('aleo1...')
|
|
104
|
+
// true — organization has registered via veritaszk_registry.aleo
|
|
32
105
|
```
|
|
33
106
|
|
|
34
|
-
|
|
107
|
+
### Audit trail
|
|
35
108
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
109
|
+
```typescript
|
|
110
|
+
import { getAuditTrail } from 'veritaszk-sdk'
|
|
111
|
+
|
|
112
|
+
const trail = await getAuditTrail('aleo1...')
|
|
113
|
+
// {
|
|
114
|
+
// orgCommitment: 'aleo1...',
|
|
115
|
+
// eventCount: 5,
|
|
116
|
+
// lastProofBlock: 142857,
|
|
117
|
+
// isExpired: false
|
|
118
|
+
// }
|
|
119
|
+
```
|
|
41
120
|
|
|
42
|
-
|
|
43
|
-
the data does not exist in any queryable public state.
|
|
121
|
+
### React hooks
|
|
44
122
|
|
|
45
|
-
|
|
123
|
+
```tsx
|
|
124
|
+
import { useSolvencyStatus } from 'veritaszk-sdk/react'
|
|
46
125
|
|
|
47
|
-
|
|
126
|
+
function SolvencyBadge({ commitment }: { commitment: string }) {
|
|
127
|
+
const { status, loading, error } = useSolvencyStatus(commitment)
|
|
128
|
+
|
|
129
|
+
if (loading) return <span>Checking...</span>
|
|
130
|
+
if (error) return <span>Error: {error}</span>
|
|
131
|
+
if (!status) return null
|
|
132
|
+
|
|
133
|
+
return (
|
|
134
|
+
<span style={{ color: status.isSolvent ? '#10b981' : '#ef4444' }}>
|
|
135
|
+
{status.isSolvent ? '✓ SOLVENT' : '✗ NOT SOLVENT'}
|
|
136
|
+
</span>
|
|
137
|
+
)
|
|
138
|
+
}
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
### Webhook monitoring
|
|
142
|
+
|
|
143
|
+
```typescript
|
|
144
|
+
import { VeritasZKWebhook } from 'veritaszk-sdk/webhooks'
|
|
145
|
+
|
|
146
|
+
const webhook = new VeritasZKWebhook({
|
|
147
|
+
url: 'https://your-server.com/webhook',
|
|
148
|
+
events: ['proof.generated', 'proof.expired', 'proof.revoked'],
|
|
149
|
+
orgCommitment: 'aleo1...',
|
|
150
|
+
pollIntervalMs: 60000,
|
|
151
|
+
})
|
|
152
|
+
|
|
153
|
+
webhook.start()
|
|
154
|
+
// POSTs to your URL whenever solvency state changes
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
## What the SDK Does NOT Return
|
|
158
|
+
|
|
159
|
+
By design, no function in this SDK can return:
|
|
160
|
+
|
|
161
|
+
- Asset amounts or liability amounts
|
|
162
|
+
- Wallet addresses beyond the org commitment
|
|
163
|
+
- Asset types or portfolio composition
|
|
164
|
+
- Any data that could reveal financial strategy
|
|
48
165
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
| network | `"testnet"` \| `"mainnet"` | `"testnet"` | Aleo network |
|
|
52
|
-
| rpcUrl | `string` | Aleo testnet RPC | Custom RPC endpoint |
|
|
53
|
-
| programId | `string` | `"veritaszk.aleo"` | Contract program ID |
|
|
166
|
+
This is guaranteed by the underlying Leo contracts — the data does not
|
|
167
|
+
exist in any queryable public state on Aleo.
|
|
54
168
|
|
|
55
|
-
|
|
169
|
+
## Deployed Programs
|
|
56
170
|
|
|
57
|
-
|
|
|
58
|
-
|
|
59
|
-
|
|
|
60
|
-
|
|
|
61
|
-
|
|
|
62
|
-
| assetCount | number | Number of asset categories declared |
|
|
63
|
-
| liabilityCount | number | Number of liability categories declared |
|
|
64
|
-
| verificationCount | number | Times this proof has been verified |
|
|
65
|
-
| lastChecked | Date | When this query was made |
|
|
171
|
+
| Program | Explorer |
|
|
172
|
+
|---------|----------|
|
|
173
|
+
| `veritaszk_registry.aleo` | [Explorer](https://explorer.aleo.org/program/veritaszk_registry.aleo) |
|
|
174
|
+
| `veritaszk_core.aleo` | [Explorer](https://explorer.aleo.org/program/veritaszk_core.aleo) |
|
|
175
|
+
| `veritaszk_audit.aleo` | [Explorer](https://explorer.aleo.org/program/veritaszk_audit.aleo) |
|
|
66
176
|
|
|
67
|
-
|
|
177
|
+
## Related Packages
|
|
68
178
|
|
|
69
|
-
|
|
179
|
+
- [veritaszk-mcp](https://www.npmjs.com/package/veritaszk-mcp) — MCP server for AI agent integration (Claude Desktop)
|
|
180
|
+
- [veritaszk-cli](https://www.npmjs.com/package/veritaszk-cli) — Terminal queries for solvency proofs
|
|
70
181
|
|
|
71
182
|
## Links
|
|
72
183
|
|
|
73
|
-
- [Live
|
|
184
|
+
- [Live Dashboard](https://veritaszk.vercel.app)
|
|
74
185
|
- [GitHub](https://github.com/Vinaystwt/veritaszk)
|
|
75
|
-
- [Aleo Explorer](https://explorer.aleo.org)
|
|
186
|
+
- [Aleo Explorer](https://explorer.aleo.org/program/veritaszk_core.aleo)
|
|
187
|
+
- [Documentation](https://veritaszk.vercel.app/docs)
|
|
76
188
|
|
|
77
|
-
Built on
|
|
189
|
+
Built on Aleo — privacy by default.
|
package/dist/index.d.ts
CHANGED
|
@@ -31,3 +31,16 @@ export declare function getAuditTrail(orgCommitment: string): Promise<AuditEvent
|
|
|
31
31
|
export declare function isRegistered(orgCommitment: string): Promise<boolean>;
|
|
32
32
|
export declare function getVerificationCount(orgCommitment: string): Promise<number>;
|
|
33
33
|
export declare function isProofExpired(orgCommitment: string): Promise<boolean>;
|
|
34
|
+
export interface ProofStatus {
|
|
35
|
+
commitment: string;
|
|
36
|
+
isSolvent: boolean;
|
|
37
|
+
proofStatus: number;
|
|
38
|
+
timestamp: number;
|
|
39
|
+
expiry: number;
|
|
40
|
+
isExpired: boolean;
|
|
41
|
+
verificationCount: number;
|
|
42
|
+
tier: number;
|
|
43
|
+
}
|
|
44
|
+
export declare function batchVerifyFromIndexer(commitments: string[], indexerUrl: string): Promise<(ProofStatus | null)[]>;
|
|
45
|
+
export declare function watchProof(commitment: string, callback: (status: ProofStatus) => void, indexerUrl: string, intervalMs?: number): () => void;
|
|
46
|
+
export declare function isProofExpiredFromIndexer(commitment: string, indexerUrl: string): Promise<boolean>;
|
package/dist/index.js
CHANGED
|
@@ -7,6 +7,9 @@ exports.getAuditTrail = getAuditTrail;
|
|
|
7
7
|
exports.isRegistered = isRegistered;
|
|
8
8
|
exports.getVerificationCount = getVerificationCount;
|
|
9
9
|
exports.isProofExpired = isProofExpired;
|
|
10
|
+
exports.batchVerifyFromIndexer = batchVerifyFromIndexer;
|
|
11
|
+
exports.watchProof = watchProof;
|
|
12
|
+
exports.isProofExpiredFromIndexer = isProofExpiredFromIndexer;
|
|
10
13
|
const EXPLORER = 'https://api.explorer.provable.com/v1/testnet';
|
|
11
14
|
exports.PROGRAMS = {
|
|
12
15
|
REGISTRY: 'veritaszk_registry.aleo',
|
|
@@ -103,3 +106,45 @@ async function isProofExpired(orgCommitment) {
|
|
|
103
106
|
return false;
|
|
104
107
|
return expiryBlock > 0 && ts > expiryBlock;
|
|
105
108
|
}
|
|
109
|
+
async function batchVerifyFromIndexer(commitments, indexerUrl) {
|
|
110
|
+
const res = await fetch(`${indexerUrl}/api/proofs`);
|
|
111
|
+
if (!res.ok)
|
|
112
|
+
throw new Error(`Indexer returned ${res.status}`);
|
|
113
|
+
const all = await res.json();
|
|
114
|
+
return commitments.map(c => {
|
|
115
|
+
const found = all.find(p => p.commitment === c);
|
|
116
|
+
return found ?? null;
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
function watchProof(commitment, callback, indexerUrl, intervalMs = 30000) {
|
|
120
|
+
let prev = null;
|
|
121
|
+
let stopped = false;
|
|
122
|
+
const poll = async () => {
|
|
123
|
+
if (stopped)
|
|
124
|
+
return;
|
|
125
|
+
try {
|
|
126
|
+
const res = await fetch(`${indexerUrl}/api/proofs/${commitment}`);
|
|
127
|
+
if (!res.ok)
|
|
128
|
+
return;
|
|
129
|
+
const status = await res.json();
|
|
130
|
+
const key = JSON.stringify(status);
|
|
131
|
+
if (prev !== null && key !== prev)
|
|
132
|
+
callback(status);
|
|
133
|
+
prev = key;
|
|
134
|
+
}
|
|
135
|
+
catch {
|
|
136
|
+
// silently ignore network errors
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
// Do an immediate poll to seed prev, then start interval
|
|
140
|
+
poll();
|
|
141
|
+
const id = setInterval(poll, intervalMs);
|
|
142
|
+
return () => { stopped = true; clearInterval(id); };
|
|
143
|
+
}
|
|
144
|
+
async function isProofExpiredFromIndexer(commitment, indexerUrl) {
|
|
145
|
+
const res = await fetch(`${indexerUrl}/api/proofs/${commitment}`);
|
|
146
|
+
if (!res.ok)
|
|
147
|
+
return false;
|
|
148
|
+
const status = await res.json();
|
|
149
|
+
return status.isExpired || status.proofStatus === 2;
|
|
150
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "veritaszk-sdk",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "SDK for VeritasZK zero-knowledge solvency proofs on Aleo",
|
|
3
|
+
"version": "0.3.0",
|
|
4
|
+
"description": "TypeScript SDK for VeritasZK — query zero-knowledge solvency proofs on Aleo. Verify that organizations prove assets exceed liabilities without any private financial data being revealed. Includes React hooks, batch verification, and webhook support.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"files": [
|
|
@@ -16,11 +16,24 @@
|
|
|
16
16
|
"keywords": [
|
|
17
17
|
"aleo",
|
|
18
18
|
"zero-knowledge",
|
|
19
|
-
"solvency",
|
|
20
19
|
"zk",
|
|
21
|
-
"
|
|
20
|
+
"solvency",
|
|
21
|
+
"proof-of-reserves",
|
|
22
|
+
"privacy",
|
|
23
|
+
"blockchain",
|
|
24
|
+
"leo",
|
|
25
|
+
"veritaszk"
|
|
22
26
|
],
|
|
27
|
+
"author": "Vinay Sharma",
|
|
23
28
|
"license": "MIT",
|
|
29
|
+
"homepage": "https://veritaszk.vercel.app",
|
|
30
|
+
"repository": {
|
|
31
|
+
"type": "git",
|
|
32
|
+
"url": "https://github.com/Vinaystwt/veritaszk"
|
|
33
|
+
},
|
|
34
|
+
"bugs": {
|
|
35
|
+
"url": "https://github.com/Vinaystwt/veritaszk/issues"
|
|
36
|
+
},
|
|
24
37
|
"devDependencies": {
|
|
25
38
|
"@types/jest": "^29.0.0",
|
|
26
39
|
"@types/node": "^20.0.0",
|
|
@@ -28,5 +41,8 @@
|
|
|
28
41
|
"jest": "^29.0.0",
|
|
29
42
|
"ts-jest": "^29.0.0",
|
|
30
43
|
"typescript": "^5.4.0"
|
|
44
|
+
},
|
|
45
|
+
"peerDependencies": {
|
|
46
|
+
"react": ">=18.0.0"
|
|
31
47
|
}
|
|
32
48
|
}
|