@@ -15,6 +15,7 @@ use twenty_first::math::x_field_element::EXTENSION_DEGREE;
15
15
use twenty_first:: util_types:: merkle_tree:: MerkleTree ;
16
16
use twenty_first:: util_types:: merkle_tree:: MerkleTreeInclusionProof ;
17
17
18
+ use crate :: U32_TO_USIZE_ERR ;
18
19
use crate :: data_type:: StructType ;
19
20
use crate :: field;
20
21
use crate :: hashing:: algebraic_hasher:: sample_indices:: SampleIndices ;
@@ -928,7 +929,7 @@ impl FriVerify {
928
929
let num_collinearity_check = self . num_collinearity_checks as usize ;
929
930
let mut a_indices = proof_stream. sample_indices ( domain_length, num_collinearity_check) ;
930
931
931
- let tree_height = self . domain_length . ilog2 ( ) as usize ;
932
+ let tree_height = self . domain_length . ilog2 ( ) ;
932
933
let fri_response = proof_stream
933
934
. dequeue ( )
934
935
. unwrap ( )
@@ -985,9 +986,11 @@ impl FriVerify {
985
986
986
987
// verify authentication paths for A leafs
987
988
for indexed_leaf in indexed_a_leaves. iter ( ) . rev ( ) {
988
- let authentication_path = & nondeterministic_digests[ num_nondeterministic_digests_read
989
- ..( num_nondeterministic_digests_read + tree_height) ] ;
990
- num_nondeterministic_digests_read += tree_height;
989
+ let auth_path_end = num_nondeterministic_digests_read
990
+ + usize:: try_from ( tree_height) . expect ( U32_TO_USIZE_ERR ) ;
991
+ let authentication_path =
992
+ & nondeterministic_digests[ num_nondeterministic_digests_read..auth_path_end] ;
993
+ num_nondeterministic_digests_read = auth_path_end;
991
994
let inclusion_proof = MerkleTreeInclusionProof {
992
995
tree_height,
993
996
indexed_leafs : vec ! [ * indexed_leaf] ,
@@ -1048,10 +1051,11 @@ impl FriVerify {
1048
1051
1049
1052
// verify authentication paths for B leafs
1050
1053
for indexed_leaf in indexed_b_leaves. iter ( ) . rev ( ) {
1051
- let authentication_path = & nondeterministic_digests
1052
- [ num_nondeterministic_digests_read
1053
- ..( num_nondeterministic_digests_read + current_tree_height) ] ;
1054
- num_nondeterministic_digests_read += current_tree_height;
1054
+ let auth_path_end = num_nondeterministic_digests_read
1055
+ + usize:: try_from ( current_tree_height) . expect ( U32_TO_USIZE_ERR ) ;
1056
+ let authentication_path =
1057
+ & nondeterministic_digests[ num_nondeterministic_digests_read..auth_path_end] ;
1058
+ num_nondeterministic_digests_read = auth_path_end;
1055
1059
let inclusion_proof = MerkleTreeInclusionProof {
1056
1060
tree_height : current_tree_height,
1057
1061
indexed_leafs : vec ! [ * indexed_leaf] ,
0 commit comments