zkrune-sdk
v1.2.1
Published
JavaScript SDK for zkRune - Generate zero-knowledge proofs with Zcash's Groth16 technology
Maintainers
Readme
zkrune-sdk
JavaScript SDK for zkRune - Generate zero-knowledge proofs in your app.
Installation
npm install zkrune-sdk
# or
yarn add zkrune-sdkQuick Start
import { generateProof, templates } from 'zkrune-sdk';
// Generate an age verification proof
const result = await generateProof({
templateId: templates.AGE_VERIFICATION,
inputs: {
birthYear: '1995',
currentYear: '2024',
minimumAge: '18'
}
});
if (result.success) {
console.log('Proof generated!', result.proof);
console.log('Time taken:', result.timing, 'ms');
}Features
- Browser & Node.js compatible
- Real Groth16 zk-SNARKs
- 13 ready-to-use templates
- Client-side proof generation
- TypeScript support
- Zero dependencies (except snarkjs)
- Zcash-powered privacy
Available Templates
Identity & Access
age-verification- Prove age without revealing exact datecredential-proof- Prove valid credentials without revealing datamembership-proof- Prove membership without identity
Financial
balance-proof- Prove minimum balance without amounttoken-swap- Prove sufficient balance for swap anonymouslyrange-proof- Prove value in range without exact number
Governance
private-voting- Vote anonymously with proofquadratic-voting- Fair governance voting with quadratic weighting
Cryptography & Advanced
hash-preimage- Prove you know secret X where hash(X) = Ysignature-verification- Verify signatures without revealing private keypatience-proof- Prove you waited a time periodnft-ownership- Prove NFT ownership without revealing which NFTanonymous-reputation- Prove reputation score exceeds threshold
API Reference
generateProof(options)
Generates a zero-knowledge proof.
Parameters:
templateId(string) - Template identifierinputs(object) - Input values for the circuitcircuitPath(string, optional) - Custom circuit path
Returns: Promise<ZKProofResult>
verifyProof(params)
Verifies a zero-knowledge proof.
Parameters:
proof- The Groth16 proof objectpublicSignals- Public signals arrayverificationKey- Verification key object
Returns: Promise<boolean>
Examples
Balance Proof
import { generateProof, templates } from 'zkrune-sdk';
const proof = await generateProof({
templateId: templates.BALANCE_PROOF,
inputs: {
balance: '10000',
minimumBalance: '5000'
}
});Membership Proof
const proof = await generateProof({
templateId: templates.MEMBERSHIP_PROOF,
inputs: {
memberId: '123456',
groupHash: '999'
}
});NFT Ownership Proof
const proof = await generateProof({
templateId: templates.NFT_OWNERSHIP,
inputs: {
nftId: '42',
collectionId: '100'
}
});Quadratic Voting
const proof = await generateProof({
templateId: templates.QUADRATIC_VOTING,
inputs: {
voteCount: '5',
credits: '25'
}
});Links
- Website: zkrune.com
- GitHub: louisstein94/zkrune
- Twitter: @rune_zk
License
MIT
