@@ -314,6 +314,8 @@ pub const AND_LOOKUPS_PER_ROUND: usize = 200;
314314pub const XOR_LOOKUPS_PER_ROUND : usize = 608 ;
315315pub const RANGE_LOOKUPS_PER_ROUND : usize = 290 ;
316316pub const LOOKUPS_PER_ROUND : usize =
317+ AND_LOOKUPS_PER_ROUND + XOR_LOOKUPS_PER_ROUND + RANGE_LOOKUPS_PER_ROUND ;
318+ pub const LOOKUP_FELTS_PER_ROUND : usize =
317319 3 * AND_LOOKUPS_PER_ROUND + 3 * XOR_LOOKUPS_PER_ROUND + RANGE_LOOKUPS_PER_ROUND ;
318320
319321pub const AND_LOOKUPS : usize = ROUNDS * AND_LOOKUPS_PER_ROUND ;
@@ -348,14 +350,15 @@ impl<E: ExtensionField> ProtocolBuilder for KeccakLayout<E> {
348350
349351 fn build_gkr_phase ( & mut self , chip : & mut Chip ) {
350352 let final_outputs =
351- chip. allocate_output_evals :: < { KECCAK_OUTPUT_SIZE + KECCAK_INPUT_SIZE + LOOKUPS_PER_ROUND * ROUNDS } > ( ) ;
353+ chip. allocate_output_evals :: < { KECCAK_OUTPUT_SIZE + KECCAK_INPUT_SIZE + LOOKUP_FELTS_PER_ROUND * ROUNDS } > ( ) ;
352354
353355 let mut final_outputs_iter = final_outputs. iter ( ) ;
354356
355357 let [ keccak_output32, keccak_input32, lookup_outputs] = [
356358 KECCAK_OUTPUT_SIZE ,
357359 KECCAK_INPUT_SIZE ,
358- LOOKUPS_PER_ROUND * ROUNDS ,
360+ //LOOKUPS_PER_ROUND
361+ LOOKUP_FELTS_PER_ROUND * ROUNDS ,
359362 ]
360363 . map ( |many| final_outputs_iter. by_ref ( ) . take ( many) . collect_vec ( ) ) ;
361364
@@ -656,12 +659,18 @@ impl<E: ExtensionField> ProtocolBuilder for KeccakLayout<E> {
656659 let beta = Constant :: Base ( 0 ) ;
657660
658661 // Send all lookups to the final output layer
662+ // for (i, lookup) in chain!(and_lookups, xor_lookups, range_lookups)
663+ // .flatten()
664+ // .enumerate()
665+ // {
666+ // expressions.push(lookup.clone());
659667 for ( i, lookup) in chain ! ( and_lookups, xor_lookups, range_lookups)
660668 . flatten ( )
661669 . enumerate ( )
662670 {
663- expressions. push ( lookup. clone ( ) ) ;
664- expr_names. push ( format ! ( "{i}th: {:?}" , lookup) ) ;
671+ expressions. push ( lookup) ;
672+ //expressions.push(lookup.compress(alpha.clone(), beta.clone()));
673+ expr_names. push ( format ! ( "{i}th: aha" ) ) ;
665674 evals. push ( lookup_outputs[ lookup_index] . clone ( ) ) ;
666675 lookup_index += 1 ;
667676 }
@@ -686,7 +695,7 @@ impl<E: ExtensionField> ProtocolBuilder for KeccakLayout<E> {
686695 } ,
687696 ) ;
688697
689- assert ! ( lookup_index == LOOKUPS_PER_ROUND * ROUNDS ) ;
698+ assert ! ( lookup_index == LOOKUP_FELTS_PER_ROUND * ROUNDS ) ;
690699
691700 let ( state8, _) = chip. allocate_wits_in_layer :: < 200 , 0 > ( ) ;
692701
@@ -743,16 +752,6 @@ pub struct KeccakTrace {
743752 pub instances : Vec < [ u32 ; KECCAK_INPUT_SIZE ] > ,
744753}
745754
746- use p3_field:: Field ;
747-
748- impl < F : Field > From < RowMajorMatrix < F > > for KeccakTrace {
749- fn from ( rmm : RowMajorMatrix < F > ) -> Self {
750- // clarify rmm encoding for large_ecall_dummy to obtain input
751- //unimplemented!();
752- KeccakTrace { instances : vec ! [ ] }
753- }
754- }
755-
756755impl < E > ProtocolWitnessGenerator < E > for KeccakLayout < E >
757756where
758757 E : ExtensionField ,
@@ -842,8 +841,9 @@ where
842841 if layer_wits[ curr_layer] . bases . is_empty ( ) {
843842 layer_wits[ curr_layer] = LayerWitness :: new ( nest :: < E > ( & felts) , vec ! [ ] ) ;
844843 } else {
845- for ( i, bases) in layer_wits[ curr_layer] . bases . iter_mut ( ) . enumerate ( ) {
846- bases. push ( felts[ i] ) ;
844+ assert_eq ! ( felts. len( ) , layer_wits[ curr_layer] . bases. len( ) ) ;
845+ for ( i, base) in layer_wits[ curr_layer] . bases . iter_mut ( ) . enumerate ( ) {
846+ base. push ( felts[ i] ) ;
847847 }
848848 }
849849 curr_layer += 1 ;
@@ -1065,6 +1065,8 @@ where
10651065 ) ;
10661066 }
10671067
1068+ dbg ! ( layer_wits. len( ) ) ;
1069+
10681070 let len = layer_wits. len ( ) - 1 ;
10691071 layer_wits[ ..len] . reverse ( ) ;
10701072
@@ -1075,7 +1077,6 @@ where
10751077pub fn run_faster_keccakf ( states : Vec < [ u64 ; 25 ] > , verify : bool , test : bool ) -> ( ) {
10761078 let params = KeccakParams { } ;
10771079 let ( layout, chip) = KeccakLayout :: build ( params) ;
1078- let gkr_circuit = chip. gkr_circuit ( ) ;
10791080
10801081 let mut instances = vec ! [ ] ;
10811082 for state in states {
@@ -1094,6 +1095,7 @@ pub fn run_faster_keccakf(states: Vec<[u64; 25]>, verify: bool, test: bool) -> (
10941095 ) ;
10951096 }
10961097
1098+ dbg ! ( instances. len( ) ) ;
10971099 let phase1_witness = layout. phase1_witness ( KeccakTrace { instances } ) ;
10981100
10991101 let mut prover_transcript = BasicTranscript :: < E > :: new ( b"protocol" ) ;
@@ -1139,6 +1141,11 @@ pub fn run_faster_keccakf(states: Vec<[u64; 25]>, verify: bool, test: bool) -> (
11391141 // }
11401142
11411143 let len = final_output1. len ( ) ;
1144+ assert_eq ! (
1145+ len,
1146+ KECCAK_INPUT_SIZE + KECCAK_OUTPUT_SIZE + LOOKUP_FELTS_PER_ROUND * ROUNDS
1147+ ) ;
1148+ assert ! ( final_output1. len( ) == final_output2. len( ) ) ;
11421149 let gkr_outputs = chain ! (
11431150 zip( final_output1, once( point1) . cycle( ) . take( len) ) ,
11441151 zip( final_output2, once( point2) . cycle( ) . take( len) )
@@ -1152,6 +1159,8 @@ pub fn run_faster_keccakf(states: Vec<[u64; 25]>, verify: bool, test: bool) -> (
11521159 . collect_vec ( )
11531160 } ;
11541161
1162+ let gkr_circuit = chip. gkr_circuit ( ) ;
1163+ dbg ! ( & gkr_circuit. layers. len( ) ) ;
11551164 let GKRProverOutput { gkr_proof, .. } = gkr_circuit
11561165 . prove ( gkr_witness, & out_evals, & vec ! [ ] , & mut prover_transcript)
11571166 . expect ( "Failed to prove phase" ) ;
0 commit comments