python_snarks
Project description
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():
gr = Groth(os.path.dirname(os.path.realpath(__file__)) + "/circuit/circuit.r1cs")
gr.calc_polynomials()
at_list = gr.calc_values_at_T()
gr.calc_encrypted_values_at_T()
# Calculate witness
wasm_path = os.path.dirname(os.path.realpath(__file__)) + "/circuit/circuit.wasm"
c = Calculator(wasm_path)
witness = c.calculate({"a": 33, "b": 34})
# Generate proof
proof, publicSignals = gen_proof(gr.setup["vk_proof"], witness)
print("#"*80)
print(proof)
print("#"*80)
print(publicSignals)
print("#"*80)
result = is_valid(gr.setup["vk_verifier"], proof, publicSignals)
print(result)
assert result == True
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
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
python-snarks-0.0.1.tar.gz
(25.4 kB
view hashes)
Built Distribution
Close
Hashes for python_snarks-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5b1816bc0f926d3a22a57d49068d25da20a520631b0b0b6854dd3b1520aa0078 |
|
MD5 | 006430a9ebcabbcd245b766ed702302b |
|
BLAKE2b-256 | 6c96e2ae29d78198da62ae6692d051435ef37583dfbe3d3055f92aad8b16c727 |