Skip to content

Commit 97c54d5

Browse files
committed
Update curve25519-dalek to 0.19
1 parent f1f5e83 commit 97c54d5

File tree

7 files changed

+41
-41
lines changed

7 files changed

+41
-41
lines changed

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ keywords = ["cryptography", "ristretto", "zero-knowledge", "bulletproofs"]
1212
description = "A pure-Rust implementation of Bulletproofs using Ristretto"
1313

1414
[dependencies]
15-
curve25519-dalek = { version = "0.18", features = ["serde"] }
16-
subtle = "0.6"
15+
curve25519-dalek = { version = "0.19", features = ["serde"] }
16+
subtle = "0.7"
1717
sha2 = "^0.7"
1818
rand = "0.5.0-pre.2"
1919
byteorder = "1.2.1"

benches/bulletproofs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ fn verify_aggregated_rangeproof_helper(n: usize, c: &mut Criterion) {
9191
let value_commitments: Vec<_> = values
9292
.iter()
9393
.zip(blindings.iter())
94-
.map(|(&v, &v_blinding)| pg.commit(Scalar::from_u64(v), v_blinding))
94+
.map(|(&v, &v_blinding)| pg.commit(Scalar::from(v), v_blinding))
9595
.collect();
9696

9797
b.iter(|| {

src/inner_product_proof.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -417,17 +417,17 @@ mod tests {
417417
#[test]
418418
fn test_inner_product() {
419419
let a = vec![
420-
Scalar::from_u64(1),
421-
Scalar::from_u64(2),
422-
Scalar::from_u64(3),
423-
Scalar::from_u64(4),
420+
Scalar::from(1u64),
421+
Scalar::from(2u64),
422+
Scalar::from(3u64),
423+
Scalar::from(4u64),
424424
];
425425
let b = vec![
426-
Scalar::from_u64(2),
427-
Scalar::from_u64(3),
428-
Scalar::from_u64(4),
429-
Scalar::from_u64(5),
426+
Scalar::from(2u64),
427+
Scalar::from(3u64),
428+
Scalar::from(4u64),
429+
Scalar::from(5u64),
430430
];
431-
assert_eq!(Scalar::from_u64(40), inner_product(&a, &b));
431+
assert_eq!(Scalar::from(40u64), inner_product(&a, &b));
432432
}
433433
}

src/range_proof/messages.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ impl ProofShare {
8383
let h = self
8484
.r_vec
8585
.iter()
86-
.zip(util::exp_iter(Scalar::from_u64(2)))
86+
.zip(util::exp_iter(Scalar::from(2u64)))
8787
.zip(util::exp_iter(y_inv))
8888
.map(|((r_i, exp_2), exp_y_inv)| {
8989
z + exp_y_inv * y_jn_inv * (-r_i) + exp_y_inv * y_jn_inv * (zz * z_j * exp_2)
@@ -106,7 +106,7 @@ impl ProofShare {
106106
}
107107

108108
let sum_of_powers_y = util::sum_of_powers(&y, n);
109-
let sum_of_powers_2 = util::sum_of_powers(&Scalar::from_u64(2), n);
109+
let sum_of_powers_2 = util::sum_of_powers(&Scalar::from(2u64), n);
110110
let delta = (z - zz) * sum_of_powers_y * y_jn - z * zz * sum_of_powers_2 * z_j;
111111
let t_check = RistrettoPoint::vartime_multiscalar_mul(
112112
iter::once(zz * z_j)

src/range_proof/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ impl RangeProof {
186186

187187
// Construct concat_z_and_2, an iterator of the values of
188188
// z^0 * \vec(2)^n || z^1 * \vec(2)^n || ... || z^(m-1) * \vec(2)^n
189-
let powers_of_2: Vec<Scalar> = util::exp_iter(Scalar::from_u64(2)).take(n).collect();
189+
let powers_of_2: Vec<Scalar> = util::exp_iter(Scalar::from(2u64)).take(n).collect();
190190
let powers_of_z = util::exp_iter(z).take(m);
191191
let concat_z_and_2 =
192192
powers_of_z.flat_map(|exp_z| powers_of_2.iter().map(move |exp_2| exp_2 * exp_z));
@@ -358,7 +358,7 @@ impl<'de> Deserialize<'de> for RangeProof {
358358
/// \\]
359359
fn delta(n: usize, m: usize, y: &Scalar, z: &Scalar) -> Scalar {
360360
let sum_y = util::sum_of_powers(y, n * m);
361-
let sum_2 = util::sum_of_powers(&Scalar::from_u64(2), n);
361+
let sum_2 = util::sum_of_powers(&Scalar::from(2u64), n);
362362
let sum_z = util::sum_of_powers(z, m);
363363

364364
(z - z * z) * sum_y - z * z * z * sum_2 * sum_z
@@ -446,7 +446,7 @@ mod tests {
446446
value_commitments = values
447447
.iter()
448448
.zip(blindings.iter())
449-
.map(|(&v, &v_blinding)| pg.commit(Scalar::from_u64(v), v_blinding))
449+
.map(|(&v, &v_blinding)| pg.commit(Scalar::from(v), v_blinding))
450450
.collect();
451451
}
452452

src/range_proof/party.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ impl Party {
3232

3333
let V = generators
3434
.pedersen_generators
35-
.commit(Scalar::from_u64(v), v_blinding);
35+
.commit(Scalar::from(v), v_blinding);
3636

3737
Ok(PartyAwaitingPosition {
3838
generators,
@@ -144,7 +144,7 @@ impl<'a> PartyAwaitingValueChallenge<'a> {
144144
let mut exp_y = offset_y; // start at y^j
145145
let mut exp_2 = Scalar::one(); // start at 2^0 = 1
146146
for i in 0..n {
147-
let a_L_i = Scalar::from_u64((self.v >> i) & 1);
147+
let a_L_i = Scalar::from((self.v >> i) & 1);
148148
let a_R_i = a_L_i - Scalar::one();
149149

150150
l_poly.0[i] = a_L_i - vc.z;

src/util.rs

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ pub fn sum_of_powers(x: &Scalar, n: usize) -> Scalar {
109109
return sum_of_powers_slow(x, n);
110110
}
111111
if n == 0 || n == 1 {
112-
return Scalar::from_u64(n as u64);
112+
return Scalar::from(n as u64);
113113
}
114114
let mut m = n;
115115
let mut result = Scalar::one() + x;
@@ -140,29 +140,29 @@ mod tests {
140140

141141
#[test]
142142
fn exp_2_is_powers_of_2() {
143-
let exp_2: Vec<_> = exp_iter(Scalar::from_u64(2)).take(4).collect();
143+
let exp_2: Vec<_> = exp_iter(Scalar::from(2u64)).take(4).collect();
144144

145-
assert_eq!(exp_2[0], Scalar::from_u64(1));
146-
assert_eq!(exp_2[1], Scalar::from_u64(2));
147-
assert_eq!(exp_2[2], Scalar::from_u64(4));
148-
assert_eq!(exp_2[3], Scalar::from_u64(8));
145+
assert_eq!(exp_2[0], Scalar::from(1u64));
146+
assert_eq!(exp_2[1], Scalar::from(2u64));
147+
assert_eq!(exp_2[2], Scalar::from(4u64));
148+
assert_eq!(exp_2[3], Scalar::from(8u64));
149149
}
150150

151151
#[test]
152152
fn test_inner_product() {
153153
let a = vec![
154-
Scalar::from_u64(1),
155-
Scalar::from_u64(2),
156-
Scalar::from_u64(3),
157-
Scalar::from_u64(4),
154+
Scalar::from(1u64),
155+
Scalar::from(2u64),
156+
Scalar::from(3u64),
157+
Scalar::from(4u64),
158158
];
159159
let b = vec![
160-
Scalar::from_u64(2),
161-
Scalar::from_u64(3),
162-
Scalar::from_u64(4),
163-
Scalar::from_u64(5),
160+
Scalar::from(2u64),
161+
Scalar::from(3u64),
162+
Scalar::from(4u64),
163+
Scalar::from(5u64),
164164
];
165-
assert_eq!(Scalar::from_u64(40), inner_product(&a, &b));
165+
assert_eq!(Scalar::from(40u64), inner_product(&a, &b));
166166
}
167167

168168
/// Raises `x` to the power `n`.
@@ -194,7 +194,7 @@ mod tests {
194194

195195
#[test]
196196
fn test_sum_of_powers() {
197-
let x = Scalar::from_u64(10);
197+
let x = Scalar::from(10u64);
198198
assert_eq!(sum_of_powers_slow(&x, 0), sum_of_powers(&x, 0));
199199
assert_eq!(sum_of_powers_slow(&x, 1), sum_of_powers(&x, 1));
200200
assert_eq!(sum_of_powers_slow(&x, 2), sum_of_powers(&x, 2));
@@ -207,13 +207,13 @@ mod tests {
207207

208208
#[test]
209209
fn test_sum_of_powers_slow() {
210-
let x = Scalar::from_u64(10);
210+
let x = Scalar::from(10u64);
211211
assert_eq!(sum_of_powers_slow(&x, 0), Scalar::zero());
212212
assert_eq!(sum_of_powers_slow(&x, 1), Scalar::one());
213-
assert_eq!(sum_of_powers_slow(&x, 2), Scalar::from_u64(11));
214-
assert_eq!(sum_of_powers_slow(&x, 3), Scalar::from_u64(111));
215-
assert_eq!(sum_of_powers_slow(&x, 4), Scalar::from_u64(1111));
216-
assert_eq!(sum_of_powers_slow(&x, 5), Scalar::from_u64(11111));
217-
assert_eq!(sum_of_powers_slow(&x, 6), Scalar::from_u64(111111));
213+
assert_eq!(sum_of_powers_slow(&x, 2), Scalar::from(11u64));
214+
assert_eq!(sum_of_powers_slow(&x, 3), Scalar::from(111u64));
215+
assert_eq!(sum_of_powers_slow(&x, 4), Scalar::from(1111u64));
216+
assert_eq!(sum_of_powers_slow(&x, 5), Scalar::from(11111u64));
217+
assert_eq!(sum_of_powers_slow(&x, 6), Scalar::from(111111u64));
218218
}
219219
}

0 commit comments

Comments
 (0)