Zero-Knowledge Swiss Knife: Python library for prototyping composable zero-knowledge proofs in the discrete-log setting.
Let’s say Peggy commits to a secret bit and wants to prove to Victor in zero knowledge that she knows this bit—that is, without revealing it. In Camenisch-Stadler notation, we can write:
To implement this zero-knowledge proof, Peggy will run:
from zksk import Secret, DLRep
from zksk import utils
# Setup: Peggy and Victor agree on two group generators.
G, H = utils.make_generators(num=2, seed=42)
# Setup: generate a secret randomizer.
r = Secret(utils.get_random_num(bits=128))
# This is Peggy's secret bit.
top_secret_bit = 1
# A Pedersen commitment to the secret bit.
C = top_secret_bit * G + r.value * H
# Peggy's definition of the proof statement, and proof generation.
# (The first or-clause corresponds to the secret value 0, and the second to the value 1. Because
# the real value of the bit is 1, the clause that corresponds to zero is marked as simulated.)
stmt = DLRep(C, r * H, simulated=True) | DLRep(C - G, r * H)
zk_proof = stmt.prove()
Victor will receive the commitment C and zk_proof from Peggy, and run this to verify the proof:
from zksk import Secret, DLRep
# Setup: get the agreed group generators.
G, H = utils.make_generators(num=2, seed=42)
# Setup: define a randomizer with an unknown value.
r = Secret()
stmt = DLRep(C, r * H) | DLRep(C - G, r * H)
assert stmt.verify(zk_proof)
Victor is now convinced that Peggy knows the committed bit.
Documentation and materials
Docs |
|
Academic paper |
https://arxiv.org/abs/1911.02459 — theoretical details |
> Warning. Please don’t use this software for anything mission-critical. It is designed for quick protyping of privacy-enhancing technologies, not production use.
Getting started
You need to have Python 3.6 or higher to use zksk. The library is tested and supported on Debian-based systems. Mac support is not guaranteed.
You can install zksk using pip:
pip install git+https://github.com/spring-epfl/zksk
To make sure everything is in order, you can run unit tests. For that, install the dev version of the package:
pip install "git+https://github.com/spring-epfl/zksk#egg=zksk[dev]"
Then, run the tests with pytest:
pytest
Contributing
See the contributing document.
Citing
If you use zksk in your research, please cite like this:
@inproceedings{LueksKFBT19,
author = {Wouter Lueks and
Bogdan Kulynych and
Jules Fasquelle and
Simon Le Bail{-}Collet and
Carmela Troncoso},
title = {zksk: {A} Library for Composable Zero-Knowledge Proofs},
booktitle = {Proceedings of the 18th {ACM} Workshop on Privacy in the Electronic
Society ({WPES@CCS})},
pages = {50--54},
year = {2019},
}
Metadata
Release files for zksk 0.0.2
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 |
|---|---|---|---|---|
| zksk-0.0.2.tar.gz | 30.5 kB | Without provenance | Details for zksk-0.0.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| zksk-0.0.2-py3-none-any.whl | Python 3 | none | any | Details for zksk-0.0.2-py3-none-any.whl |
Total release size: 65.7 kB
Release files / zksk-0.0.2.tar.gz
| Download URL | zksk-0.0.2.tar.gz |
|---|---|
| Size | 30.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a2bc222d384c1c4583308f5f246e83d4eaf7a54cdc6476d7f6764128cfac2ef9
|
|
BLAKE2b-256 checksum How to use checksums |
d14348ae02e9074202aad48d33fa79c37a97ee754dcf99d5131b6f4aa736991f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.4.2 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.28.1 CPython/3.7.3
|
Release files / zksk-0.0.2-py3-none-any.whl
| Download URL | zksk-0.0.2-py3-none-any.whl |
|---|---|
| Size | 35.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4c519eed8664a2454bd212f14180e7210eb3c64949439dc519e43fc6766204ec
|
|
BLAKE2b-256 checksum How to use checksums |
28b2660a3b2e5cf34f813be5606c8bcd1d18680b107912bfb495a5c40c5f1ccb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.4.2 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.28.1 CPython/3.7.3
|
Security for zksk 0.0.2
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.