Zero-code AI x ZK middleware for verifiable dApps
npm install zypher-sdkrunZypher(prompt)
--expectedHash & --expectedSigner
bash
pnpm install
`
You must compile your circom circuit first:
`bash
cd src/middleware/zk/circuits
circom prompt_hash.circom --r1cs --wasm --sym -o build -l ../../../../circomlib/circuits
`
โจ Quick Usage (SDK)
`typescript
import { runZypher } from 'zypher-sdk'
const result = await runZypher({
prompt: "What is uuu in one sentence?",
config: {
apiKey: 'YOUR_API_KEY',
network: 'polygon',
agent: 'ollama', // or 'openai'
debug: true,
middleware: {
proofOfPrompt: true,
proofOfInference: true
}
}
})
`
$3
1. Hash the prompt using Poseidon
2. Generate ZK witness & proof (Groth16)
3. Auto-sign with the user's wallet
4. Export session as verifiable JSON
๐ค Example Output
`json
{
"prompt": "What is uuu in one sentence?",
"response": "In music, 'uuu' represents ...",
"stamp": "0xzk_abc123",
"promptHash": "19201350...",
"zkProof": {
"proof": { ... },
"publicSignals": []
},
"signature": "0x...",
"signedBy": "0xYourWalletAddress",
"success": true
}
`
Exported to /proofs/session_.
๐งช Verifying Sessions
`bash
pnpm verify proofs/session_1752460000000.json
`
With optional checks:
`bash
pnpm verify proofs/session_1752460000000.json \
--expectedHash \
--expectedSigner 0xYourWalletAddress
`
๐ ๏ธ Circuit: prompt_hash.circom
`circom
signal input prompt;
signal input promptHash;
component hasher = Poseidon(1);
hasher.inputs[0] <== prompt;
hasher.out === promptHash;
`
Located at src/middleware/zk/circuits.
๐ Folder Structure
`
โโโ src/
โ โโโ cli/ # Verifier CLI
โ โโโ core/ # init, pipeline, export logic
โ โโโ middleware/zk/ # Circuits, wasm, r1cs
โ โโโ utils/ # Signature, file, hash
โโโ proofs/ # Exported sessions
โโโ circomlib/ # External circuits
โโโ dev.ts # Sample test runner
โโโ README.md
``