veritaszk-cli 0.1.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/dist/index.js ADDED
@@ -0,0 +1,131 @@
1
+ #!/usr/bin/env node
2
+ import { program } from 'commander';
3
+ const EXPLORER = 'https://api.explorer.provable.com/v1/testnet';
4
+ const CORE = 'veritaszk_core.aleo';
5
+ const AUDIT = 'veritaszk_audit.aleo';
6
+ async function q(prog, mapping, key) {
7
+ const res = await fetch(`${EXPLORER}/program/${prog}/mapping/${mapping}/${key}`);
8
+ if (!res.ok)
9
+ return null;
10
+ try {
11
+ return await res.json();
12
+ }
13
+ catch {
14
+ return null;
15
+ }
16
+ }
17
+ function parseU32(val) {
18
+ if (!val)
19
+ return null;
20
+ return Number(String(val).replace('u32', '').trim());
21
+ }
22
+ program
23
+ .name('veritaszk')
24
+ .description('Query VeritasZK zero-knowledge solvency proofs')
25
+ .version('0.1.0');
26
+ program
27
+ .command('verify <commitment>')
28
+ .description('Check solvency status of an organization')
29
+ .action(async (commitment) => {
30
+ console.log('Querying Aleo testnet...\n');
31
+ const [solvent, timestamp, expiry, count, threshold] = await Promise.all([
32
+ q(CORE, 'solvency_proofs', commitment),
33
+ q(CORE, 'proof_timestamps', commitment),
34
+ q(CORE, 'proof_expiry', commitment),
35
+ q(CORE, 'verification_counts', commitment),
36
+ q(CORE, 'threshold_proofs', commitment),
37
+ ]);
38
+ const isSolvent = solvent === true || solvent === 'true';
39
+ const thresholdLabels = {
40
+ 0: 'not set', 1: 'basic', 2: '100% buffer', 3: '200% buffer'
41
+ };
42
+ const tLevel = threshold
43
+ ? Number(String(threshold).replace('u8', '')) : 0;
44
+ console.log('VeritasZK Solvency Check');
45
+ console.log('─'.repeat(44));
46
+ console.log(`Organization: ${commitment}`);
47
+ console.log(`Status: ${isSolvent ? '✓ SOLVENT' : '✗ NOT SOLVENT'}`);
48
+ console.log(`Proven at: block ${parseU32(timestamp) ?? 'unknown'}`);
49
+ console.log(`Expires at: block ${parseU32(expiry) ?? 'no expiry'}`);
50
+ console.log(`Verified by: ${parseU32(count) ?? 0} parties`);
51
+ console.log(`Threshold: ${thresholdLabels[tLevel] ?? 'unknown'}`);
52
+ console.log('─'.repeat(44));
53
+ console.log('Network: Aleo Testnet | veritaszk_core.aleo');
54
+ });
55
+ program
56
+ .command('list')
57
+ .description('Show protocol info and how to find verified orgs')
58
+ .option('-l, --limit <n>', 'Max results', '10')
59
+ .action(() => {
60
+ console.log('VeritasZK — Zero-Knowledge Solvency Protocol');
61
+ console.log('─'.repeat(44));
62
+ console.log('Dashboard: https://veritaszk.vercel.app');
63
+ console.log('Registry: veritaszk_registry.aleo');
64
+ console.log('Core: veritaszk_core.aleo');
65
+ console.log('Audit: veritaszk_audit.aleo');
66
+ console.log('npm SDK: npm install veritaszk-sdk');
67
+ console.log('MCP: npx veritaszk-mcp');
68
+ console.log('');
69
+ console.log('Use: veritaszk verify <commitment> to check any org');
70
+ });
71
+ program
72
+ .command('proof <commitment>')
73
+ .description('Get full proof metadata for an organization')
74
+ .option('-f, --format <fmt>', 'Output format: json or table', 'table')
75
+ .action(async (commitment, opts) => {
76
+ const [solvent, timestamp, expiry, count, threshold, auditCount, lastBlock] = await Promise.all([
77
+ q(CORE, 'solvency_proofs', commitment),
78
+ q(CORE, 'proof_timestamps', commitment),
79
+ q(CORE, 'proof_expiry', commitment),
80
+ q(CORE, 'verification_counts', commitment),
81
+ q(CORE, 'threshold_proofs', commitment),
82
+ q(AUDIT, 'event_count', commitment),
83
+ q(AUDIT, 'last_proof_block', commitment),
84
+ ]);
85
+ const data = {
86
+ org_commitment: commitment,
87
+ is_solvent: solvent === true || solvent === 'true',
88
+ proof_timestamp_block: parseU32(timestamp),
89
+ expiry_block: parseU32(expiry),
90
+ verification_count: parseU32(count) ?? 0,
91
+ threshold_level: threshold
92
+ ? Number(String(threshold).replace('u8', '')) : 0,
93
+ audit_event_count: parseU32(auditCount) ?? 0,
94
+ last_proof_block: parseU32(lastBlock),
95
+ network: 'testnet',
96
+ };
97
+ if (opts.format === 'json') {
98
+ console.log(JSON.stringify(data, null, 2));
99
+ }
100
+ else {
101
+ Object.entries(data).forEach(([k, v]) => console.log(`${k.padEnd(26)} ${v}`));
102
+ }
103
+ });
104
+ program
105
+ .command('watch <commitment>')
106
+ .description('Poll solvency status every 30 seconds')
107
+ .action(async (commitment) => {
108
+ console.log(`Watching: ${commitment}`);
109
+ console.log('Polling every 30s. Ctrl+C to stop.\n');
110
+ let lastSolvent = null;
111
+ let lastCount = 0;
112
+ const poll = async () => {
113
+ const [solvent, count] = await Promise.all([
114
+ q(CORE, 'solvency_proofs', commitment),
115
+ q(CORE, 'verification_counts', commitment),
116
+ ]);
117
+ const isSolvent = solvent === true || solvent === 'true';
118
+ const verCount = parseU32(count) ?? 0;
119
+ const changed = lastSolvent !== null &&
120
+ (lastSolvent !== isSolvent || lastCount !== verCount);
121
+ const ts = new Date().toISOString();
122
+ console.log(`[${ts}] ${isSolvent ? '✓ SOLVENT' : '✗ NOT SOLVENT'}` +
123
+ ` | verifications: ${verCount}` +
124
+ (changed ? ' ← CHANGED' : ''));
125
+ lastSolvent = isSolvent;
126
+ lastCount = verCount;
127
+ };
128
+ await poll();
129
+ setInterval(poll, 30000);
130
+ });
131
+ program.parse();
package/package.json ADDED
@@ -0,0 +1,19 @@
1
+ {
2
+ "name": "veritaszk-cli",
3
+ "version": "0.1.0",
4
+ "description": "CLI for querying VeritasZK zero-knowledge solvency proofs",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "bin": { "veritaszk": "dist/index.js" },
8
+ "scripts": {
9
+ "build": "tsc",
10
+ "prepublishOnly": "npm run build"
11
+ },
12
+ "keywords": ["cli", "aleo", "zero-knowledge", "solvency"],
13
+ "license": "MIT",
14
+ "dependencies": { "commander": "^12.0.0" },
15
+ "devDependencies": {
16
+ "typescript": "^5.4.0",
17
+ "@types/node": "^20.0.0"
18
+ }
19
+ }
package/src/index.ts ADDED
@@ -0,0 +1,140 @@
1
+ #!/usr/bin/env node
2
+ import { program } from 'commander'
3
+
4
+ const EXPLORER = 'https://api.explorer.provable.com/v1/testnet'
5
+ const CORE = 'veritaszk_core.aleo'
6
+ const AUDIT = 'veritaszk_audit.aleo'
7
+
8
+ async function q(prog: string, mapping: string, key: string) {
9
+ const res = await fetch(
10
+ `${EXPLORER}/program/${prog}/mapping/${mapping}/${key}`
11
+ )
12
+ if (!res.ok) return null
13
+ try { return await res.json() } catch { return null }
14
+ }
15
+
16
+ function parseU32(val: any): number | null {
17
+ if (!val) return null
18
+ return Number(String(val).replace('u32', '').trim())
19
+ }
20
+
21
+ program
22
+ .name('veritaszk')
23
+ .description('Query VeritasZK zero-knowledge solvency proofs')
24
+ .version('0.1.0')
25
+
26
+ program
27
+ .command('verify <commitment>')
28
+ .description('Check solvency status of an organization')
29
+ .action(async (commitment: string) => {
30
+ console.log('Querying Aleo testnet...\n')
31
+ const [solvent, timestamp, expiry, count, threshold] =
32
+ await Promise.all([
33
+ q(CORE, 'solvency_proofs', commitment),
34
+ q(CORE, 'proof_timestamps', commitment),
35
+ q(CORE, 'proof_expiry', commitment),
36
+ q(CORE, 'verification_counts', commitment),
37
+ q(CORE, 'threshold_proofs', commitment),
38
+ ])
39
+ const isSolvent = solvent === true || solvent === 'true'
40
+ const thresholdLabels: Record<number, string> = {
41
+ 0: 'not set', 1: 'basic', 2: '100% buffer', 3: '200% buffer'
42
+ }
43
+ const tLevel = threshold
44
+ ? Number(String(threshold).replace('u8', '')) : 0
45
+ console.log('VeritasZK Solvency Check')
46
+ console.log('─'.repeat(44))
47
+ console.log(`Organization: ${commitment}`)
48
+ console.log(`Status: ${isSolvent ? '✓ SOLVENT' : '✗ NOT SOLVENT'}`)
49
+ console.log(`Proven at: block ${parseU32(timestamp) ?? 'unknown'}`)
50
+ console.log(`Expires at: block ${parseU32(expiry) ?? 'no expiry'}`)
51
+ console.log(`Verified by: ${parseU32(count) ?? 0} parties`)
52
+ console.log(`Threshold: ${thresholdLabels[tLevel] ?? 'unknown'}`)
53
+ console.log('─'.repeat(44))
54
+ console.log('Network: Aleo Testnet | veritaszk_core.aleo')
55
+ })
56
+
57
+ program
58
+ .command('list')
59
+ .description('Show protocol info and how to find verified orgs')
60
+ .option('-l, --limit <n>', 'Max results', '10')
61
+ .action(() => {
62
+ console.log('VeritasZK — Zero-Knowledge Solvency Protocol')
63
+ console.log('─'.repeat(44))
64
+ console.log('Dashboard: https://veritaszk.vercel.app')
65
+ console.log('Registry: veritaszk_registry.aleo')
66
+ console.log('Core: veritaszk_core.aleo')
67
+ console.log('Audit: veritaszk_audit.aleo')
68
+ console.log('npm SDK: npm install veritaszk-sdk')
69
+ console.log('MCP: npx veritaszk-mcp')
70
+ console.log('')
71
+ console.log('Use: veritaszk verify <commitment> to check any org')
72
+ })
73
+
74
+ program
75
+ .command('proof <commitment>')
76
+ .description('Get full proof metadata for an organization')
77
+ .option('-f, --format <fmt>', 'Output format: json or table', 'table')
78
+ .action(async (commitment: string, opts) => {
79
+ const [solvent, timestamp, expiry, count, threshold,
80
+ auditCount, lastBlock] = await Promise.all([
81
+ q(CORE, 'solvency_proofs', commitment),
82
+ q(CORE, 'proof_timestamps', commitment),
83
+ q(CORE, 'proof_expiry', commitment),
84
+ q(CORE, 'verification_counts', commitment),
85
+ q(CORE, 'threshold_proofs', commitment),
86
+ q(AUDIT, 'event_count', commitment),
87
+ q(AUDIT, 'last_proof_block', commitment),
88
+ ])
89
+ const data = {
90
+ org_commitment: commitment,
91
+ is_solvent: solvent === true || solvent === 'true',
92
+ proof_timestamp_block: parseU32(timestamp),
93
+ expiry_block: parseU32(expiry),
94
+ verification_count: parseU32(count) ?? 0,
95
+ threshold_level: threshold
96
+ ? Number(String(threshold).replace('u8', '')) : 0,
97
+ audit_event_count: parseU32(auditCount) ?? 0,
98
+ last_proof_block: parseU32(lastBlock),
99
+ network: 'testnet',
100
+ }
101
+ if (opts.format === 'json') {
102
+ console.log(JSON.stringify(data, null, 2))
103
+ } else {
104
+ Object.entries(data).forEach(([k, v]) =>
105
+ console.log(`${k.padEnd(26)} ${v}`)
106
+ )
107
+ }
108
+ })
109
+
110
+ program
111
+ .command('watch <commitment>')
112
+ .description('Poll solvency status every 30 seconds')
113
+ .action(async (commitment: string) => {
114
+ console.log(`Watching: ${commitment}`)
115
+ console.log('Polling every 30s. Ctrl+C to stop.\n')
116
+ let lastSolvent: boolean | null = null
117
+ let lastCount = 0
118
+ const poll = async () => {
119
+ const [solvent, count] = await Promise.all([
120
+ q(CORE, 'solvency_proofs', commitment),
121
+ q(CORE, 'verification_counts', commitment),
122
+ ])
123
+ const isSolvent = solvent === true || solvent === 'true'
124
+ const verCount = parseU32(count) ?? 0
125
+ const changed = lastSolvent !== null &&
126
+ (lastSolvent !== isSolvent || lastCount !== verCount)
127
+ const ts = new Date().toISOString()
128
+ console.log(
129
+ `[${ts}] ${isSolvent ? '✓ SOLVENT' : '✗ NOT SOLVENT'}` +
130
+ ` | verifications: ${verCount}` +
131
+ (changed ? ' ← CHANGED' : '')
132
+ )
133
+ lastSolvent = isSolvent
134
+ lastCount = verCount
135
+ }
136
+ await poll()
137
+ setInterval(poll, 30000)
138
+ })
139
+
140
+ program.parse()
package/tsconfig.json ADDED
@@ -0,0 +1,10 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "module": "Node16",
5
+ "moduleResolution": "Node16",
6
+ "outDir": "dist",
7
+ "strict": true
8
+ },
9
+ "include": ["src/**/*"]
10
+ }