Skip to main content

A python client library to easily generate arguments for zero-knowledge proofs (ZKPs)

Project description

ZnaKes

python-version codecov License: LGPL v3 PRs Welcome FLAKE8

A one-stop client library which facilitates the creation of arguments for zero-knowledge Proofs. ZnaKes provide an easy interface to generate zk-friendly crypto primitives necessary in efficient circuits developed with popular tools such as ZoKrates, Circom, Noir and so on...

:warning: This is a proof-of-concept implementation. It has not been tested for production.

This repository code is primarily based from ZoKrates Pycrypto for the zkSNARKs toolbox ZoKrates. Nonetheless, we plan of adding more primitives support by other tools as well. Some of these primitives are:

  • Poseidon, mimc and pedersen hashes.
  • EdDSA signatures for multiple curves (BN254, BLS12_381...)
  • ... and more!

Install

Make sure you are running a python 3 runtime.

pip install ZnaKes

Example

For more examples of the package functionalities, take a look in the tests folder.

Create and verify Eddsa signature

Let's create a simple demo, called demo.py, in which we sign a hashed message with the BabyJubJub curve:

import hashlib

from znakes.curves import BabyJubJub
from znakes.eddsa import PrivateKey, PublicKey

if __name__ == "__main__":

    raw_msg = "This is my secret message"
    msg = hashlib.sha512(raw_msg.encode("utf-8")).digest()

    sk = PrivateKey.from_rand(curve=BabyJubJub)
    sig = sk.sign(msg)

    pk = PublicKey.from_private(sk)
    is_verified = pk.verify(sig, msg)
    print(is_verified)

Contributing

We happily welcome contributions. You can either pick an existing issue or create a new issue. Before that make sure you have read our CODE_OF_CONDUCT and CONTRIBUTION GUIDELINES

Please note that your submited contributions shall be licensed as below, without any additional terms or conditions.

Setup

First install the development packages via pip install -r requirements-dev.txt.

In addition this repo uses the python package pre-commit to make sure the correct formatting (black & flake) is applied and all tests pass. You can install it via pip install pre-commit.

Then you just need to call pre-commit install.

Acknowledgements

  • ZoKrates dev tem for providing a great starting point for this project and for the awesome tool ZoKrates.
  • jesse squires for the great CONTRIBUTING.md and CODE_OF_CONDUCT guidelines.
  • Josee9988 for the amazing issue templates.

License

This repo is released under the GNU Lesser General Public License v3.

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

znakes-0.1.1.tar.gz (96.6 kB view details)

Uploaded Source

Built Distribution

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

znakes-0.1.1-py3-none-any.whl (21.6 kB view details)

Uploaded Python 3

File details

Details for the file znakes-0.1.1.tar.gz.

File metadata

  • Download URL: znakes-0.1.1.tar.gz
  • Upload date:
  • Size: 96.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.8

File hashes

Hashes for znakes-0.1.1.tar.gz
Algorithm Hash digest
SHA256 5b6a011fa58995a6b9b2825e91247d59ea30c8e861709ae529f3be10569364bb
MD5 7a23cd39ed5fff6d12c8ac99d4d7f006
BLAKE2b-256 44e88607194e07cb2b3b4d7f5290c6cb88cd8ed2b07e909f8f5c3a9506a11f09

See more details on using hashes here.

File details

Details for the file znakes-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: znakes-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 21.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.8

File hashes

Hashes for znakes-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 251e22861d552efc6591b472faae949b95c0b9b1513fc71f78e3d1f4d18f8c4e
MD5 3a6695f45fefff4fe0127f9bf09139c6
BLAKE2b-256 c902ed0674d431b8a3a042f9643fdb46ae1cb4db31d3a42f6a1a976c17200abd

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