Zero-Knowledge Swiss Knife: Python library for prototyping composable zero-knowledge proofs.
Project description
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},
}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file zksk-fork-0.0.31.tar.gz
.
File metadata
- Download URL: zksk-fork-0.0.31.tar.gz
- Upload date:
- Size: 35.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.7.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7bcb81bc64fcea640df57b3a27612c3d3ac7bc6884789adec1ec4476e243017d |
|
MD5 | 8b41dfa9b3b7e118f11757f12f400940 |
|
BLAKE2b-256 | 1648310a5a22c5a893eaf387bb536e3f00cf05dd389210795503659e7b939979 |
File details
Details for the file zksk_fork-0.0.31-py3-none-any.whl
.
File metadata
- Download URL: zksk_fork-0.0.31-py3-none-any.whl
- Upload date:
- Size: 35.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.7.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1f8292374c340c5a57ac5bf59b00b2c3437748fcb9d3c2438506775649124543 |
|
MD5 | 0edbc4c54dd678dab746d47d45837fe6 |
|
BLAKE2b-256 | b9022d911ea25256e03c254d0c50b0f0359fe17bac4f1178ac5c1c76c178262c |