UNPKG

zk-threshold-proof

Version:

A lightweight SDK to generate and verify ZK proofs that assert a private value is greater than or equal to a threshold.

63 lines (44 loc) โ€ข 1.52 kB
# ๐Ÿงช Usage Examples ## Example 1 โ€” Generate and Verify Proof from Config File This is the easiest way to use the SDK: create a `config.json` and pass it to the `generateProof()` function. ```json title="config.json" { "circuitPath": "./circuits/ageVerifier/ageVerifier.circom", "input": { "birthDate": 631152000, "minAge": 18, "currentDate": 1718169600 } } ``` > Tip: You can find a working version of this file in `circuits/ageVerifier/config.json`. ```js title="generate.js" const { generateProof, verifyProof } = require("zk-threshold-proof"); (async () => { const proof = await generateProof("./circuits/ageVerifier/config.json"); const isValid = await verifyProof(proof); console.log("โœ… Valid Proof?", isValid); })(); ``` --- ## Example 2 โ€” Use with Adapter (e.g. zkVerify) You can also verify proofs using a specific blockchain adapter: ```js const { zkVerifyAdapter } = require("zk-threshold-proof/src/adapters"); (async () => { const proof = await generateProof("./circuits/ageVerifier/config.json"); const result = await zkVerifyAdapter.verify(proof, "0xVerifierContractAddress"); console.log("zkVerify result:", result); })(); ``` > Adapters available: > > * `zkVerifyAdapter` > * `polygonIdAdapter` > * `semaphoreAdapter` More details in the [Adapters Section](./adapters). --- ## Notes * All proof generation happens locally. * You can plug this into any ZK-enabled verifier or blockchain platform. * Works out-of-the-box with Circom-compatible circuits.