@@ -53,6 +53,8 @@ pub struct NovaAugmentedCircuitInputs<E: Engine> {
53
53
z0 : Vec < E :: Base > ,
54
54
zi : Option < Vec < E :: Base > > ,
55
55
U : Option < RelaxedR1CSInstance < E > > ,
56
+ ri : Option < E :: Base > ,
57
+ r_next : E :: Base ,
56
58
u : Option < R1CSInstance < E > > ,
57
59
T : Option < Commitment < E > > ,
58
60
}
@@ -65,6 +67,8 @@ impl<E: Engine> NovaAugmentedCircuitInputs<E> {
65
67
z0 : Vec < E :: Base > ,
66
68
zi : Option < Vec < E :: Base > > ,
67
69
U : Option < RelaxedR1CSInstance < E > > ,
70
+ ri : Option < E :: Base > ,
71
+ r_next : E :: Base ,
68
72
u : Option < R1CSInstance < E > > ,
69
73
T : Option < Commitment < E > > ,
70
74
) -> Self {
@@ -74,6 +78,8 @@ impl<E: Engine> NovaAugmentedCircuitInputs<E> {
74
78
z0,
75
79
zi,
76
80
U ,
81
+ ri,
82
+ r_next,
77
83
u,
78
84
T ,
79
85
}
@@ -117,6 +123,8 @@ impl<'a, E: Engine, SC: StepCircuit<E::Base>> NovaAugmentedCircuit<'a, E, SC> {
117
123
Vec < AllocatedNum < E :: Base > > ,
118
124
Vec < AllocatedNum < E :: Base > > ,
119
125
AllocatedRelaxedR1CSInstance < E > ,
126
+ AllocatedNum < E :: Base > ,
127
+ AllocatedNum < E :: Base > ,
120
128
AllocatedR1CSInstance < E > ,
121
129
AllocatedPoint < E > ,
122
130
) ,
@@ -158,6 +166,14 @@ impl<'a, E: Engine, SC: StepCircuit<E::Base>> NovaAugmentedCircuit<'a, E, SC> {
158
166
self . params . n_limbs ,
159
167
) ?;
160
168
169
+ // Allocate ri
170
+ let r_i = AllocatedNum :: alloc ( cs. namespace ( || "ri" ) , || {
171
+ Ok ( self . inputs . get ( ) ?. ri . unwrap_or ( E :: Base :: ZERO ) )
172
+ } ) ?;
173
+
174
+ // Allocate r_i+1
175
+ let r_next = AllocatedNum :: alloc ( cs. namespace ( || "r_i+1" ) , || Ok ( self . inputs . get ( ) ?. r_next ) ) ?;
176
+
161
177
// Allocate the instance to be folded in
162
178
let u = AllocatedR1CSInstance :: alloc (
163
179
cs. namespace ( || "allocate instance u to fold" ) ,
@@ -174,7 +190,7 @@ impl<'a, E: Engine, SC: StepCircuit<E::Base>> NovaAugmentedCircuit<'a, E, SC> {
174
190
) ?;
175
191
T . check_on_curve ( cs. namespace ( || "check T on curve" ) ) ?;
176
192
177
- Ok ( ( params, i, z_0, z_i, U , u, T ) )
193
+ Ok ( ( params, i, z_0, z_i, U , r_i , r_next , u, T ) )
178
194
}
179
195
180
196
/// Synthesizes base case and returns the new relaxed `R1CSInstance`
@@ -212,6 +228,7 @@ impl<'a, E: Engine, SC: StepCircuit<E::Base>> NovaAugmentedCircuit<'a, E, SC> {
212
228
z_0 : & [ AllocatedNum < E :: Base > ] ,
213
229
z_i : & [ AllocatedNum < E :: Base > ] ,
214
230
U : & AllocatedRelaxedR1CSInstance < E > ,
231
+ r_i : & AllocatedNum < E :: Base > ,
215
232
u : & AllocatedR1CSInstance < E > ,
216
233
T : & AllocatedPoint < E > ,
217
234
arity : usize ,
@@ -230,6 +247,7 @@ impl<'a, E: Engine, SC: StepCircuit<E::Base>> NovaAugmentedCircuit<'a, E, SC> {
230
247
ro. absorb ( e) ;
231
248
}
232
249
U . absorb_in_ro ( cs. namespace ( || "absorb U" ) , & mut ro) ?;
250
+ ro. absorb ( r_i) ;
233
251
234
252
let hash_bits = ro. squeeze ( cs. namespace ( || "Input hash" ) , NUM_HASH_BITS ) ?;
235
253
let hash = le_bits_to_num ( cs. namespace ( || "bits to hash" ) , & hash_bits) ?;
@@ -263,7 +281,7 @@ impl<'a, E: Engine, SC: StepCircuit<E::Base>> NovaAugmentedCircuit<'a, E, SC> {
263
281
let arity = self . step_circuit . arity ( ) ;
264
282
265
283
// Allocate all witnesses
266
- let ( params, i, z_0, z_i, U , u, T ) =
284
+ let ( params, i, z_0, z_i, U , r_i , r_next , u, T ) =
267
285
self . alloc_witness ( cs. namespace ( || "allocate the circuit witness" ) , arity) ?;
268
286
269
287
// Compute variable indicating if this is the base case
@@ -282,6 +300,7 @@ impl<'a, E: Engine, SC: StepCircuit<E::Base>> NovaAugmentedCircuit<'a, E, SC> {
282
300
& z_0,
283
301
& z_i,
284
302
& U ,
303
+ & r_i,
285
304
& u,
286
305
& T ,
287
306
arity,
@@ -347,6 +366,7 @@ impl<'a, E: Engine, SC: StepCircuit<E::Base>> NovaAugmentedCircuit<'a, E, SC> {
347
366
ro. absorb ( e) ;
348
367
}
349
368
Unew . absorb_in_ro ( cs. namespace ( || "absorb U_new" ) , & mut ro) ?;
369
+ ro. absorb ( & r_next) ;
350
370
let hash_bits = ro. squeeze ( cs. namespace ( || "output hash bits" ) , NUM_HASH_BITS ) ?;
351
371
let hash = le_bits_to_num ( cs. namespace ( || "convert hash to num" ) , & hash_bits) ?;
352
372
@@ -410,6 +430,7 @@ mod tests {
410
430
411
431
// Execute the base case for the primary
412
432
let zero1 = <<E2 as Engine >:: Base as Field >:: ZERO ;
433
+ let ri_1 = <<E2 as Engine >:: Base as Field >:: ZERO ;
413
434
let mut cs1 = SatisfyingAssignment :: < E1 > :: new ( ) ;
414
435
let inputs1: NovaAugmentedCircuitInputs < E2 > = NovaAugmentedCircuitInputs :: new (
415
436
scalar_as_base :: < E1 > ( zero1) , // pass zero for testing
@@ -418,6 +439,8 @@ mod tests {
418
439
None ,
419
440
None ,
420
441
None ,
442
+ ri_1,
443
+ None ,
421
444
None ,
422
445
) ;
423
446
let circuit1: NovaAugmentedCircuit < ' _ , E2 , TrivialCircuit < <E2 as Engine >:: Base > > =
@@ -429,13 +452,16 @@ mod tests {
429
452
430
453
// Execute the base case for the secondary
431
454
let zero2 = <<E1 as Engine >:: Base as Field >:: ZERO ;
455
+ let ri_2 = <<E1 as Engine >:: Base as Field >:: ZERO ;
432
456
let mut cs2 = SatisfyingAssignment :: < E2 > :: new ( ) ;
433
457
let inputs2: NovaAugmentedCircuitInputs < E1 > = NovaAugmentedCircuitInputs :: new (
434
458
scalar_as_base :: < E2 > ( zero2) , // pass zero for testing
435
459
zero2,
436
460
vec ! [ zero2] ,
437
461
None ,
438
462
None ,
463
+ None ,
464
+ ri_2,
439
465
Some ( inst1) ,
440
466
None ,
441
467
) ;
0 commit comments