Skip to content

Commit 459e928

Browse files
committed
Merge main into develop
2 parents ee8cc66 + 6a17ceb commit 459e928

File tree

10 files changed

+137
-89
lines changed

10 files changed

+137
-89
lines changed

CHANGELOG.md

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

33
Entries are listed in reverse chronological order.
44

5+
## 1.0.2
6+
7+
* Updates the library to use the renamed functions in Merlin 1.1.
8+
* Adds additional validation checks to prevent identity points being used as
9+
part of a proof. This does not appear to have security content, but is
10+
intended as a defense-in-depth mechanism.
11+
See [this comment][identity_comment] for more motivation.
12+
* Documentation tweaks.
13+
514
## 1.0.1
615

716
* Tweaks to crate metadata.
@@ -20,3 +29,4 @@ Entries are listed in reverse chronological order.
2029
Initial prerelease version, supporting single and aggregated range proofs, and
2130
multiparty proof aggregation.
2231

32+
[identity_comment]: https://github.com/dalek-cryptography/bulletproofs/pull/248#discussion_r251916724

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "bulletproofs"
3-
version = "1.0.1"
3+
version = "1.0.2"
44
authors = ["Cathie Yun <[email protected]>",
55
"Henry de Valence <[email protected]>",
66
"Oleg Andreev <[email protected]>"]
@@ -12,7 +12,7 @@ keywords = ["cryptography", "ristretto", "zero-knowledge", "bulletproofs"]
1212
description = "A pure-Rust implementation of Bulletproofs using Ristretto"
1313

1414
[dependencies]
15-
curve25519-dalek = { version = "1", features = ["serde"] }
15+
curve25519-dalek = { version = "1.0.3", features = ["serde"] }
1616
subtle = "2"
1717
sha3 = "0.8"
1818
digest = "0.8"
@@ -21,7 +21,7 @@ byteorder = "1"
2121
serde = "1"
2222
serde_derive = "1"
2323
failure = "0.1"
24-
merlin = "1"
24+
merlin = "1.1"
2525
clear_on_drop = "0.2"
2626

2727
[dev-dependencies]

README.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<img
44
width="100%"
5-
src="https://user-images.githubusercontent.com/698/46373713-9cc40280-c643-11e8-9bfe-2b0586e40369.png"
5+
src="https://doc.dalek.rs/assets/bulletproofs-rangeproof.png"
66
/>
77

