15
15
16
16
use core:: ops:: Mul ;
17
17
18
- use p3_field:: { AbstractField , Field , PrimeField32 } ;
18
+ use p3_field:: { Field , FieldAlgebra , PrimeField32 } ;
19
19
use p3_monty_31:: {
20
20
GenericPoseidon2LinearLayersMonty31 , InternalLayerBaseParameters , InternalLayerParameters ,
21
21
MontyField31 , Poseidon2ExternalLayerMonty31 , Poseidon2InternalLayerMonty31 ,
@@ -50,7 +50,7 @@ pub type Poseidon2BabyBear<const WIDTH: usize> = Poseidon2<
50
50
51
51
/// An implementation of the the matrix multiplications in the internal and external layers of Poseidon2.
52
52
///
53
- /// This can act on [AF ; WIDTH] for any AbstractField which implements multiplication by BabyBear field elements.
53
+ /// This can act on [FA ; WIDTH] for any AbstractField which implements multiplication by BabyBear field elements.
54
54
/// If you have either `[BabyBear::Packing; WIDTH]` or `[BabyBear; WIDTH]` it will be much faster
55
55
/// to use `Poseidon2BabyBear<WIDTH>` instead of building a Poseidon2 permutation using this.
56
56
pub type GenericPoseidon2LinearLayersBabyBear =
@@ -152,11 +152,11 @@ impl InternalLayerBaseParameters<BabyBearParameters, 16> for BabyBearInternalLay
152
152
state[ 15 ] = sum - state[ 15 ] ;
153
153
}
154
154
155
- fn generic_internal_linear_layer < AF > ( state : & mut [ AF ; 16 ] )
155
+ fn generic_internal_linear_layer < FA > ( state : & mut [ FA ; 16 ] )
156
156
where
157
- AF : AbstractField + Mul < BabyBear , Output = AF > ,
157
+ FA : FieldAlgebra + Mul < BabyBear , Output = FA > ,
158
158
{
159
- let part_sum: AF = state[ 1 ..] . iter ( ) . cloned ( ) . sum ( ) ;
159
+ let part_sum: FA = state[ 1 ..] . iter ( ) . cloned ( ) . sum ( ) ;
160
160
let full_sum = part_sum. clone ( ) + state[ 0 ] . clone ( ) ;
161
161
162
162
// The first three diagonal elements are -2, 1, 2 so we do something custom.
@@ -230,11 +230,11 @@ impl InternalLayerBaseParameters<BabyBearParameters, 24> for BabyBearInternalLay
230
230
state[ 23 ] = sum - state[ 23 ] ;
231
231
}
232
232
233
- fn generic_internal_linear_layer < AF > ( state : & mut [ AF ; 24 ] )
233
+ fn generic_internal_linear_layer < FA > ( state : & mut [ FA ; 24 ] )
234
234
where
235
- AF : AbstractField + Mul < BabyBear , Output = AF > ,
235
+ FA : FieldAlgebra + Mul < BabyBear , Output = FA > ,
236
236
{
237
- let part_sum: AF = state[ 1 ..] . iter ( ) . cloned ( ) . sum ( ) ;
237
+ let part_sum: FA = state[ 1 ..] . iter ( ) . cloned ( ) . sum ( ) ;
238
238
let full_sum = part_sum. clone ( ) + state[ 0 ] . clone ( ) ;
239
239
240
240
// The first three diagonal elements are -2, 1, 2 so we do something custom.
@@ -260,7 +260,7 @@ impl InternalLayerParameters<BabyBearParameters, 24> for BabyBearInternalLayerPa
260
260
261
261
#[ cfg( test) ]
262
262
mod tests {
263
- use p3_field:: AbstractField ;
263
+ use p3_field:: FieldAlgebra ;
264
264
use p3_symmetric:: Permutation ;
265
265
use rand:: { Rng , SeedableRng } ;
266
266
use rand_xoshiro:: Xoroshiro128Plus ;
0 commit comments