zkpy
A Python library that allows for easy compiling/proving/verifying of zk circuits.
Overview
ZKPy is a Python library that allows for easy compiling/proving/verifying of zk circuits. It is implemented as a wrapper of Circom or SnarkJS, allowing developers to incorporate zero knowledge proofs into Python projects.
Features:
The ptau module allows users to:
- Create and contribute to a powers of tau ceremony
- Apply beacon to a powers of tau ceremony
- Perform phase 2 of a powers of tau ceremony (for groth16)
- Export and import contributions from 3rd party software
- Verify a powers of tau file
The circuits module allows users to:
- Compile circom circuits
- Generate r1cs, wasm, etc
- Generate witness from input file
- Prove circuits with support for three proving schemes (groth16, PLONK, FFLONK)
- Export verification keys
- Verify proofs with support for three proving schemes (groth16, PLONK, FFLONK)
Dependencies
zkpy requires Circom and snarkjs. You can find installation instructions here.
Installation
The recommended way to install zkpy is through pip.
pip install zkpy
Usage
Powers of Tau
Here is an example use case walking through a powers of tau ceremony:
from zkpy.ptau import PTau
ptau = PTau()
ptau.start()
ptau.contribute()
ptau.beacon()
ptau.prep_phase2()
The PTau object maintains an underlying powers of tau file throughout these operations. You can also import an existing ptau file:
ptau = PTau(ptau_file="ptau_file.ptau")
At any stage, we can verify the powers of tau file is valid:
ptau.verify()
Circuit
This class uses a circuit defined in a circom file to generate and verify zk proofs.
Here is an example scenario walking through compiling a circuit, generating witnesses, generating a proof, and verifying the proof:
from zkpy.circuit import Circuit, GROTH, PLONK, FFLONK
circuit = Circuit("./circuit.circom")
circuit.compile()
circuit.get_info()
circuit.print_constraints()
circuit.gen_witness("./example_circuits/input.json")
circuit.setup(PLONK, ptau)
circuit.prove(PLONK)
circuit.export_vkey()
circuit.verify(PLONK, vkey_file="vkey.json", public_file="public.json", proof_file="proof.json")
Contributing
Help is always appreciated! Feel free to open an issue if you find a problem, or open a pull request if you've solved an issue.
See more at CONTRIBUTING.md
Metadata
Release files for zkpy 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| zkpy-0.2.0.tar.gz | 13.4 MB | Without provenance | Details for zkpy-0.2.0.tar.gz |
Release files / zkpy-0.2.0.tar.gz
| Download URL | zkpy-0.2.0.tar.gz |
|---|---|
| Size | 13.4 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
13f937bd5e74dd6a04c3cd9bb90b10c8ba15216b1865980cc9ebfeafd15c5553
|
|
BLAKE2b-256 checksum How to use checksums |
545f99bb70aece717fc478aba4c63fb3dc3a0173b2a958b92f2a4812bd078569
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.13
|
Security for zkpy 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.