python-snarks
This is a Python implementation of zkSNARK schemes. This library is based on snarkjs, and uses the output from circom.
For now, it is for research purpose, not implemented for product.
Install
$ pip install python-snarks
Usage
import os
from python_snarks import Groth, Calculator, gen_proof, is_valid
def test_groth():
## 1. setup zkp
print("1. setting up...")
gr = Groth(os.path.dirname(os.path.realpath(__file__)) + "/circuit/circuit.r1cs")
gr.setup_zk()
## 2. proving
print("2. proving...")
wasm_path = os.path.dirname(os.path.realpath(__file__)) + "/circuit/circuit.wasm"
c = Calculator(wasm_path)
witness = c.calculate({"a": 33, "b": 34})
proof, publicSignals = gen_proof(gr.setup["vk_proof"], witness)
print("#"*80)
print(proof)
print("#"*80)
print(publicSignals)
print("#"*80)
## 3. verifying
print("3. verifying...")
result = is_valid(gr.setup["vk_verifier"], proof, publicSignals)
print(result)
assert result == True
export solidity verifier
Groth class's export_solidity_verifier function creates solidity file. You can deploy it on ethereum network and use it as a verifier.
import os
from python_snarks import Groth, Calculator, gen_proof, is_valid
def test_groth():
## 1. setup zkp
print("1. setting up...")
gr = Groth(os.path.dirname(os.path.realpath(__file__)) + "/circuit/circuit.r1cs")
gr.setup_zk()
gr.export_solidity_verifier("verifier.sol")
verifying on contract
result = contract_instance.functions.verifyProof(
...proof and public signals...
).call()
Test
$ pytest tests/test_groth16.py
Supported platforms
The supported platforms currently support are set to the requirements of the wasmer-python.
TODO
- Compatibility with the latest snarkjs, circom
- Performance optimizing
Metadata
Release files for python-snarks 0.0.3
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 | |
|---|---|---|---|---|
| python-snarks-0.0.3.tar.gz | 18.3 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| python_snarks-0.0.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 53.6 kB
Release files / python-snarks-0.0.3.tar.gz
| Download URL | python-snarks-0.0.3.tar.gz |
|---|---|
| Size | 18.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f3963f4a3b228bba217d88befcebd68b81831c4bd4948573bd7028f89ba39ba1
|
|
BLAKE2b-256 checksum How to use checksums |
17f5af1db9e5299c8d90ad7fed7f3b9da3163c8d5b3aeca1efa2317b94521f1f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.5
|
Release files / python_snarks-0.0.3-py3-none-any.whl
| Download URL | python_snarks-0.0.3-py3-none-any.whl |
|---|---|
| Size | 35.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f7a33935e6379f22b66a4984f6392c96dac2484130bf48fedf8aa32c0724b1ec
|
|
BLAKE2b-256 checksum How to use checksums |
b2ac5cd2ceab6842394b837d84dfba49846a8046837aeee205320a398316b970
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.5
|
Security for python-snarks 0.0.3
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.