@@ -120,7 +120,6 @@ namespace main(256);
120
120
//===== MEMORY OPCODES ==========================================================
121
121
pol commit sel_op_set;
122
122
pol commit sel_op_mov;
123
- pol commit sel_op_cmov;
124
123
125
124
//===== TABLE SUBOP-TR ========================================================
126
125
// Boolean selectors for (sub-)operations. Only one operation is activated at
@@ -160,7 +159,7 @@ namespace main(256);
160
159
// A helper witness being the inverse of some value
161
160
// to show a non-zero equality
162
161
pol commit inv;
163
- pol commit id_zero; // Boolean telling whether id is zero (cmov opcode)
162
+ pol commit id_zero; // Boolean telling whether id is zero (jmp opcode)
164
163
165
164
//===== MEMORY MODEL ========================================================
166
165
// ind_addr_a -> (gets resolved to)
@@ -285,7 +284,6 @@ namespace main(256);
285
284
// Might be removed if derived from opcode based on a lookup of constants
286
285
sel_op_set * (1 - sel_op_set) = 0;
287
286
sel_op_mov * (1 - sel_op_mov) = 0;
288
- sel_op_cmov * (1 - sel_op_cmov) = 0;
289
287
290
288
op_err * (1 - op_err) = 0;
291
289
tag_err * (1 - tag_err) = 0; // Potential optimization (boolean constraint derivation from equivalence check to mem)?
@@ -424,7 +422,7 @@ namespace main(256);
424
422
pol SEL_ALL_BINARY = sel_op_and + sel_op_or + sel_op_xor;
425
423
pol SEL_ALL_GADGET = sel_op_radix_le + sel_op_sha256 + sel_op_poseidon2 + sel_op_keccak + sel_op_pedersen
426
424
+ sel_op_ecadd + sel_op_pedersen_commit + sel_op_msm;
427
- pol SEL_ALL_MEMORY = sel_op_cmov + sel_op_mov + sel_op_set;
425
+ pol SEL_ALL_MEMORY = sel_op_mov + sel_op_set;
428
426
pol OPCODE_SELECTORS = sel_op_fdiv + sel_op_calldata_copy + sel_op_get_contract_instance
429
427
+ SEL_ALL_ALU + SEL_ALL_BINARY + SEL_ALL_MEMORY + SEL_ALL_GADGET
430
428
+ KERNEL_INPUT_SELECTORS + KERNEL_OUTPUT_SELECTORS + SEL_ALL_LEFTGAS
@@ -457,35 +455,32 @@ namespace main(256);
457
455
//====== MEMORY OPCODES CONSTRAINTS =========================================
458
456
459
457
// TODO: consolidate with zero division error handling
460
- // TODO: Ensure that operation decompostion will ensure mutual exclusivity of sel_op_cmov and sel_op_jumpi
461
458
462
- // When sel_op_cmov or sel_op_jumpi == 1, we need id == 0 <==> id_zero == 0
459
+ // When sel_op_jumpi == 1, we need id == 0 <==> id_zero == 0
463
460
// This can be achieved with the 2 following relations.
464
461
// inv is an extra witness to show that we can invert id, i.e., inv = id^(-1)
465
462
// If id == 0, we have to set inv = 1 to satisfy the second relation,
466
463
// because id_zero == 1 from the first relation.
467
- #[CMOV_CONDITION_RES_1 ]
468
- (sel_op_cmov + sel_op_jumpi) * (id * inv - 1 + id_zero) = 0;
469
- #[CMOV_CONDITION_RES_2 ]
470
- (sel_op_cmov + sel_op_jumpi) * id_zero * (1 - inv) = 0;
464
+ #[JMP_CONDITION_RES_1 ]
465
+ sel_op_jumpi * (id * inv - 1 + id_zero) = 0;
466
+ #[JMP_CONDITION_RES_2 ]
467
+ sel_op_jumpi * id_zero * (1 - inv) = 0;
471
468
472
469
// Boolean selectors telling whether we move ia to ic or ib to ic.
473
470
// Boolean constraints and mutual exclusivity are derived from their
474
- // respective definitions based on sel_op_mov, sel_op_cmov, and id_zero.
471
+ // respective definitions based on sel_op_mov, and id_zero.
475
472
pol commit sel_mov_ia_to_ic;
476
473
pol commit sel_mov_ib_to_ic;
477
474
478
475
// For MOV, we copy ia to ic.
479
- // For CMOV, we copy ia to ic if id is NOT zero, otherwise we copy ib to ic.
480
- sel_mov_ia_to_ic = sel_op_mov + sel_op_cmov * (1 - id_zero);
481
- sel_mov_ib_to_ic = sel_op_cmov * id_zero;
476
+ sel_mov_ia_to_ic = sel_op_mov * (1 - id_zero);
482
477
483
478
#[MOV_SAME_VALUE_A]
484
479
sel_mov_ia_to_ic * (ia - ic) = 0; // Ensure that the correct value is moved/copied.
485
480
#[MOV_SAME_VALUE_B]
486
481
sel_mov_ib_to_ic * (ib - ic) = 0; // Ensure that the correct value is moved/copied.
487
482
#[MOV_MAIN_SAME_TAG]
488
- ( sel_op_mov + sel_op_cmov) * (r_in_tag - w_in_tag) = 0;
483
+ sel_op_mov * (r_in_tag - w_in_tag) = 0;
489
484
490
485
// Predicate to activate the copy of intermediate registers to ALU table. If tag_err == 1,
491
486
// the operation is not copied to the ALU table.
@@ -580,27 +575,27 @@ namespace main(256);
580
575
slice.sel_start {slice.clk, slice.space_id, slice.col_offset, slice.cnt, slice.addr, slice.sel_cd_cpy, slice.sel_return};
581
576
582
577
#[PERM_MAIN_MEM_A]
583
- sel_mem_op_a {clk, space_id, mem_addr_a, ia, rwa, r_in_tag, w_in_tag, sel_mov_ia_to_ic, sel_op_cmov }
578
+ sel_mem_op_a {clk, space_id, mem_addr_a, ia, rwa, r_in_tag, w_in_tag, sel_mov_ia_to_ic}
584
579
is
585
580
mem.sel_op_a {mem.clk, mem.space_id, mem.addr, mem.val, mem.rw
586
- , mem.r_in_tag, mem.w_in_tag, mem.sel_mov_ia_to_ic, mem.sel_op_cmov };
581
+ , mem.r_in_tag, mem.w_in_tag, mem.sel_mov_ia_to_ic};
587
582
588
583
#[PERM_MAIN_MEM_B]
589
- sel_mem_op_b {clk, space_id, mem_addr_b, ib, rwb, r_in_tag, w_in_tag, sel_mov_ib_to_ic, sel_op_cmov }
584
+ sel_mem_op_b {clk, space_id, mem_addr_b, ib, rwb, r_in_tag, w_in_tag, sel_mov_ib_to_ic}
590
585
is
591
586
mem.sel_op_b {mem.clk, mem.space_id, mem.addr, mem.val, mem.rw
592
- , mem.r_in_tag, mem.w_in_tag, mem.sel_mov_ib_to_ic, mem.sel_op_cmov };
587
+ , mem.r_in_tag, mem.w_in_tag, mem.sel_mov_ib_to_ic};
593
588
594
589
#[PERM_MAIN_MEM_C]
595
590
sel_mem_op_c {clk, space_id, mem_addr_c, ic, rwc, r_in_tag, w_in_tag}
596
591
is
597
592
mem.sel_op_c {mem.clk, mem.space_id, mem.addr, mem.val, mem.rw, mem.r_in_tag, mem.w_in_tag};
598
593
599
594
#[PERM_MAIN_MEM_D]
600
- sel_mem_op_d {clk, space_id, mem_addr_d, id, rwd, r_in_tag, w_in_tag, sel_op_cmov }
595
+ sel_mem_op_d {clk, space_id, mem_addr_d, id, rwd, r_in_tag, w_in_tag}
601
596
is
602
597
mem.sel_op_d {mem.clk, mem.space_id, mem.addr, mem.val, mem.rw
603
- , mem.r_in_tag, mem.w_in_tag, mem.sel_op_cmov };
598
+ , mem.r_in_tag, mem.w_in_tag};
604
599
605
600
#[PERM_MAIN_MEM_IND_ADDR_A]
606
601
sel_resolve_ind_addr_a {clk, space_id, ind_addr_a, mem_addr_a}
0 commit comments