@@ -153,27 +153,26 @@ impl<C: CurveGroup> VerifiableSecretSharing for FeldmanVss<C> {
153
153
154
154
fn reconstruct (
155
155
pp : & Self :: PublicParam ,
156
- shares : impl Iterator < Item = ( usize , Self :: SecretShare ) > ,
156
+ shares : impl ExactSizeIterator < Item = ( usize , Self :: SecretShare ) > + Clone ,
157
157
) -> Result < Self :: Secret , VssError > {
158
- let shares = shares. collect :: < Vec < _ > > ( ) ;
159
158
let n = pp. n . get ( ) ;
160
159
let t = pp. t . get ( ) ;
161
160
// input validation
162
161
if shares. len ( ) != t {
163
162
return Err ( VssError :: MismatchedSharesCount ( t, shares. len ( ) ) ) ;
164
163
}
165
- for ( idx, _) in shares. iter ( ) {
166
- if * idx >= n {
167
- return Err ( VssError :: IndexOutOfBound ( n - 1 , * idx) ) ;
164
+ for ( idx, _) in shares. clone ( ) {
165
+ if idx >= n {
166
+ return Err ( VssError :: IndexOutOfBound ( n - 1 , idx) ) ;
168
167
}
169
168
}
170
169
171
170
// Lagrange interpolate to get back the secret
172
171
let eval_points: Vec < _ > = shares
173
- . iter ( )
174
- . map ( |& ( idx, _) | C :: ScalarField :: from ( idx as u64 + 1 ) )
172
+ . clone ( )
173
+ . map ( |( idx, _) | C :: ScalarField :: from ( idx as u64 + 1 ) )
175
174
. collect ( ) ;
176
- let evals: Vec < _ > = shares. iter ( ) . map ( |& ( _, share) | share) . collect ( ) ;
175
+ let evals: Vec < _ > = shares. map ( |( _, share) | share) . collect ( ) ;
177
176
interpolate :: < C > ( & eval_points, & evals)
178
177
. map_err ( |e| VssError :: FailedReconstruction ( e. to_string ( ) ) )
179
178
}
0 commit comments