Skip to content

Commit 2537864

Browse files
committed
Merge branch 'release/0.6.0'
2 parents 3580ce4 + 3cee319 commit 2537864

File tree

17 files changed

+2662
-607
lines changed

17 files changed

+2662
-607
lines changed

Cargo.toml

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "zkp"
3-
version = "0.5.0"
3+
version = "0.6.0"
44
authors = ["Henry de Valence <hdevalence@hdevalence.ca>"]
55
license = "CC0-1.0"
66
repository = "https://github.com/hdevalence/zkp"
@@ -13,24 +13,26 @@ exclude = [
1313
]
1414

1515
[dependencies]
16-
sha2 = "0.8"
1716
merlin = "1"
1817
rand = "0.6"
1918
serde = "1.0"
2019
serde_derive = "1.0"
21-
22-
[dev-dependencies]
23-
bincode = "1"
20+
failure = "0.1.5"
21+
failure_derive = "0.1.5"
2422

2523
[dependencies.curve25519-dalek]
2624
features = ["serde", "nightly", "alloc"]
2725
version = "1"
28-
default-features = false
26+
27+
[dev-dependencies]
28+
bincode = "1"
29+
sha2 = "0.8"
2930

3031
[features]
3132
default = ["u64_backend"]
3233
u32_backend = ["curve25519-dalek/u32_backend"]
3334
u64_backend = ["curve25519-dalek/u64_backend"]
34-
avx2_backend = ["curve25519-dalek/avx2_backend"]
35+
simd_backend = ["curve25519-dalek/simd_backend"]
3536
nightly = ["curve25519-dalek/nightly"]
3637
bench = [ ]
38+
debug-transcript = ["merlin/debug-transcript"]

README.md

Lines changed: 92 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,103 @@
1-
# zkp
1+
# zkp: a toolkit for Schnorr proofs
22

3-
This crate has an experimental zero-knowledge proof compiler
4-
implemented using Rust macros.
3+
This crate has a toolkit for Schnorr-style zero-knowledge proofs,
4+
instantiated using the ristretto255 group.
55

6-
It provides a DSL resembling Camenisch-Stadler notation for proving
7-
statements about discrete logarithms in the Decaf group on
8-
Curve25519, as implemented in
9-
[`curve25519-dalek`](https://github.com/isislovecruft/curve25519-dalek).
10-
Note that both the Decaf implementation in `curve25519-dalek`, *as
11-
well as this library*, are currently **UNFINISHED, UNREVIEWED, AND
12-
EXPERIMENTAL**. (I haven't actually checked carefully that the
13-
proofs are sound, for instance...)
6+
It provides two levels of API:
147

15-
## Warning
8+
* a higher-level, declarative API based around the `define_proof` macro,
9+
which provides an embedded DSL for specifying proof statements in
10+
Camenisch-Stadler-like notation:
11+
```
12+
define_proof! {
13+
vrf_proof, // Name of the module for generated implementation
14+
"VRF", // Label for the proof statement
15+
(x), // Secret variables
16+
(A, G, H), // Public variables unique to each proof
17+
(B) : // Public variables common between proofs
18+
A = (x * B), // Statements to prove
19+
G = (x * H)
20+
}
21+
```
22+
This expands into a module containing an implementation of proving,
23+
verification, and batch verification. Proving uses constant-time
24+
implementations, and the proofs have a derived implementation of
25+
(memory-safe) serialization and deserialization via Serde.
1626

17-
This code has **not** yet received sufficient peer review by other qualified
18-
cryptographers to be considered in any way, shape, or form, safe.
27+
* a lower-level, imperative API inspired by [Bellman][bellman], which
28+
provides a constraint system for Schnorr-style statements. This
29+
allows programmable construction of proof statements at runtime. The
30+
higher-level `define_proof` macro expands into an invocation of the
31+
lower-level API.
32+
The lower-level API is contained in the `toolbox` module.
1933

20-
**USE AT YOUR OWN RISK**
34+
# Examples
2135

22-
## Documentation
36+
Examples of how to use the API can be found in the library's `tests`
37+
directory.
2338

24-
Extensive documentation is available [here](https://docs.rs/zkp).
39+
Currently, the examples include:
2540

26-
# Pre-Release TODOs
41+
* Specification of an "anonymous credential presentation with 10 hidden
42+
attributes" proof from CMZ'13. Depending on the backend selection, the
43+
generated implementation is between 20 to 40 times faster than the benchmark
44+
numbers reported in that paper.
2745

28-
* don't use any yolocrypto features (i.e. stabilise decaf in curve25519-dalek)
29-
* make sure proofs are sound
30-
* make a CONTRIBUTING.md
46+
* A transcript-based signature and VRF construction with an auto-generated
47+
implementation. This includes an example of using the online interactive
48+
composition [described in the Merlin blog post][merlin_blog] to provide chained
49+
signatures with a counterparty.
3150

32-
# Future TODOs
51+
* An example of using the lower-level constraint system API.
3352

34-
* ???
53+
54+
# Use and features
55+
56+
To enable the `define_proof` macro, import the crate like so:
57+
```
58+
#[macro_use]
59+
extern crate zkp;
60+
```
61+
62+
#### Nightly features
63+
64+
The `nightly` feature enables nightly-specific features. It is required
65+
to build the documentation.
66+
67+
#### Backend selection
68+
69+
`zkp` provides the following pass-through features to select a
70+
`curve25519-dalek` backend:
71+
72+
* `u32_backend`
73+
* `u64_backend`
74+
* `simd_backend`
75+
76+
#### Transcript debugging
77+
78+
The `debug-transcript` feature is for development and testing, and
79+
prints a log of the data fed into the proof transcript.
80+
81+
#### Autogenerated benchmarks
82+
83+
The `define_proof` macro builds benchmarks for the generated proof
84+
statements, but because these are generated in the client crate (where
85+
the macro expansion happens), they need an extra step to be enabled.
86+
87+
**To enable generated benchmarks in your crate, do the following**:
88+
89+
* Add a `bench` feature to your crate's `Cargo.toml`;
90+
* Add `#[cfg_attr(feature = "bench", feature(test))]` to your crate's
91+
`lib.rs` or `main.rs`, to enable Rust's nightly-only benchmark
92+
feature.
93+
94+
# WARNING
95+
96+
**THIS IMPLEMENTATION IS NOT YET READY FOR PRODUCTION USE**
97+
98+
While I expect the 1.0 version to be largely unchanged from the current
99+
code, for now there are no stability guarantees on the proofs, so they
100+
should not yet be deployed.
101+
102+
[bellman]: https://github.com/zkcrypto/bellman
103+
[merlin_blog]: https://medium.com/@hdevalence/merlin-flexible-composable-transcripts-for-zero-knowledge-proofs-28d9fda22d9a

0 commit comments

Comments
 (0)