77use curve25519_dalek:: ristretto:: RistrettoPoint ;
88use curve25519_dalek:: scalar:: Scalar ;
99use merlin:: Transcript ;
10- use rand:: { CryptoRng , Rng } ;
1110
1211use errors:: MPCError ;
13- use generators:: BulletproofGens ;
12+ use generators:: { BulletproofGens , PedersenGens } ;
1413use inner_product_proof;
1514use range_proof:: RangeProof ;
1615use transcript:: TranscriptProtocol ;
@@ -25,21 +24,22 @@ pub struct Dealer {}
2524impl Dealer {
2625 /// Creates a new dealer coordinating `m` parties proving `n`-bit ranges.
2726 pub fn new < ' a , ' b > (
28- gens : & ' b BulletproofGens ,
27+ bp_gens : & ' b BulletproofGens ,
28+ pc_gens : & ' b PedersenGens ,
29+ transcript : & ' a mut Transcript ,
2930 n : usize ,
3031 m : usize ,
31- transcript : & ' a mut Transcript ,
3232 ) -> Result < DealerAwaitingValueCommitments < ' a , ' b > , MPCError > {
3333 if !( n == 8 || n == 16 || n == 32 || n == 64 ) {
3434 return Err ( MPCError :: InvalidBitsize ) ;
3535 }
3636 if !m. is_power_of_two ( ) {
3737 return Err ( MPCError :: InvalidAggregation ) ;
3838 }
39- if gens . gens_capacity < n {
39+ if bp_gens . gens_capacity < n {
4040 return Err ( MPCError :: InvalidGeneratorsLength ) ;
4141 }
42- if gens . party_capacity < m {
42+ if bp_gens . party_capacity < m {
4343 return Err ( MPCError :: InvalidGeneratorsLength ) ;
4444 }
4545
@@ -60,25 +60,27 @@ impl Dealer {
6060 transcript. rangeproof_domain_sep ( n as u64 , m as u64 ) ;
6161
6262 Ok ( DealerAwaitingValueCommitments {
63- n ,
64- m ,
63+ bp_gens ,
64+ pc_gens ,
6565 transcript,
6666 initial_transcript,
67- gens,
67+ n,
68+ m,
6869 } )
6970 }
7071}
7172
7273/// The initial dealer state, waiting for the parties to send value
7374/// commitments.
7475pub struct DealerAwaitingValueCommitments < ' a , ' b > {
75- n : usize ,
76- m : usize ,
76+ bp_gens : & ' b BulletproofGens ,
77+ pc_gens : & ' b PedersenGens ,
7778 transcript : & ' a mut Transcript ,
7879 /// The dealer keeps a copy of the initial transcript state, so
7980 /// that it can attempt to verify the aggregated proof at the end.
8081 initial_transcript : Transcript ,
81- gens : & ' b BulletproofGens ,
82+ n : usize ,
83+ m : usize ,
8284}
8385
8486impl < ' a , ' b > DealerAwaitingValueCommitments < ' a , ' b > {
@@ -114,7 +116,8 @@ impl<'a, 'b> DealerAwaitingValueCommitments<'a, 'b> {
114116 m : self . m ,
115117 transcript : self . transcript ,
116118 initial_transcript : self . initial_transcript ,
117- gens : self . gens ,
119+ bp_gens : self . bp_gens ,
120+ pc_gens : self . pc_gens ,
118121 value_challenge,
119122 value_commitments,
120123 A ,
@@ -130,7 +133,8 @@ pub struct DealerAwaitingPolyCommitments<'a, 'b> {
130133 m : usize ,
131134 transcript : & ' a mut Transcript ,
132135 initial_transcript : Transcript ,
133- gens : & ' b BulletproofGens ,
136+ bp_gens : & ' b BulletproofGens ,
137+ pc_gens : & ' b PedersenGens ,
134138 value_challenge : ValueChallenge ,
135139 value_commitments : Vec < ValueCommitment > ,
136140 /// Aggregated commitment to the parties' bits
@@ -164,7 +168,8 @@ impl<'a, 'b> DealerAwaitingPolyCommitments<'a, 'b> {
164168 m : self . m ,
165169 transcript : self . transcript ,
166170 initial_transcript : self . initial_transcript ,
167- gens : self . gens ,
171+ bp_gens : self . bp_gens ,
172+ pc_gens : self . pc_gens ,
168173 value_challenge : self . value_challenge ,
169174 value_commitments : self . value_commitments ,
170175 A : self . A ,
@@ -184,7 +189,8 @@ pub struct DealerAwaitingProofShares<'a, 'b> {
184189 m : usize ,
185190 transcript : & ' a mut Transcript ,
186191 initial_transcript : Transcript ,
187- gens : & ' b BulletproofGens ,
192+ bp_gens : & ' b BulletproofGens ,
193+ pc_gens : & ' b PedersenGens ,
188194 value_challenge : ValueChallenge ,
189195 value_commitments : Vec < ValueCommitment > ,
190196 poly_challenge : PolyChallenge ,
@@ -217,7 +223,7 @@ impl<'a, 'b> DealerAwaitingProofShares<'a, 'b> {
217223
218224 // Get a challenge value to combine statements for the IPP
219225 let w = self . transcript . challenge_scalar ( b"w" ) ;
220- let Q = w * self . gens . pedersen_gens . B ;
226+ let Q = w * self . pc_gens . B ;
221227
222228 let l_vec: Vec < Scalar > = proof_shares
223229 . iter ( )
@@ -232,8 +238,8 @@ impl<'a, 'b> DealerAwaitingProofShares<'a, 'b> {
232238 self . transcript ,
233239 & Q ,
234240 util:: exp_iter ( self . value_challenge . y . invert ( ) ) ,
235- self . gens . G ( self . n , self . m ) . cloned ( ) . collect ( ) ,
236- self . gens . H ( self . n , self . m ) . cloned ( ) . collect ( ) ,
241+ self . bp_gens . G ( self . n , self . m ) . cloned ( ) . collect ( ) ,
242+ self . bp_gens . H ( self . n , self . m ) . cloned ( ) . collect ( ) ,
237243 l_vec,
238244 r_vec,
239245 ) ;
@@ -258,25 +264,25 @@ impl<'a, 'b> DealerAwaitingProofShares<'a, 'b> {
258264 /// error.
259265 ///
260266 /// XXX define error types so we can surface the blame info
261- pub fn receive_shares < R : Rng + CryptoRng > (
262- mut self ,
263- rng : & mut R ,
264- proof_shares : & [ ProofShare ] ,
265- ) -> Result < RangeProof , MPCError > {
267+ pub fn receive_shares ( mut self , proof_shares : & [ ProofShare ] ) -> Result < RangeProof , MPCError > {
266268 let proof = self . assemble_shares ( proof_shares) ?;
267269
268270 let V : Vec < _ > = self . value_commitments . iter ( ) . map ( |vc| vc. V_j ) . collect ( ) ;
269271
270272 // See comment in `Dealer::new` for why we use `initial_transcript`
271273 let transcript = & mut self . initial_transcript ;
272- if proof. verify ( & V , self . gens , transcript, rng, self . n ) . is_ok ( ) {
274+ if proof
275+ . verify ( self . bp_gens , self . pc_gens , transcript, & V , self . n )
276+ . is_ok ( )
277+ {
273278 Ok ( proof)
274279 } else {
275280 // Proof verification failed. Now audit the parties:
276281 let mut bad_shares = Vec :: new ( ) ;
277282 for j in 0 ..self . m {
278283 match proof_shares[ j] . audit_share (
279- & self . gens ,
284+ & self . bp_gens ,
285+ & self . pc_gens ,
280286 j,
281287 & self . value_commitments [ j] ,
282288 & self . value_challenge ,
0 commit comments