File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed
algorithms/src/snark/varuna/data_structures Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -88,7 +88,7 @@ impl<E: PairingEngine> Commitments<E> {
88
88
compress : Compress ,
89
89
validate : Validate ,
90
90
) -> Result < Self , snarkvm_utilities:: SerializationError > {
91
- let mut w = Vec :: with_capacity ( batch_sizes . iter ( ) . sum ( ) ) ;
91
+ let mut w = Vec :: new ( ) ;
92
92
for batch_size in batch_sizes {
93
93
w. extend ( deserialize_vec_without_len ( & mut reader, compress, validate, * batch_size) ?) ;
94
94
}
@@ -261,7 +261,11 @@ impl<E: PairingEngine> Proof<E> {
261
261
262
262
/// Check that the number of messages is consistent with our batch size
263
263
pub fn check_batch_sizes ( & self ) -> Result < ( ) , SNARKError > {
264
- let total_instances = self . batch_sizes . iter ( ) . sum :: < usize > ( ) ;
264
+ let total_instances = self
265
+ . batch_sizes
266
+ . iter ( )
267
+ . try_fold ( 0usize , |acc, & size| acc. checked_add ( size) )
268
+ . ok_or ( SNARKError :: BatchSizeMismatch ) ?;
265
269
if self . commitments . witness_commitments . len ( ) != total_instances {
266
270
return Err ( SNARKError :: BatchSizeMismatch ) ;
267
271
}
You can’t perform that action at this time.
0 commit comments