Skip to content

Commit 322fc3e

Browse files
committed
Merge branch 'release/0.7'
2 parents 2aa14cc + 8b79e45 commit 322fc3e

File tree

11 files changed

+80
-72
lines changed

11 files changed

+80
-72
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
Entries are listed in reverse chronological order.
44

5+
## 0.7.0
6+
7+
* Update `curve25519-dalek`, `merlin` dependencies to 2.0.
8+
* Switch from `failure` to `thiserror` to provide `std`-compatible errors.
9+
* Correct `curve25519-dalek` feature-selection logic.
10+
511
## 0.6.2
612

713
* Correct minimum `curve25519-dalek` version to 1.0.3, not 1.0.0.

Cargo.toml

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
[package]
22
name = "zkp"
3-
version = "0.6.2"
3+
version = "0.7.0"
44
authors = ["Henry de Valence <[email protected]>"]
5+
edition = "2018"
56
license = "CC0-1.0"
67
readme = "README.md"
78
repository = "https://github.com/hdevalence/zkp"
89
documentation = "https://docs.rs/zkp"
910
categories = ["cryptography"]
10-
keywords = ["cryptography", "curve25519", "zero-knowledge", "NIZK", "compiler"]
11-
description = "This crate has an experimental zero-knowledge proof compiler implemented using Rust macros"
11+
keywords = ["cryptography", "ristretto", "zero-knowledge", "NIZK", "compiler"]
12+
description = "A toolkit for auto-generated implementations of Schnorr proofs"
1213
exclude = [
1314
".gitignore"
1415
]
@@ -17,26 +18,23 @@ exclude = [
1718
features = ["nightly"]
1819

1920
[dependencies]
20-
merlin = "1"
21-
rand = "0.6"
22-
serde = "1.0"
23-
serde_derive = "1.0"
24-
failure = "0.1.5"
25-
failure_derive = "0.1.5"
26-
27-
[dependencies.curve25519-dalek]
28-
features = ["serde", "nightly", "alloc"]
29-
version = "1.0.3"
21+
merlin = "2"
22+
rand = "0.7"
23+
serde = "1"
24+
serde_derive = "1"
25+
thiserror = "1"
26+
# Disable default features to deselect a backend, then select one below
27+
curve25519-dalek = { version = "2", default-features = false, features = ["serde", "std"] }
3028

3129
[dev-dependencies]
3230
bincode = "1"
3331
sha2 = "0.8"
3432

3533
[features]
34+
nightly = ["curve25519-dalek/nightly"]
35+
debug-transcript = ["merlin/debug-transcript"]
36+
bench = []
3637
default = ["u64_backend"]
3738
u32_backend = ["curve25519-dalek/u32_backend"]
3839
u64_backend = ["curve25519-dalek/u64_backend"]
3940
simd_backend = ["curve25519-dalek/simd_backend"]
40-
nightly = ["curve25519-dalek/nightly"]
41-
bench = [ ]
42-
debug-transcript = ["merlin/debug-transcript"]

benches/dleq.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ use curve25519_dalek::constants as dalek_constants;
3030
use curve25519_dalek::ristretto::RistrettoPoint;
3131
use curve25519_dalek::scalar::Scalar;
3232

33-
use zkp::Transcript;
3433
use zkp::toolbox::{batch_verifier::BatchVerifier, prover::Prover, verifier::Verifier, SchnorrCS};
34+
use zkp::Transcript;
3535

3636
#[allow(non_snake_case)]
3737
fn dleq_statement<CS: SchnorrCS>(
@@ -62,8 +62,8 @@ fn create_compact_dleq(b: &mut Bencher) {
6262
let var_x = prover.allocate_scalar(b"x", x);
6363
let (var_G, _) = prover.allocate_point(b"G", G);
6464
let (var_H, _) = prover.allocate_point(b"H", H);
65-
let (var_A, cmpr_A) = prover.allocate_point(b"A", A);
66-
let (var_B, cmpr_B) = prover.allocate_point(b"B", B);
65+
let (var_A, _cmpr_A) = prover.allocate_point(b"A", A);
66+
let (var_B, _cmpr_B) = prover.allocate_point(b"B", B);
6767

6868
dleq_statement(&mut prover, var_x, var_A, var_B, var_G, var_H);
6969

@@ -132,8 +132,8 @@ fn create_batchable_dleq(b: &mut Bencher) {
132132
let var_x = prover.allocate_scalar(b"x", x);
133133
let (var_G, _) = prover.allocate_point(b"G", G);
134134
let (var_H, _) = prover.allocate_point(b"H", H);
135-
let (var_A, cmpr_A) = prover.allocate_point(b"A", A);
136-
let (var_B, cmpr_B) = prover.allocate_point(b"B", B);
135+
let (var_A, _cmpr_A) = prover.allocate_point(b"A", A);
136+
let (var_B, _cmpr_B) = prover.allocate_point(b"B", B);
137137

138138
dleq_statement(&mut prover, var_x, var_A, var_B, var_G, var_H);
139139

benches/zkp.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,6 @@ extern crate sha2;
2121
extern crate zkp;
2222

2323
extern crate test;
24-
use test::Bencher;
25-
26-
use self::sha2::Sha512;
27-
28-
use curve25519_dalek::constants as dalek_constants;
29-
use curve25519_dalek::ristretto::RistrettoPoint;
30-
use curve25519_dalek::scalar::Scalar;
31-
32-
use zkp::Transcript;
3324

3425
mod cmz {
3526
// Proof statement for "credential presentation with 10 hidden attributes" from CMZ'13.

src/errors.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
1+
use thiserror::Error;
22
/// An error during proving or verification, such as a verification failure.
3-
#[derive(Debug, Fail)]
3+
#[derive(Debug, Error)]
44
pub enum ProofError {
55
/// Something is wrong with the proof, causing a verification failure.
6-
#[fail(display = "Verification failed.")]
6+
#[error("Verification failed.")]
77
VerificationFailure,
88
/// Occurs during batch verification if the batch parameters are mis-sized.
9-
#[fail(display = "Mismatched parameter sizes for batch verification.")]
9+
#[error("Mismatched parameter sizes for batch verification.")]
1010
BatchSizeMismatch,
1111
}

src/lib.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,6 @@
2020
//! Docs will only build on nightly Rust until
2121
//! [RFC 1990 stabilizes](https://github.com/rust-lang/rust/issues/44732).
2222
23-
extern crate failure;
24-
#[macro_use]
25-
extern crate failure_derive;
26-
2723
extern crate serde;
2824

2925
#[doc(hidden)]
@@ -42,11 +38,11 @@ mod errors;
4238
mod proofs;
4339
mod util;
4440

45-
pub use errors::*;
46-
pub use proofs::*;
41+
pub use crate::errors::*;
42+
pub use crate::proofs::*;
4743

4844
pub mod toolbox;
4945

5046
#[macro_use]
5147
mod macros;
52-
pub use macros::*;
48+
pub use crate::macros::*;

src/toolbox/batch_verifier.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ use curve25519_dalek::ristretto::{CompressedRistretto, RistrettoPoint};
44
use curve25519_dalek::scalar::Scalar;
55
use curve25519_dalek::traits::{IsIdentity, VartimeMultiscalarMul};
66

7-
use crate::{ProofError, Transcript, BatchableProof};
8-
use toolbox::{TranscriptProtocol, SchnorrCS};
9-
use util::Matrix;
7+
use crate::toolbox::{SchnorrCS, TranscriptProtocol};
8+
use crate::util::Matrix;
9+
use crate::{BatchableProof, ProofError, Transcript};
1010

1111
/// Used to produce batch verification results.
1212
///
1313
/// To use a [`BatchVerifier`], first construct one using [`BatchVerifier::new()`],
1414
/// declaring a batch size,
15-
/// supplying a domain separation label for the proof statement, as well as a
15+
/// supplying a domain separation label for the proof statement, as well as a
1616
/// transcript for each proof to verify.
1717
///
1818
/// Allocate secret variables using [`BatchVerifier::allocate_scalar`].

src/toolbox/mod.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,18 @@
3434
//! function, making it possible to combine generated and hand-crafted
3535
//! proof statements into the same constraint system.
3636
37+
/// Implements batch verification of batchable proofs.
38+
pub mod batch_verifier;
3739
/// Implements proof creation.
3840
pub mod prover;
3941
/// Implements proof verification of compact and batchable proofs.
4042
pub mod verifier;
41-
/// Implements batch verification of batchable proofs.
42-
pub mod batch_verifier;
4343

4444
use curve25519_dalek::ristretto::{CompressedRistretto, RistrettoPoint};
4545
use curve25519_dalek::scalar::Scalar;
4646
use curve25519_dalek::traits::IsIdentity;
4747

48-
use crate::{Transcript, ProofError};
48+
use crate::{ProofError, Transcript};
4949

5050
/// An interface for specifying proof statements, common between
5151
/// provers and verifiers.
@@ -164,12 +164,12 @@ pub trait TranscriptProtocol {
164164

165165
impl TranscriptProtocol for Transcript {
166166
fn domain_sep(&mut self, label: &'static [u8]) {
167-
self.commit_bytes(b"dom-sep", b"schnorrzkp/1.0/ristretto255");
168-
self.commit_bytes(b"dom-sep", label);
167+
self.append_message(b"dom-sep", b"schnorrzkp/1.0/ristretto255");
168+
self.append_message(b"dom-sep", label);
169169
}
170170

171171
fn append_scalar_var(&mut self, label: &'static [u8]) {
172-
self.commit_bytes(b"scvar", label);
172+
self.append_message(b"scvar", label);
173173
}
174174

175175
fn append_point_var(
@@ -178,8 +178,8 @@ impl TranscriptProtocol for Transcript {
178178
point: &RistrettoPoint,
179179
) -> CompressedRistretto {
180180
let encoding = point.compress();
181-
self.commit_bytes(b"ptvar", label);
182-
self.commit_bytes(b"val", encoding.as_bytes());
181+
self.append_message(b"ptvar", label);
182+
self.append_message(b"val", encoding.as_bytes());
183183
encoding
184184
}
185185

@@ -191,8 +191,8 @@ impl TranscriptProtocol for Transcript {
191191
if point.is_identity() {
192192
return Err(ProofError::VerificationFailure);
193193
}
194-
self.commit_bytes(b"ptvar", label);
195-
self.commit_bytes(b"val", point.as_bytes());
194+
self.append_message(b"ptvar", label);
195+
self.append_message(b"val", point.as_bytes());
196196
Ok(())
197197
}
198198

@@ -202,8 +202,8 @@ impl TranscriptProtocol for Transcript {
202202
point: &RistrettoPoint,
203203
) -> CompressedRistretto {
204204
let encoding = point.compress();
205-
self.commit_bytes(b"blindcom", label);
206-
self.commit_bytes(b"val", encoding.as_bytes());
205+
self.append_message(b"blindcom", label);
206+
self.append_message(b"val", encoding.as_bytes());
207207
encoding
208208
}
209209

@@ -215,8 +215,8 @@ impl TranscriptProtocol for Transcript {
215215
if point.is_identity() {
216216
return Err(ProofError::VerificationFailure);
217217
}
218-
self.commit_bytes(b"blindcom", label);
219-
self.commit_bytes(b"val", point.as_bytes());
218+
self.append_message(b"blindcom", label);
219+
self.append_message(b"val", point.as_bytes());
220220
Ok(())
221221
}
222222

src/toolbox/prover.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ use curve25519_dalek::ristretto::{CompressedRistretto, RistrettoPoint};
44
use curve25519_dalek::scalar::Scalar;
55
use curve25519_dalek::traits::MultiscalarMul;
66

7-
use crate::{Transcript, CompactProof, BatchableProof};
8-
use toolbox::{SchnorrCS, TranscriptProtocol};
7+
use crate::toolbox::{SchnorrCS, TranscriptProtocol};
8+
use crate::{BatchableProof, CompactProof, Transcript};
99

1010
/// Used to create proofs.
1111
///
@@ -77,7 +77,7 @@ impl<'a> Prover<'a> {
7777
// Construct a TranscriptRng
7878
let mut rng_builder = self.transcript.build_rng();
7979
for scalar in &self.scalars {
80-
rng_builder = rng_builder.commit_witness_bytes(b"", scalar.as_bytes());
80+
rng_builder = rng_builder.rekey_with_witness_bytes(b"", scalar.as_bytes());
8181
}
8282
let mut transcript_rng = rng_builder.finalize(&mut thread_rng());
8383

src/toolbox/verifier.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ use curve25519_dalek::ristretto::{CompressedRistretto, RistrettoPoint};
55
use curve25519_dalek::scalar::Scalar;
66
use curve25519_dalek::traits::{IsIdentity, VartimeMultiscalarMul};
77

8-
use crate::{ProofError, Transcript, CompactProof, BatchableProof};
9-
use toolbox::{SchnorrCS, TranscriptProtocol};
8+
use crate::toolbox::{SchnorrCS, TranscriptProtocol};
9+
use crate::{BatchableProof, CompactProof, ProofError, Transcript};
1010

1111
/// Used to produce verification results.
1212
///
@@ -31,7 +31,6 @@ pub struct Verifier<'a> {
3131
constraints: Vec<(PointVar, Vec<(ScalarVar, PointVar)>)>,
3232
}
3333

34-
3534
/// A secret variable used during verification.
3635
///
3736
/// Note that this variable is only a placeholder; it has no

0 commit comments

Comments
 (0)