@@ -43,7 +43,7 @@ use crate::{
4343} ;
4444
4545#[ derive( Debug ) ]
46- pub struct KeccakMemoryControlConfig < E : ExtensionField > {
46+ pub struct KeccakEcallConfig < E : ExtensionField > {
4747 pub ( crate ) vm_state : StateInOut < E > ,
4848 pub ( crate ) ecall_id : OpFixedRS < E , { Platform :: reg_ecall ( ) } , false > ,
4949 pub ( crate ) state_ptr : ( OpFixedRS < E , { Platform :: reg_arg0 ( ) } , true > , MemAddr < E > ) ,
@@ -53,17 +53,17 @@ pub struct KeccakMemoryControlConfig<E: ExtensionField> {
5353}
5454
5555#[ derive( Debug ) ]
56- pub struct KeccakPermutationConfig < E : ExtensionField > {
56+ pub struct KeccakCoreConfig < E : ExtensionField > {
5757 pub layout : KeccakLayout < E > ,
5858}
5959
6060/// Syscall-facing Keccak chip: VM state, syscall decode, guest memory, and local state bus.
61- pub struct KeccakMemoryControlInstruction < E > ( PhantomData < E > ) ;
61+ pub struct KeccakEcallInstruction < E > ( PhantomData < E > ) ;
6262
6363/// Pure Keccak-f chip. It reads/writes the Keccak-local state bus and has no guest memory ops.
64- pub struct KeccakPermutationInstruction < E > ( PhantomData < E > ) ;
64+ pub struct KeccakCoreInstruction < E > ( PhantomData < E > ) ;
6565
66- pub type KeccakInstruction < E > = KeccakPermutationInstruction < E > ;
66+ pub type KeccakInstruction < E > = KeccakCoreInstruction < E > ;
6767
6868fn new_memory_expr < E : ExtensionField > ( cb : & mut CircuitBuilder < E > , name : String ) -> MemoryExpr < E > {
6969 array:: from_fn ( |i| cb. create_witin ( || format ! ( "{name}_{i}" ) ) . expr ( ) )
@@ -78,22 +78,22 @@ fn assign_memory_expr<E: ExtensionField>(
7878 let limbs = value. as_u16_limbs ( ) ;
7979 for ( limb_expr, limb) in expr. iter ( ) . zip_eq ( limbs. iter ( ) ) {
8080 let multilinear_extensions:: Expression :: WitIn ( wit) = limb_expr else {
81- panic ! ( "keccak memory-control state limbs must be witness columns" ) ;
81+ panic ! ( "keccak ecall state limbs must be witness columns" ) ;
8282 } ;
8383 instance[ * wit as usize ] = E :: BaseField :: from_canonical_u64 ( * limb as u64 ) ;
8484 }
8585}
8686
87- impl < E : ExtensionField > Instruction < E > for KeccakMemoryControlInstruction < E > {
88- type InstructionConfig = KeccakMemoryControlConfig < E > ;
87+ impl < E : ExtensionField > Instruction < E > for KeccakEcallInstruction < E > {
88+ type InstructionConfig = KeccakEcallConfig < E > ;
8989 type InsnType = InsnKind ;
9090
9191 fn inst_kinds ( ) -> & ' static [ Self :: InsnType ] {
9292 & [ InsnKind :: ECALL ]
9393 }
9494
9595 fn name ( ) -> String {
96- "KeccakMemoryControl " . to_string ( )
96+ "KeccakEcall " . to_string ( )
9797 }
9898
9999 fn construct_circuit (
@@ -171,7 +171,7 @@ impl<E: ExtensionField> Instruction<E> for KeccakMemoryControlInstruction<E> {
171171 } )
172172 . collect :: < Result < Vec < WriteMEM > , _ > > ( ) ?;
173173
174- Ok ( KeccakMemoryControlConfig {
174+ Ok ( KeccakEcallConfig {
175175 vm_state,
176176 ecall_id,
177177 state_ptr : ( state_ptr, state_ptr_value) ,
@@ -306,16 +306,16 @@ impl<E: ExtensionField> Instruction<E> for KeccakMemoryControlInstruction<E> {
306306 }
307307}
308308
309- impl < E : ExtensionField > Instruction < E > for KeccakPermutationInstruction < E > {
310- type InstructionConfig = KeccakPermutationConfig < E > ;
309+ impl < E : ExtensionField > Instruction < E > for KeccakCoreInstruction < E > {
310+ type InstructionConfig = KeccakCoreConfig < E > ;
311311 type InsnType = InsnKind ;
312312
313313 fn inst_kinds ( ) -> & ' static [ Self :: InsnType ] {
314314 & [ InsnKind :: ECALL ]
315315 }
316316
317317 fn name ( ) -> String {
318- "KeccakPermutation " . to_string ( )
318+ "KeccakCore " . to_string ( )
319319 }
320320
321321 fn construct_circuit (
@@ -332,7 +332,7 @@ impl<E: ExtensionField> Instruction<E> for KeccakPermutationInstruction<E> {
332332 let mut layout =
333333 <KeccakLayout < E > as ProtocolBuilder < E > >:: build_layer_logic ( cb, KeccakParams { } ) ?;
334334 let chip = layout. finalize ( Self :: name ( ) , cb) ;
335- Ok ( ( KeccakPermutationConfig { layout } , chip. gkr_circuit ( ) ) )
335+ Ok ( ( KeccakCoreConfig { layout } , chip. gkr_circuit ( ) ) )
336336 }
337337
338338 fn generate_fixed_traces (
@@ -492,36 +492,32 @@ mod tests {
492492 }
493493
494494 #[ test]
495- fn keccak_split_accounting_keeps_memory_out_of_permutation ( ) {
496- let ( mem_reads, mem_writes, mem_lks, _) =
497- build_counts :: < KeccakMemoryControlInstruction < E > > ( ) ;
498- let ( perm_reads, perm_writes, _, max_perm_selector_groups) =
499- build_counts :: < KeccakPermutationInstruction < E > > ( ) ;
495+ fn keccak_split_accounting_keeps_memory_out_of_core ( ) {
496+ let ( ecall_reads, ecall_writes, ecall_lks, _) = build_counts :: < KeccakEcallInstruction < E > > ( ) ;
497+ let ( core_reads, core_writes, _, max_core_selector_groups) =
498+ build_counts :: < KeccakCoreInstruction < E > > ( ) ;
500499
500+ assert_eq ! ( core_reads, 1 , "core should only read the input state bus" ) ;
501501 assert_eq ! (
502- perm_reads, 1 ,
503- "permutation should only read the input state bus"
504- ) ;
505- assert_eq ! (
506- perm_writes, 1 ,
507- "permutation should only write the output state bus"
502+ core_writes, 1 ,
503+ "core should only write the output state bus"
508504 ) ;
509505 assert ! (
510- max_perm_selector_groups < 1024 ,
511- "permutation sumcheck groups grew to {max_perm_selector_groups }"
506+ max_core_selector_groups < 1024 ,
507+ "core sumcheck groups grew to {max_core_selector_groups }"
512508 ) ;
513509
514510 assert ! (
515- mem_reads >= KECCAK_INPUT32_SIZE + 3 ,
516- "memory-control should own guest memory/register reads"
511+ ecall_reads >= KECCAK_INPUT32_SIZE + 3 ,
512+ "ecall should own guest memory/register reads"
517513 ) ;
518514 assert ! (
519- mem_writes >= KECCAK_INPUT32_SIZE + 3 ,
520- "memory-control should own guest memory/register writes"
515+ ecall_writes >= KECCAK_INPUT32_SIZE + 3 ,
516+ "ecall should own guest memory/register writes"
521517 ) ;
522518 assert ! (
523- mem_lks >= KECCAK_INPUT32_SIZE + 2 ,
524- "memory-control should own timestamp/register LT lookups"
519+ ecall_lks >= KECCAK_INPUT32_SIZE + 2 ,
520+ "ecall should own timestamp/register LT lookups"
525521 ) ;
526522 }
527523
@@ -531,49 +527,49 @@ mod tests {
531527 let steps = vec ! [ step] ;
532528 let step_indices = vec ! [ 0 ] ;
533529
534- let mut mem_cs = ConstraintSystem :: < E > :: new ( || "keccak_memory_control " ) ;
530+ let mut mem_cs = ConstraintSystem :: < E > :: new ( || "keccak_ecall " ) ;
535531 let mut mem_cb = CircuitBuilder :: new ( & mut mem_cs) ;
536- let ( mem_config, _) = KeccakMemoryControlInstruction :: < E > :: build_gkr_iop_circuit (
532+ let ( mem_config, _) = KeccakEcallInstruction :: < E > :: build_gkr_iop_circuit (
537533 & mut mem_cb,
538534 & ProgramParams :: default ( ) ,
539535 )
540- . expect ( "build memory-control circuit" ) ;
536+ . expect ( "build ecall circuit" ) ;
541537 let mem_num_witin = mem_cb. cs . num_witin as usize ;
542538 let mem_num_structural_witin = mem_cb. cs . num_structural_witin as usize ;
543539
544- let mut perm_cs = ConstraintSystem :: < E > :: new ( || "keccak_permutation " ) ;
540+ let mut perm_cs = ConstraintSystem :: < E > :: new ( || "keccak_core " ) ;
545541 let mut perm_cb = CircuitBuilder :: new ( & mut perm_cs) ;
546- let ( perm_config, _) = KeccakPermutationInstruction :: < E > :: build_gkr_iop_circuit (
542+ let ( perm_config, _) = KeccakCoreInstruction :: < E > :: build_gkr_iop_circuit (
547543 & mut perm_cb,
548544 & ProgramParams :: default ( ) ,
549545 )
550- . expect ( "build permutation circuit" ) ;
546+ . expect ( "build core circuit" ) ;
551547 let perm_num_witin = perm_cb. cs . num_witin as usize ;
552548 let perm_num_structural_witin = perm_cb. cs . num_structural_witin as usize ;
553549
554550 let mut mem_shard_ctx = ShardContext :: default ( ) ;
555551 mem_shard_ctx. syscall_witnesses = std:: sync:: Arc :: new ( syscall_witnesses. clone ( ) ) ;
556- let ( mem_rmms, _) = KeccakMemoryControlInstruction :: < E > :: assign_instances (
552+ let ( mem_rmms, _) = KeccakEcallInstruction :: < E > :: assign_instances (
557553 & mem_config,
558554 & mut mem_shard_ctx,
559555 mem_num_witin,
560556 mem_num_structural_witin,
561557 & steps,
562558 & step_indices,
563559 )
564- . expect ( "assign memory-control witness" ) ;
560+ . expect ( "assign ecall witness" ) ;
565561
566562 let mut perm_shard_ctx = ShardContext :: default ( ) ;
567563 perm_shard_ctx. syscall_witnesses = std:: sync:: Arc :: new ( syscall_witnesses) ;
568- let ( perm_rmms, _) = KeccakPermutationInstruction :: < E > :: assign_instances (
564+ let ( perm_rmms, _) = KeccakCoreInstruction :: < E > :: assign_instances (
569565 & perm_config,
570566 & mut perm_shard_ctx,
571567 perm_num_witin,
572568 perm_num_structural_witin,
573569 & steps,
574570 & step_indices,
575571 )
576- . expect ( "assign permutation witness" ) ;
572+ . expect ( "assign core witness" ) ;
577573
578574 let mem_wit_row = selected_row ( mem_rmms[ 0 ] . values ( ) , mem_num_witin, 0 ) ;
579575 let mem_structural_row =
@@ -605,25 +601,25 @@ mod tests {
605601 . w_expressions_namespace_map
606602 . iter ( )
607603 . position ( |name| name. contains ( "keccak_state_in" ) )
608- . expect ( "memory-control input bus write" ) ;
604+ . expect ( "ecall input bus write" ) ;
609605 let mem_out_read = mem_cb
610606 . cs
611607 . r_expressions_namespace_map
612608 . iter ( )
613609 . position ( |name| name. contains ( "keccak_state_out" ) )
614- . expect ( "memory-control output bus read" ) ;
610+ . expect ( "ecall output bus read" ) ;
615611 let perm_in_read = perm_cb
616612 . cs
617613 . r_expressions_namespace_map
618614 . iter ( )
619615 . position ( |name| name. contains ( "keccak_state_in" ) )
620- . expect ( "permutation input bus read" ) ;
616+ . expect ( "core input bus read" ) ;
621617 let perm_out_write = perm_cb
622618 . cs
623619 . w_expressions_namespace_map
624620 . iter ( )
625621 . position ( |name| name. contains ( "keccak_state_out" ) )
626- . expect ( "permutation output bus write" ) ;
622+ . expect ( "core output bus write" ) ;
627623
628624 assert_eq ! (
629625 eval_expr(
0 commit comments