1
- unconstrained fn __get_shuffle_indices <T , let N : u32 >(lhs : [T ; N ], rhs : [T ; N ]) -> [Field ; N ]
1
+ unconstrained fn __get_shuffle_indices <T , let N : u32 >(lhs : [T ; N ], rhs : [T ; N ]) -> [u32 ; N ]
2
2
where
3
3
T : std::cmp::Eq ,
4
4
{
5
- let mut shuffle_indices : [Field ; N ] = [0 ; N ];
5
+ let mut shuffle_indices : [u32 ; N ] = [0 ; N ];
6
6
7
7
let mut shuffle_mask : [bool ; N ] = [false ; N ];
8
8
for i in 0 ..N {
11
11
if ((shuffle_mask [j ] == false ) & (!found )) {
12
12
if (lhs [i ] == rhs [j ]) {
13
13
found = true ;
14
- shuffle_indices [i ] = j as Field ;
14
+ shuffle_indices [i ] = j ;
15
15
shuffle_mask [j ] = true ;
16
16
}
17
17
}
@@ -25,11 +25,11 @@ where
25
25
shuffle_indices
26
26
}
27
27
28
- unconstrained fn __get_index <let N : u32 >(indices : [Field ; N ], idx : Field ) -> Field {
28
+ unconstrained fn __get_index <let N : u32 >(indices : [u32 ; N ], idx : u32 ) -> u32 {
29
29
let mut result = 0 ;
30
30
for i in 0 ..N {
31
31
if (indices [i ] == idx ) {
32
- result = i as Field ;
32
+ result = i ;
33
33
break ;
34
34
}
35
35
}
44
44
let shuffle_indices = unsafe { __get_shuffle_indices (lhs , rhs ) };
45
45
46
46
for i in 0 ..N {
47
- let idx = unsafe { __get_index (shuffle_indices , i as Field ) };
47
+ let idx = unsafe { __get_index (shuffle_indices , i ) };
48
48
// checks the relation between shuffle_indices and output of __get_index
49
- assert_eq (shuffle_indices [idx ], i as Field );
49
+ assert_eq (shuffle_indices [idx ], i );
50
50
}
51
51
for i in 0 ..N {
52
52
let idx = shuffle_indices [i ];
@@ -57,15 +57,15 @@ where
57
57
}
58
58
}
59
59
60
- pub fn get_shuffle_indices <T , let N : u32 >(lhs : [T ; N ], rhs : [T ; N ]) -> [Field ; N ]
60
+ pub fn get_shuffle_indices <T , let N : u32 >(lhs : [T ; N ], rhs : [T ; N ]) -> [u32 ; N ]
61
61
where
62
62
T : std::cmp::Eq ,
63
63
{
64
64
//@Safety: as explained in check_shuffle function
65
65
let shuffle_indices = unsafe { __get_shuffle_indices (lhs , rhs ) };
66
66
for i in 0 ..N {
67
- let idx = unsafe { __get_index (shuffle_indices , i as Field ) };
68
- assert_eq (shuffle_indices [idx ], i as Field );
67
+ let idx = unsafe { __get_index (shuffle_indices , i ) };
68
+ assert_eq (shuffle_indices [idx ], i );
69
69
}
70
70
for i in 0 ..N {
71
71
let idx = shuffle_indices [i ];
0 commit comments