@@ -592,22 +592,19 @@ machine Keccakf32Memory(mem: Memory) with
592
592
// }
593
593
// }
594
594
595
- let query_c: int , int , int , fe [] - > int = query |x , limb , bit_in_limb , a|
596
- utils::fold(
597
- 5 ,
598
- |y| ( int (a [ y * 10 + x * 2 + limb ] ) >> bit_in_limb) & 0x1 ,
599
- 0 ,
600
- |acc , e| acc ^ e
601
- ) ;
602
-
603
595
query |row| {
604
596
let _ = array::map_enumerated(c , |i , c_i| {
605
597
let x = i / 64 ;
606
598
let z = i % 64 ;
607
599
let limb = z / 32 ;
608
600
let bit_in_limb = z % 32 ;
609
601
610
- compute_from(c_i , row , a , |a| fe(query_c(x , limb , bit_in_limb , a)))
602
+ let a_elems = array::new( 5 , |y| a [ y * 10 + x * 2 + limb ] ) ;
603
+
604
+ compute_from(
605
+ c_i , row , a_elems ,
606
+ |a_elems_fe| fe(utils::fold(
607
+ 5 , |y| ( int (a_elems_fe [ y ] ) >> bit_in_limb) & 0x1 , 0 , |acc , e| acc ^ e)))
611
608
}) ;
612
609
} ;
613
610
@@ -622,17 +619,18 @@ machine Keccakf32Memory(mem: Memory) with
622
619
// }
623
620
// }
624
621
625
- let query_c_prime: int , int , fe [] - > int = query |x , z , c|
626
- int (c [ x * 64 + z ] ) ^
627
- int (c [ ((x + 4 ) % 5 ) * 64 + z ] ) ^
628
- int (c [ ((x + 1 ) % 5 ) * 64 + (z + 63 ) % 64 ] ) ;
629
-
630
622
query |row| {
631
623
let _ = array::map_enumerated(c_prime , |i , c_i| {
632
624
let x = i / 64 ;
633
625
let z = i % 64 ;
634
626
635
- compute_from(c_i , row , c , |c| fe(query_c_prime(x , z , c))) ;
627
+ let c_elems = [
628
+ c [ x * 64 + z ],
629
+ c [ ((x + 4 ) % 5 ) * 64 + z ],
630
+ c [ ((x + 1 ) % 5 ) * 64 + (z + 63 ) % 64 ]
631
+ ] ;
632
+
633
+ compute_from(c_i , row , c_elems , |c_elems_fe| fe( int (c_elems_fe [ 0 ] ) ^ int (c_elems_fe [ 1 ] ) ^ int (c_elems_fe [ 2 ] ))) ;
636
634
}) ;
637
635
} ;
638
636
@@ -717,6 +715,7 @@ machine Keccakf32Memory(mem: Memory) with
717
715
let x = (i / 2 ) % 5 ;
718
716
let limb = i % 2 ;
719
717
718
+ // Seems to be faster to require all 5 * 5 * 64 elements of a_prime
720
719
compute_from(a_i , row , a_prime , |a_prime| fe(query_a_prime_prime(x , y , limb , a_prime))) ;
721
720
}) ;
722
721
} ;
0 commit comments