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
Markdown
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);
})();
```
---
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).
---
* 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.