Skip to main content

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():
    ## 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

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.2.tar.gz (17.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

python_snarks-0.0.2-py3-none-any.whl (34.1 kB view details)

Uploaded Python 3

File details

Details for the file python-snarks-0.0.2.tar.gz.

File metadata

  • Download URL: python-snarks-0.0.2.tar.gz
  • Upload date:
  • Size: 17.3 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for python-snarks-0.0.2.tar.gz
Algorithm Hash digest
SHA256 3c8103867fbbfa8257fc006dc8365a270a695ae49a9e9b4be5404168f295cf31
MD5 2e2d30caf8763d3e11c7e09d102ef438
BLAKE2b-256 8d8817b9dfc1bd907b464ec7783e70b741fe0c81b82dd8811399994daf2ffed8

See more details on using hashes here.

File details

Details for the file python_snarks-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: python_snarks-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 34.1 kB
  • Tags: Python 3
  • Uploaded using 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

File hashes

Hashes for python_snarks-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 0df1e41fe20815dd7915917b9f54152806e60e77cb5c4ee4c74959861084af5b
MD5 8051817d019b4442fbf0df9eaac9b408
BLAKE2b-256 7ce14695472bc0f98cc016ec9489feb56711837327b2693b09e874308ae2d319

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page