88
The fastest [Bulletproofs][bp_website] implementation ever, featuring
@@ -145,6 +145,15 @@ assert!(
145145
);
146146
# }
147147
```
148+
## Building
149+
150+
To compile successfully, you will need to have nightly Rust installed, rather than stable.
151+
152+
You can install nightly Rust with rustup:
153+
154+
```text
155+
rustup default nightly
156+
```
148157

149158
## Tests and Benchmarks
150159

src/inner_product_proof.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,8 @@ impl InnerProductProof {
112112
L_vec.push(L);
113113
R_vec.push(R);
114114

115-
transcript.commit_point(b"L", &L);
116-
transcript.commit_point(b"R", &R);
115+
transcript.append_point(b"L", &L);
116+
transcript.append_point(b"R", &R);
117117

118118
let u = transcript.challenge_scalar(b"u");
119119
let u_inv = u.invert();
@@ -162,8 +162,8 @@ impl InnerProductProof {
162162
L_vec.push(L);
163163
R_vec.push(R);
164164

165-
transcript.commit_point(b"L", &L);
166-
transcript.commit_point(b"R", &R);
165+
transcript.append_point(b"L", &L);
166+
transcript.append_point(b"R", &R);
167167

168168
let u = transcript.challenge_scalar(b"u");
169169
let u_inv = u.invert();
@@ -213,8 +213,8 @@ impl InnerProductProof {
213213

214214
let mut challenges = Vec::with_capacity(lg_n);
215215
for (L, R) in self.L_vec.iter().zip(self.R_vec.iter()) {
216-
transcript.commit_point(b"L", L);
217-
transcript.commit_point(b"R", R);
216+
transcript.validate_and_append_point(b"L", L)?;
217+
transcript.validate_and_append_point(b"R", R)?;
218218
challenges.push(transcript.challenge_scalar(b"u"));
219219
}
220220

src/r1cs/prover.rs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ impl<'t, 'g> Prover<'t, 'g> {
274274

275275
// Add the commitment to the transcript.
276276
let V = self.pc_gens.commit(v, v_blinding).compress();
277-
self.transcript.commit_point(b"V", &V);
277+
self.transcript.append_point(b"V", &V);
278278

279279
(V, Variable::Committed(i))
280280
}
@@ -377,7 +377,7 @@ impl<'t, 'g> Prover<'t, 'g> {
377377
// We cannot do this in advance because user can commit variables one-by-one,
378378
// but this suffix provides safe disambiguation because each variable
379379
// is prefixed with a separate label.
380-
self.transcript.commit_u64(b"m", self.v.len() as u64);
380+
self.transcript.append_u64(b"m", self.v.len() as u64);
381381

382382
// Create a `TranscriptRng` from the high-level witness data
383383
//
@@ -397,7 +397,7 @@ impl<'t, 'g> Prover<'t, 'g> {
397397

398398
// Commit the blinding factors for the input wires
399399
for v_b in &self.v_blinding {
400-
builder = builder.commit_witness_bytes(b"v_blinding", v_b.as_bytes());
400+
builder = builder.rekey_with_witness_bytes(b"v_blinding", v_b.as_bytes());
401401
}
402402

403403
use rand::thread_rng;
@@ -450,9 +450,9 @@ impl<'t, 'g> Prover<'t, 'g> {
450450
)
451451
.compress();
452452

453-
self.transcript.commit_point(b"A_I1", &A_I1);
454-
self.transcript.commit_point(b"A_O1", &A_O1);
455-
self.transcript.commit_point(b"S1", &S1);
453+
self.transcript.append_point(b"A_I1", &A_I1);
454+
self.transcript.append_point(b"A_O1", &A_O1);
455+
self.transcript.append_point(b"S1", &S1);
456456

457457
// Process the remaining constraints.
458458
self = self.create_randomized_constraints()?;
@@ -527,9 +527,9 @@ impl<'t, 'g> Prover<'t, 'g> {
527527
)
528528
};
529529

530-
self.transcript.commit_point(b"A_I2", &A_I2);
531-
self.transcript.commit_point(b"A_O2", &A_O2);
532-
self.transcript.commit_point(b"S2", &S2);
530+
self.transcript.append_point(b"A_I2", &A_I2);
531+
self.transcript.append_point(b"A_O2", &A_O2);
532+
self.transcript.append_point(b"S2", &S2);
533533

534534
// 4. Compute blinded vector polynomials l(x) and r(x)
535535

@@ -582,11 +582,11 @@ impl<'t, 'g> Prover<'t, 'g> {
582582
let T_5 = self.pc_gens.commit(t_poly.t5, t_5_blinding).compress();
583583
let T_6 = self.pc_gens.commit(t_poly.t6, t_6_blinding).compress();
584584

585-
self.transcript.commit_point(b"T_1", &T_1);
586-
self.transcript.commit_point(b"T_3", &T_3);
587-
self.transcript.commit_point(b"T_4", &T_4);
588-
self.transcript.commit_point(b"T_5", &T_5);
589-
self.transcript.commit_point(b"T_6", &T_6);
585+
self.transcript.append_point(b"T_1", &T_1);
586+
self.transcript.append_point(b"T_3", &T_3);
587+
self.transcript.append_point(b"T_4", &T_4);
588+
self.transcript.append_point(b"T_5", &T_5);
589+
self.transcript.append_point(b"T_6", &T_6);
590590

591591
let u = self.transcript.challenge_scalar(b"u");
592592
let x = self.transcript.challenge_scalar(b"x");
@@ -628,10 +628,10 @@ impl<'t, 'g> Prover<'t, 'g> {
628628

629629
let e_blinding = x * (i_blinding + x * (o_blinding + x * s_blinding));
630630

631-
self.transcript.commit_scalar(b"t_x", &t_x);
631+
self.transcript.append_scalar(b"t_x", &t_x);
632632
self.transcript
633-
.commit_scalar(b"t_x_blinding", &t_x_blinding);
634-
self.transcript.commit_scalar(b"e_blinding", &e_blinding);
633+
.append_scalar(b"t_x_blinding", &t_x_blinding);
634+
self.transcript.append_scalar(b"e_blinding", &e_blinding);
635635

636636
// Get a challenge value to combine statements for the IPP
637637
let w = self.transcript.challenge_scalar(b"w");

src/r1cs/verifier.rs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ impl<'t> Verifier<'t> {
229229
self.V.push(commitment);
230230

231231
// Add the commitment to the transcript.
232-
self.transcript.commit_point(b"V", &commitment);
232+
self.transcript.append_point(b"V", &commitment);
233233

234234
Variable::Committed(i)
235235
}
@@ -328,12 +328,12 @@ impl<'t> Verifier<'t> {
328328
// We cannot do this in advance because user can commit variables one-by-one,
329329
// but this suffix provides safe disambiguation because each variable
330330
// is prefixed with a separate label.
331-
self.transcript.commit_u64(b"m", self.V.len() as u64);
331+
self.transcript.append_u64(b"m", self.V.len() as u64);
332332

333333
let n1 = self.num_vars;
334-
self.transcript.commit_point(b"A_I1", &proof.A_I1);
335-
self.transcript.commit_point(b"A_O1", &proof.A_O1);
336-
self.transcript.commit_point(b"S1", &proof.S1);
334+
self.transcript.append_point(b"A_I1", &proof.A_I1);
335+
self.transcript.append_point(b"A_O1", &proof.A_O1);
336+
self.transcript.append_point(b"S1", &proof.S1);
337337

338338
// Process the remaining constraints.
339339
self = self.create_randomized_constraints()?;
@@ -354,27 +354,27 @@ impl<'t> Verifier<'t> {
354354
// We are performing a single-party circuit proof, so party index is 0.
355355
let gens = bp_gens.share(0);
356356

357-
self.transcript.commit_point(b"A_I2", &proof.A_I2);
358-
self.transcript.commit_point(b"A_O2", &proof.A_O2);
359-
self.transcript.commit_point(b"S2", &proof.S2);
357+
self.transcript.append_point(b"A_I2", &proof.A_I2);
358+
self.transcript.append_point(b"A_O2", &proof.A_O2);
359+
self.transcript.append_point(b"S2", &proof.S2);
360360

361361
let y = self.transcript.challenge_scalar(b"y");
362362
let z = self.transcript.challenge_scalar(b"z");
363363

364-
self.transcript.commit_point(b"T_1", &proof.T_1);
365-
self.transcript.commit_point(b"T_3", &proof.T_3);
366-
self.transcript.commit_point(b"T_4", &proof.T_4);
367-
self.transcript.commit_point(b"T_5", &proof.T_5);
368-
self.transcript.commit_point(b"T_6", &proof.T_6);
364+
self.transcript.append_point(b"T_1", &proof.T_1);
365+
self.transcript.append_point(b"T_3", &proof.T_3);
366+
self.transcript.append_point(b"T_4", &proof.T_4);
367+
self.transcript.append_point(b"T_5", &proof.T_5);
368+
self.transcript.append_point(b"T_6", &proof.T_6);
369369

370370
let u = self.transcript.challenge_scalar(b"u");
371371
let x = self.transcript.challenge_scalar(b"x");
372372

373-
self.transcript.commit_scalar(b"t_x", &proof.t_x);
373+
self.transcript.append_scalar(b"t_x", &proof.t_x);
374374
self.transcript
375-
.commit_scalar(b"t_x_blinding", &proof.t_x_blinding);
375+
.append_scalar(b"t_x_blinding", &proof.t_x_blinding);
376376
self.transcript
377-
.commit_scalar(b"e_blinding", &proof.e_blinding);
377+
.append_scalar(b"e_blinding", &proof.e_blinding);
378378

379379
let w = self.transcript.challenge_scalar(b"w");
380380

src/range_proof/dealer.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -95,15 +95,15 @@ impl<'a, 'b> DealerAwaitingBitCommitments<'a, 'b> {
9595

9696
// Commit each V_j individually
9797
for vc in bit_commitments.iter() {
98-
self.transcript.commit_point(b"V", &vc.V_j);
98+
self.transcript.append_point(b"V", &vc.V_j);
9999
}
100100

101101
// Commit aggregated A_j, S_j
102102
let A: RistrettoPoint = bit_commitments.iter().map(|vc| vc.A_j).sum();
103-
self.transcript.commit_point(b"A", &A.compress());
103+
self.transcript.append_point(b"A", &A.compress());
104104

105105
let S: RistrettoPoint = bit_commitments.iter().map(|vc| vc.S_j).sum();
106-
self.transcript.commit_point(b"S", &S.compress());
106+
self.transcript.append_point(b"S", &S.compress());
107107

108108
let y = self.transcript.challenge_scalar(b"y");
109109
let z = self.transcript.challenge_scalar(b"z");
@@ -159,8 +159,8 @@ impl<'a, 'b> DealerAwaitingPolyCommitments<'a, 'b> {
159159
let T_1: RistrettoPoint = poly_commitments.iter().map(|pc| pc.T_1_j).sum();
160160
let T_2: RistrettoPoint = poly_commitments.iter().map(|pc| pc.T_2_j).sum();
161161

162-
self.transcript.commit_point(b"T_1", &T_1.compress());
163-
self.transcript.commit_point(b"T_2", &T_2.compress());
162+
self.transcript.append_point(b"T_1", &T_1.compress());
163+
self.transcript.append_point(b"T_2", &T_2.compress());
164164

165165
let x = self.transcript.challenge_scalar(b"x");
166166
let poly_challenge = PolyChallenge { x };
@@ -222,10 +222,10 @@ impl<'a, 'b> DealerAwaitingProofShares<'a, 'b> {
222222
let t_x_blinding: Scalar = proof_shares.iter().map(|ps| ps.t_x_blinding).sum();
223223
let e_blinding: Scalar = proof_shares.iter().map(|ps| ps.e_blinding).sum();
224224

225-
self.transcript.commit_scalar(b"t_x", &t_x);
225+
self.transcript.append_scalar(b"t_x", &t_x);
226226
self.transcript
227-
.commit_scalar(b"t_x_blinding", &t_x_blinding);
228-
self.transcript.commit_scalar(b"e_blinding", &e_blinding);
227+
.append_scalar(b"t_x_blinding", &t_x_blinding);
228+
self.transcript.append_scalar(b"e_blinding", &e_blinding);
229229

230230
// Get a challenge value to combine statements for the IPP
231231
let w = self.transcript.challenge_scalar(b"w");

src/range_proof/mod.rs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -287,24 +287,27 @@ impl RangeProof {
287287
transcript.rangeproof_domain_sep(n as u64, m as u64);
288288

289289
for V in value_commitments.iter() {
290-
transcript.commit_point(b"V", V);
290+
// Allow the commitments to be zero (0 value, 0 blinding)
291+
// See https://github.com/dalek-cryptography/bulletproofs/pull/248#discussion_r255167177
292+
transcript.append_point(b"V", V);
291293
}
292-
transcript.commit_point(b"A", &self.A);
293-
transcript.commit_point(b"S", &self.S);
294+
295+
transcript.validate_and_append_point(b"A", &self.A)?;
296+
transcript.validate_and_append_point(b"S", &self.S)?;
294297

295298
let y = transcript.challenge_scalar(b"y");
296299
let z = transcript.challenge_scalar(b"z");
297300
let zz = z * z;
298301
let minus_z = -z;
299302

300-
transcript.commit_point(b"T_1", &self.T_1);
301-
transcript.commit_point(b"T_2", &self.T_2);
303+
transcript.validate_and_append_point(b"T_1", &self.T_1)?;
304+
transcript.validate_and_append_point(b"T_2", &self.T_2)?;
302305

303306
let x = transcript.challenge_scalar(b"x");
304307

305-
transcript.commit_scalar(b"t_x", &self.t_x);
306-
transcript.commit_scalar(b"t_x_blinding", &self.t_x_blinding);
307-
transcript.commit_scalar(b"e_blinding", &self.e_blinding);
308+
transcript.append_scalar(b"t_x", &self.t_x);
309+
transcript.append_scalar(b"t_x_blinding", &self.t_x_blinding);
310+
transcript.append_scalar(b"e_blinding", &self.e_blinding);
308311

309312
let w = transcript.challenge_scalar(b"w");
310313

0 commit comments

Comments
 (0)