@@ -12,16 +12,16 @@ pub(crate) mod fq;
1212pub ( crate ) mod grain;
1313pub ( crate ) mod mds;
1414
15- #[ cfg( test) ]
16- pub ( crate ) mod test_vectors;
15+ #[ cfg( any ( test, feature = "test-dependencies" ) ) ]
16+ pub mod test_vectors;
1717
1818mod p128pow5t3;
1919pub use p128pow5t3:: P128Pow5T3 ;
2020
2121use grain:: SboxType ;
2222
2323/// The type used to hold permutation state.
24- pub ( crate ) type State < F , const T : usize > = [ F ; T ] ;
24+ pub type State < F , const T : usize > = [ F ; T ] ;
2525
2626/// The type used to hold sponge rate.
2727pub ( crate ) type SpongeRate < F , const RATE : usize > = [ Option < F > ; RATE ] ;
@@ -175,7 +175,17 @@ impl<F, const RATE: usize> SpongeMode for Absorbing<F, RATE> {}
175175impl < F , const RATE : usize > SpongeMode for Squeezing < F , RATE > { }
176176
177177impl < F : fmt:: Debug , const RATE : usize > Absorbing < F , RATE > {
178- pub ( crate ) fn init_with ( val : F ) -> Self {
178+ pub fn init_empty ( ) -> Self {
179+ Self (
180+ ( 0 ..RATE )
181+ . map ( |_| None )
182+ . collect :: < Vec < _ > > ( )
183+ . try_into ( )
184+ . unwrap ( ) ,
185+ )
186+ }
187+
188+ pub fn init_with ( val : F ) -> Self {
179189 Self (
180190 iter:: once ( Some ( val) )
181191 . chain ( ( 1 ..RATE ) . map ( |_| None ) )
@@ -184,6 +194,22 @@ impl<F: fmt::Debug, const RATE: usize> Absorbing<F, RATE> {
184194 . unwrap ( ) ,
185195 )
186196 }
197+
198+ pub fn get ( & self , n : usize ) -> Option < Option < & F > > {
199+ self . 0 . iter ( ) . nth ( n) . map ( |x| x. as_ref ( ) )
200+ }
201+ }
202+
203+ impl < F : fmt:: Debug , const RATE : usize > Squeezing < F , RATE > {
204+ pub fn init_with ( vals : [ F ; RATE ] ) -> Self {
205+ Self (
206+ vals. into_iter ( )
207+ . map ( Some )
208+ . collect :: < Vec < _ > > ( )
209+ . try_into ( )
210+ . unwrap ( ) ,
211+ )
212+ }
187213}
188214
189215/// A Poseidon sponge.
0 commit comments