@@ -3,6 +3,7 @@ pub mod impl_goldilocks {
33 ExtensionField , FieldFrom , FieldInto , FromUniformBytes , SmallField ,
44 array_try_from_uniform_bytes, impl_from_uniform_bytes_for_binomial_extension,
55 poseidon:: { PoseidonField , new_array} ,
6+ wrapper:: Wrapper ,
67 } ;
78 use p3:: {
89 challenger:: DuplexChallenger ,
@@ -21,8 +22,6 @@ pub mod impl_goldilocks {
2122
2223 #[ cfg( debug_assertions) ]
2324 use crate :: poseidon:: impl_instruments:: * ;
24- #[ cfg( debug_assertions) ]
25- use p3:: symmetric:: CryptographicPermutation ;
2625
2726 pub type GoldilocksExt2 = BinomialExtensionField < Goldilocks , 2 > ;
2827
@@ -47,17 +46,13 @@ pub mod impl_goldilocks {
4746 pub const POSEIDON2_GOLDILICK_WIDTH : usize = 8 ;
4847 pub const POSEIDON2_GOLDILICK_RATE : usize = 4 ;
4948
50- #[ cfg( debug_assertions) ]
51- impl CryptographicPermutation < [ Goldilocks ; POSEIDON2_GOLDILICK_WIDTH ] >
52- for Instrumented < Poseidon2GoldilocksHL < POSEIDON2_GOLDILICK_WIDTH > >
53- {
54- }
55-
49+ type WP = Wrapper < Poseidon2GoldilocksHL < POSEIDON2_GOLDILICK_WIDTH > , POSEIDON2_GOLDILICK_WIDTH > ;
5650 impl PoseidonField for Goldilocks {
5751 #[ cfg( debug_assertions) ]
58- type P = Instrumented < Poseidon2GoldilocksHL < POSEIDON2_GOLDILICK_WIDTH > > ;
52+ type P = Instrumented < WP > ;
5953 #[ cfg( not( debug_assertions) ) ]
60- type P = Poseidon2GoldilocksHL < POSEIDON2_GOLDILICK_WIDTH > ;
54+ type P = WP ;
55+
6156 type T =
6257 DuplexChallenger < Self , Self :: P , POSEIDON2_GOLDILICK_WIDTH , POSEIDON2_GOLDILICK_RATE > ;
6358 type S = PaddingFreeSponge < Self :: P , POSEIDON2_GOLDILICK_WIDTH , POSEIDON2_GOLDILICK_RATE , 4 > ;
@@ -71,24 +66,34 @@ pub mod impl_goldilocks {
7166
7267 #[ cfg( debug_assertions) ]
7368 fn get_default_perm ( ) -> Self :: P {
74- Instrumented :: new ( Poseidon2GoldilocksHL :: new (
69+ Instrumented :: new ( Wrapper :: new ( Poseidon2GoldilocksHL :: new (
7570 ExternalLayerConstants :: < Goldilocks , POSEIDON2_GOLDILICK_WIDTH > :: new_from_saved_array (
7671 HL_GOLDILOCKS_8_EXTERNAL_ROUND_CONSTANTS ,
7772 new_array,
7873 ) ,
7974 new_array ( HL_GOLDILOCKS_8_INTERNAL_ROUND_CONSTANTS ) . to_vec ( ) ,
80- ) )
75+ ) ) )
8176 }
8277
8378 #[ cfg( not( debug_assertions) ) ]
8479 fn get_default_perm ( ) -> Self :: P {
85- Poseidon2GoldilocksHL :: new (
80+ Wrapper :: new ( Poseidon2GoldilocksHL :: new (
8681 ExternalLayerConstants :: < Goldilocks , POSEIDON2_GOLDILICK_WIDTH > :: new_from_saved_array (
8782 HL_GOLDILOCKS_8_EXTERNAL_ROUND_CONSTANTS ,
8883 new_array,
8984 ) ,
9085 new_array ( HL_GOLDILOCKS_8_INTERNAL_ROUND_CONSTANTS ) . to_vec ( ) ,
91- )
86+ ) )
87+ }
88+
89+ fn get_default_perm_rc ( ) -> Vec < Self > {
90+ HL_GOLDILOCKS_8_EXTERNAL_ROUND_CONSTANTS [ 0 ]
91+ . iter ( )
92+ . flatten ( )
93+ . chain ( HL_GOLDILOCKS_8_INTERNAL_ROUND_CONSTANTS . iter ( ) )
94+ . chain ( HL_GOLDILOCKS_8_EXTERNAL_ROUND_CONSTANTS [ 1 ] . iter ( ) . flatten ( ) )
95+ . map ( |v| Self :: from_canonical_u64 ( * v) )
96+ . collect ( )
9297 }
9398
9499 fn get_default_sponge ( ) -> Self :: S {
0 commit comments