@@ -38,7 +38,7 @@ use crate::{
38
38
use eth_types:: Field ;
39
39
use gadgets:: util:: { and, not, select, sum, Expr } ;
40
40
use halo2_proofs:: {
41
- circuit:: { Layouter , Region , Value } ,
41
+ circuit:: { AssignedCell , Layouter , Region , Value } ,
42
42
plonk:: { Column , ConstraintSystem , Error , Expression , Fixed , TableColumn , VirtualCells } ,
43
43
poly:: Rotation ,
44
44
} ;
@@ -55,7 +55,8 @@ pub struct KeccakCircuitConfig<F> {
55
55
q_padding_last : Column < Fixed > ,
56
56
/// The columns for other circuits to lookup Keccak hash results
57
57
pub keccak_table : KeccakTable ,
58
- cell_manager : CellManager < F > ,
58
+ /// Expose the columns that stores the cells for hash input/output
59
+ pub cell_manager : CellManager < F > ,
59
60
round_cst : Column < Fixed > ,
60
61
normalize_3 : [ TableColumn ; 2 ] ,
61
62
normalize_4 : [ TableColumn ; 2 ] ,
@@ -890,12 +891,13 @@ impl<F: Field> KeccakCircuitConfig<F> {
890
891
)
891
892
}
892
893
893
- fn set_row (
894
+ /// Set the cells for a keccak row; return the cells that are assigned.
895
+ pub fn set_row (
894
896
& self ,
895
897
region : & mut Region < ' _ , F > ,
896
898
offset : usize ,
897
899
row : & KeccakRow < F > ,
898
- ) -> Result < ( ) , Error > {
900
+ ) -> Result < Vec < AssignedCell < F , F > > , Error > {
899
901
// Fixed selectors
900
902
for ( name, column, value) in & [
901
903
( "q_enable" , self . q_enable , F :: from ( row. q_enable ) ) ,
@@ -930,18 +932,19 @@ impl<F: Field> KeccakCircuitConfig<F> {
930
932
) ?;
931
933
932
934
// Cell values
935
+ let mut res = vec ! [ ] ;
933
936
for ( idx, ( bit, column) ) in row
934
937
. cell_values
935
938
. iter ( )
936
939
. zip ( self . cell_manager . columns ( ) )
937
940
. enumerate ( )
938
941
{
939
- region. assign_advice (
942
+ res . push ( region. assign_advice (
940
943
|| format ! ( "assign lookup value {} {}" , idx, offset) ,
941
944
column. advice ,
942
945
offset,
943
946
|| Value :: known ( * bit) ,
944
- ) ?;
947
+ ) ?) ;
945
948
}
946
949
947
950
// Round constant
@@ -952,10 +955,11 @@ impl<F: Field> KeccakCircuitConfig<F> {
952
955
|| Value :: known ( row. round_cst ) ,
953
956
) ?;
954
957
955
- Ok ( ( ) )
958
+ Ok ( res )
956
959
}
957
960
958
- pub ( crate ) fn load_aux_tables ( & self , layouter : & mut impl Layouter < F > ) -> Result < ( ) , Error > {
961
+ /// Load the auxiliary table for keccak table.
962
+ pub fn load_aux_tables ( & self , layouter : & mut impl Layouter < F > ) -> Result < ( ) , Error > {
959
963
load_normalize_table ( layouter, "normalize_6" , & self . normalize_6 , 6u64 ) ?;
960
964
load_normalize_table ( layouter, "normalize_4" , & self . normalize_4 , 4u64 ) ?;
961
965
load_normalize_table ( layouter, "normalize_3" , & self . normalize_3 , 3u64 ) ?;
@@ -969,7 +973,8 @@ impl<F: Field> KeccakCircuitConfig<F> {
969
973
load_pack_table ( layouter, & self . pack_table )
970
974
}
971
975
972
- fn annotate_circuit ( & self , region : & mut Region < F > ) {
976
+ /// Annotate the circuit
977
+ pub fn annotate_circuit ( & self , region : & mut Region < F > ) {
973
978
//region.name_column(|| "KECCAK_q_enable", self.q_enable);
974
979
region. name_column ( || "KECCAK_q_first" , self . q_first ) ;
975
980
region. name_column ( || "KECCAK_q_round" , self . q_round ) ;
0 commit comments