@@ -14,7 +14,7 @@ use crate::{
14
14
traits:: {
15
15
circuit:: StepCircuit , commitment:: CommitmentTrait , Engine , ROCircuitTrait , ROConstantsCircuit ,
16
16
} ,
17
- Commitment ,
17
+ Commitment , StepCounterType ,
18
18
} ;
19
19
use abomonation_derive:: Abomonation ;
20
20
use bellpepper:: gadgets:: { boolean_utils:: conditionally_select_slice, Assignment } ;
@@ -260,6 +260,7 @@ impl<'a, E: Engine, SC: StepCircuit<E::Base>> NovaAugmentedCircuit<'a, E, SC> {
260
260
cs : & mut CS ,
261
261
) -> Result < Vec < AllocatedNum < E :: Base > > , SynthesisError > {
262
262
let arity = self . step_circuit . arity ( ) ;
263
+ let counter_type = self . step_circuit . get_counter_type ( ) ;
263
264
264
265
// Allocate all witnesses
265
266
let ( params, i, z_0, z_i, U , u, T ) =
@@ -307,15 +308,31 @@ impl<'a, E: Engine, SC: StepCircuit<E::Base>> NovaAugmentedCircuit<'a, E, SC> {
307
308
) ?;
308
309
309
310
// Compute i + 1
310
- let i_new = AllocatedNum :: alloc ( cs. namespace ( || "i + 1" ) , || {
311
- Ok ( * i. get_value ( ) . get ( ) ? + E :: Base :: ONE )
311
+ let i_new = AllocatedNum :: alloc ( cs. namespace ( || "next i" ) , || match counter_type {
312
+ StepCounterType :: Incremental => Ok ( * i. get_value ( ) . get ( ) ? + E :: Base :: ONE ) ,
313
+ StepCounterType :: External => {
314
+ let inc = * is_base_case. get_value ( ) . get ( ) ? as u64 ;
315
+ Ok ( * i. get_value ( ) . get ( ) ? + E :: Base :: from ( inc) )
316
+ }
312
317
} ) ?;
313
- cs. enforce (
314
- || "check i + 1" ,
315
- |lc| lc,
316
- |lc| lc,
317
- |lc| lc + i_new. get_variable ( ) - CS :: one ( ) - i. get_variable ( ) ,
318
- ) ;
318
+ match counter_type {
319
+ StepCounterType :: Incremental => {
320
+ cs. enforce (
321
+ || "check i + 1" ,
322
+ |lc| lc,
323
+ |lc| lc,
324
+ |lc| lc + i_new. get_variable ( ) - CS :: one ( ) - i. get_variable ( ) ,
325
+ ) ;
326
+ }
327
+ StepCounterType :: External => {
328
+ cs. enforce (
329
+ || "check i + 1 base" ,
330
+ |lc| lc,
331
+ |lc| lc,
332
+ |lc| lc + i_new. get_variable ( ) - is_base_case. get_variable ( ) - i. get_variable ( ) ,
333
+ ) ;
334
+ }
335
+ }
319
336
320
337
// Compute z_{i+1}
321
338
let z_input = conditionally_select_slice (
0 commit comments