Skip to content

Commit 6e5b0fb

Browse files
evqrillian
andauthored
Update dependencies, 2.0.0 release (#35)
* Update deps, 2.0.0 release * Fix minor clippy warnings (#38) * Loop over test vectors directly Address a clippy warning by unpacking over the container elements directly instead of using a range and index variable. This is more idiomatic. * Simplify test assertion Use the more explicit `is_err` instead of negating `is_ok`. Addresses a clippy lint. * Remove redundant struct label in test Address a clippy warning. When the struct initialization value has the same name as the member, it's idiomatic to omit the member label. * Remove unnecessary base64 import The base64 package is referred to by its full path, so the explict `use` statement is redundant in contemporary rust compilers. Addresses a clippy lint. * Fix broken build status badge (#37) The travis-ci.org service is no longer available. Link to the github actions status badge and page instead. * Update to criterion 0.5 (#36) * Update to criterion 0.5 Use the latest release of the `criterion` benchmark framework, v0.5.1 at the time of writing. No relevant api changes. This aligns with more recent software releases so there's less surprise and fewer old versions of things. * Fix benchmark typo Correct spelling of the "sign pre-tokens" benchmark. * cargo fmt (#39) --------- Co-authored-by: Ralph Giles <[email protected]> Co-authored-by: Ralph Giles <[email protected]>
1 parent 5be85b6 commit 6e5b0fb

File tree

10 files changed

+34
-436
lines changed

10 files changed

+34
-436
lines changed

Cargo.toml

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
authors = ["eV <[email protected]>"]
33
edition = "2018"
44
name = "challenge-bypass-ristretto"
5-
version = "1.0.2"
5+
version = "2.0.0"
66
readme = "README.md"
77
license = "MPL-2.0"
88
repository = "https://github.com/brave-intl/challenge-bypass-ristretto"
@@ -14,13 +14,13 @@ exclude = [
1414
]
1515

1616
[dependencies]
17-
crypto-mac = "0.10"
18-
curve25519-dalek = { version = "3", default-features = false }
19-
digest = "0.9"
20-
hmac = "0.10"
21-
rand = { version = "0.7", default-features = false }
22-
rand_core = "0.5.1"
23-
rand_chacha = "0.2.2"
17+
crypto-mac = "0.11"
18+
curve25519-dalek = { version = "4", default-features = false, features = ["precomputed-tables", "zeroize", "rand_core", "digest"]}
19+
digest = "0.10"
20+
hmac = "0.12"
21+
rand = { version = "0.8", default-features = false }
22+
rand_core = "0.6"
23+
rand_chacha = "0.3"
2424
subtle = { version = "^2.2", default-features = false }
2525
zeroize = "1.3"
2626

@@ -33,30 +33,21 @@ optional = true
3333
version = "^1.0.0"
3434
default-features = false
3535

36-
[dependencies.merlin]
37-
optional = true
38-
version = "2"
39-
4036
[dev-dependencies]
4137
serde_json = "1.0"
4238
serde = { version = "^1.0.0", features = ["derive"] }
43-
sha2 = "0.9"
39+
sha2 = "0.10"
4440
base64 = "0.13"
45-
rand = { version = "0.7", default-features = true }
46-
criterion = { version = "0.3.4", features = ["html_reports"] }
41+
rand = { version = "0.8", default-features = true }
42+
criterion = { version = "0.5", features = ["html_reports"] }
4743

4844
[features]
49-
nightly = ["curve25519-dalek/nightly"]
50-
default = ["std", "u64_backend"]
51-
std = ["alloc", "curve25519-dalek/std", "subtle/std"]
45+
default = ["std"]
46+
std = ["alloc", "subtle/std"]
5247
alloc = ["curve25519-dalek/alloc"]
53-
u32_backend = ["curve25519-dalek/u32_backend"]
54-
u64_backend = ["curve25519-dalek/u64_backend"]
55-
avx2_backend = ["curve25519-dalek/avx2_backend"]
5648
serde_base64 = ["serde", "base64"]
5749

5850
[package.metadata.docs.rs]
59-
features = ["nightly"]
6051
rustdoc-args = [
6152
"--document-private-items",
6253
"--html-in-header",

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
.PHONY: docs
22

33
docs:
4-
cargo rustdoc --features nightly -- --document-private-items --html-in-header ./rustdoc-include-katex-header.html
4+
cargo rustdoc -- --document-private-items --html-in-header ./rustdoc-include-katex-header.html

README.md

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# challenge-bypass-ristretto [![](https://img.shields.io/crates/v/challenge-bypass-ristretto.svg)](https://crates.io/crates/challenge-bypass-ristretto) [![](https://docs.rs/challenge-bypass-ristretto/badge.svg)](https://docs.rs/challenge-bypass-ristretto) [![Build Status](https://travis-ci.org/brave-intl/challenge-bypass-ristretto.svg?branch=master)](https://travis-ci.org/brave-intl/challenge-bypass-ristretto)
1+
# challenge-bypass-ristretto [![](https://img.shields.io/crates/v/challenge-bypass-ristretto.svg)](https://crates.io/crates/challenge-bypass-ristretto) [![](https://docs.rs/challenge-bypass-ristretto/badge.svg)](https://docs.rs/challenge-bypass-ristretto) [![Build Status](https://github.com/brave-intl/challenge-bypass-ristretto/workflows/CI/badge.svg)](https://github.com/brave-intl/challenge-bypass-ristretto/actions)
22

33
**A rust implemention of the
44
[privacy pass cryptographic protocol](https://www.petsymposium.org/2018/files/papers/issue3/popets-2018-0026.pdf)
@@ -99,10 +99,6 @@ The optional features include `base64` and `serde`.
9999
* `base64` exposes methods for base64 encoding / decoding of the various structures.
100100
* `serde` implements the [serde](https://serde.rs) `Serialize` / `Deserialize` traits.
101101

102-
`merlin` is an experimental feature that uses [merlin](https://github.com/dalek-cryptography/merlin) to implement the DLEQ proofs. This diverges from
103-
the original protocol specified in the privacy pass paper. It is not yet stable / intended for use and
104-
is implemented in [`src/dleq_merlin.rs`].
105-
106102
# Development
107103

108104
Install rust.
@@ -115,6 +111,5 @@ Run `cargo build`
115111

116112
Run `cargo test`
117113

118-
[`src/dleq_merlin.rs`]: src/dleq_merlin.rs
119114
[`tests/e2e.rs`]: tests/e2e.rs
120115
[a more detailed writeup is also available]: https://docs.rs/challenge-bypass-ristretto#cryptographic-protocol

benches/benchmarks.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ pub fn e2e_server_benchmarks(c: &mut Criterion) {
3131

3232
let signing_req = client.create_tokens(n_tokens);
3333

34-
c.bench_function("sing pre-tokens", |b| {
34+
c.bench_function("sign pre-tokens", |b| {
3535
b.iter(|| {
3636
let _signing_resp = server.sign_tokens(signing_req.clone());
3737
});
@@ -72,7 +72,6 @@ struct Client {
7272
unblinded_tokens: Vec<UnblindedToken>,
7373
}
7474

75-
#[cfg(not(feature = "merlin"))]
7675
impl Client {
7776
fn create_tokens(&mut self, n: u8) -> SigningRequest {
7877
let mut rng = OsRng;
@@ -137,7 +136,6 @@ struct Server {
137136
spent_tokens: Vec<TokenPreimage>,
138137
}
139138

140-
#[cfg(not(feature = "merlin"))]
141139
impl Server {
142140
fn sign_tokens(&self, req: SigningRequest) -> SigningResponse {
143141
let mut rng = OsRng;

src/dleq.rs

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ impl DLEQProof {
4949
{
5050
let t = Scalar::random(rng);
5151

52-
let A = &t * &constants::RISTRETTO_BASEPOINT_TABLE;
52+
let A = t * constants::RISTRETTO_BASEPOINT_POINT;
5353
let B = t * P;
5454

5555
let mut h = D::default();
@@ -113,7 +113,7 @@ impl DLEQProof {
113113
let X = constants::RISTRETTO_BASEPOINT_COMPRESSED;
114114
let Y = public_key.0;
115115

116-
let A = (&self.s * &constants::RISTRETTO_BASEPOINT_TABLE)
116+
let A = (self.s * constants::RISTRETTO_BASEPOINT_POINT)
117117
+ (self.c
118118
* Y.decompress()
119119
.ok_or(TokenError(InternalError::PointDecompressionError))?);
@@ -195,9 +195,9 @@ impl DLEQProof {
195195
c_bits.copy_from_slice(&bytes[..32]);
196196
s_bits.copy_from_slice(&bytes[32..]);
197197

198-
let c = Scalar::from_canonical_bytes(c_bits)
198+
let c = Option::from(Scalar::from_canonical_bytes(c_bits))
199199
.ok_or(TokenError(InternalError::ScalarFormatError))?;
200-
let s = Scalar::from_canonical_bytes(s_bits)
200+
let s = Option::from(Scalar::from_canonical_bytes(s_bits))
201201
.ok_or(TokenError(InternalError::ScalarFormatError))?;
202202

203203
Ok(DLEQProof { c, s })
@@ -379,7 +379,7 @@ mod tests {
379379

380380
let proof = DLEQProof::_new::<Sha512, _>(&mut rng, P, Q, &key1);
381381

382-
assert!(!proof._verify::<Sha512>(P, Q, &key1.public_key).is_ok());
382+
assert!(proof._verify::<Sha512>(P, Q, &key1.public_key).is_err());
383383
}
384384

385385
#[allow(non_snake_case)]
@@ -393,9 +393,7 @@ mod tests {
393393
("tviSLm/W8oFds67y9lMs990fjh08hQNV17/4V2bmOQY=", "5ufRlCvVKvXp1yuxxS7Jvw9LSwQUl6Q/MlT6HY2l1Hc=", "zOVEbK4KQ1GBW97YUVNguoN+NntwtGi1t+EeioMusXY=", "lH2gNbwqSC1nYYxT3I7fNQagTsD4OvSbzwrSCpanQkQ=", "NJF9U3TWiCWMd6Qh/vA90F/2N6udsXbTvifNxf0rzgbhInoEvYDi5jZAZUQEi7x7mmP8iFq7+ukoOroy6/8jCw=="),
394394
("Ge3prZ2jJSoh1A3ZvrSfaSA1kDziGW2I+Gmh6jniaAs=", "2nNCd5YN9H5EYlOL9/kmLYNBMkaLwnG3wjyd7jw2QAY=", "YHdAzlpSTAMy3mB+F4mPwlyVl+V9Yt4f3cDPNJpWdns=", "gEnqgXg3FDaCQFayTXrIfpbZ2n0P6FD/95LuMsdIfFk=", "Fj2/YunbQs5XxSyLxl/fC4dAfRlErGurTtHHSfGKyQTzrLZrO7VghmGFQaMAXZ+jg+6v99YL6FWj1Y/5WFt2Aw=="),
395395
];
396-
for i in 0..vectors.len() {
397-
let (k, Y, P, Q_b64, dleq_b64) = vectors[i];
398-
396+
for (k, Y, P, Q_b64, dleq_b64) in vectors {
399397
let server_key = SigningKey::decode_base64(k).unwrap();
400398

401399
assert_eq!(server_key.public_key.encode_base64(), Y);
@@ -430,9 +428,7 @@ mod tests {
430428
("siv+BM3AvP8Jv1aL4MFhMs9Xa6jxUNhFXpTWDfGrZQQ=", "XgFOlHEz5zm5dtx6ptYIXNg1NsJ/3vAq+cf/9eBkbxI=", "dsaMl4/9FcOFtaW3l65y1Z9ETJR36aTcXPMp+w4HGUY=,aH2q1HiReMA/Ney2NNZCgl+5GKK9xrxVwdC+THq9pFY=,uGRqS51VD7DuK0gSpMb3owRld57W6DqOyZpygXJVpmI=,Bvv+lqtCg39SD1H218r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ZrDo3v6dw56owm6NazoBLKwtqMPWdtxSRVWxc=", "KVEotBgIaz5Rymqpy4paroHGQyD/80FdvLCrONxDzQUWgNZxZ6aiCJ2VxIGP+6+86FZXS1sXGgs3dwft/VMCCw=="),
432430
];
433-
for i in 0..vectors.len() {
434-
let (k, Y, P, Q, M_b64, Z_b64, dleq_b64) = vectors[i];
435-
431+
for (k, Y, P, Q, M_b64, Z_b64, dleq_b64) in vectors {
436432
let server_key = SigningKey::decode_base64(k).unwrap();
437433

438434
assert_eq!(server_key.public_key.encode_base64(), Y);

0 commit comments

Comments
 (0)