@@ -27,7 +27,7 @@ use crate::transcript::TranscriptProtocol;
2727/// When all constraints are added, the proving code calls `prove`
2828/// which consumes the `Prover` instance, samples random challenges
2929/// that instantiate the randomized constraints, and creates a complete proof.
30- pub struct Prover < ' g , T : BorrowMut < Transcript > > {
30+ pub struct Prover < ' g , ' c , T : BorrowMut < Transcript > > {
3131 transcript : T ,
3232 pc_gens : & ' g PedersenGens ,
3333 /// The constraints accumulated so far.
@@ -38,7 +38,7 @@ pub struct Prover<'g, T: BorrowMut<Transcript>> {
3838 /// This list holds closures that will be called in the second phase of the protocol,
3939 /// when non-randomized variables are committed.
4040 deferred_constraints :
41- Vec < Box < dyn FnOnce ( & mut RandomizingProver < ' g , T > ) -> Result < ( ) , R1CSError > > > ,
41+ Vec < Box < dyn ' c + FnOnce ( & mut RandomizingProver < ' g , ' c , T > ) -> Result < ( ) , R1CSError > > > ,
4242
4343 /// Index of a pending multiplier that's not fully assigned yet.
4444 pending_multiplier : Option < usize > ,
@@ -66,8 +66,8 @@ struct Secrets {
6666/// monomorphize the closures for the proving and verifying code.
6767/// However, this type cannot be instantiated by the user and therefore can only be used within
6868/// the callback provided to `specify_randomized_constraints`.
69- pub struct RandomizingProver < ' g , T : BorrowMut < Transcript > > {
70- prover : Prover < ' g , T > ,
69+ pub struct RandomizingProver < ' g , ' c , T : BorrowMut < Transcript > > {
70+ prover : Prover < ' g , ' c , T > ,
7171}
7272
7373/// Overwrite secrets with null bytes when they go out of scope.
@@ -94,7 +94,7 @@ impl Drop for Secrets {
9494 }
9595}
9696
97- impl < ' g , T : BorrowMut < Transcript > > ConstraintSystem for Prover < ' g , T > {
97+ impl < ' g , ' c , T : BorrowMut < Transcript > > ConstraintSystem for Prover < ' g , ' c , T > {
9898 fn transcript ( & mut self ) -> & mut Transcript {
9999 self . transcript . borrow_mut ( )
100100 }
@@ -178,19 +178,26 @@ impl<'g, T: BorrowMut<Transcript>> ConstraintSystem for Prover<'g, T> {
178178 }
179179}
180180
181- impl < ' g , T : BorrowMut < Transcript > > RandomizableConstraintSystem for Prover < ' g , T > {
182- type RandomizedCS = RandomizingProver < ' g , T > ;
181+ impl < ' g , ' constraints , T : BorrowMut < Transcript > + ' constraints >
182+ RandomizableConstraintSystem < ' constraints > for Prover < ' g , ' constraints , T >
183+ where
184+ ' g : ' constraints ,
185+ {
186+ type RandomizedCS = RandomizingProver < ' g , ' constraints , T > ;
183187
184- fn specify_randomized_constraints < F > ( & mut self , callback : F ) -> Result < ( ) , R1CSError >
188+ fn specify_randomized_constraints < ' a : ' constraints , F > (
189+ & mut self ,
190+ callback : F ,
191+ ) -> Result < ( ) , R1CSError >
185192 where
186- F : ' static + FnOnce ( & mut Self :: RandomizedCS ) -> Result < ( ) , R1CSError > ,
193+ F : ' a + FnOnce ( & mut Self :: RandomizedCS ) -> Result < ( ) , R1CSError > ,
187194 {
188195 self . deferred_constraints . push ( Box :: new ( callback) ) ;
189196 Ok ( ( ) )
190197 }
191198}
192199
193- impl < ' g , T : BorrowMut < Transcript > > ConstraintSystem for RandomizingProver < ' g , T > {
200+ impl < ' g , ' c , T : BorrowMut < Transcript > > ConstraintSystem for RandomizingProver < ' g , ' c , T > {
194201 fn transcript ( & mut self ) -> & mut Transcript {
195202 self . prover . transcript . borrow_mut ( )
196203 }
@@ -223,13 +230,13 @@ impl<'g, T: BorrowMut<Transcript>> ConstraintSystem for RandomizingProver<'g, T>
223230 }
224231}
225232
226- impl < ' g , T : BorrowMut < Transcript > > RandomizedConstraintSystem for RandomizingProver < ' g , T > {
233+ impl < ' g , ' c , T : BorrowMut < Transcript > > RandomizedConstraintSystem for RandomizingProver < ' g , ' c , T > {
227234 fn challenge_scalar ( & mut self , label : & ' static [ u8 ] ) -> Scalar {
228235 self . prover . transcript . borrow_mut ( ) . challenge_scalar ( label)
229236 }
230237}
231238
232- impl < ' g , T : BorrowMut < Transcript > > Prover < ' g , T > {
239+ impl < ' g , ' c , T : BorrowMut < Transcript > > Prover < ' g , ' c , T > {
233240 /// Construct an empty constraint system with specified external
234241 /// input variables.
235242 ///
0 commit comments