@@ -246,19 +246,17 @@ impl<C: CurveGroup> KeyResharing<Self> for FeldmanVss<C> {
246
246
fn combine (
247
247
old_pp : & FeldmanVssPublicParam ,
248
248
new_pp : & FeldmanVssPublicParam ,
249
- send_node_indices : & [ usize ] ,
250
- row_commitments : & [ FeldmanCommitment < C > ] ,
251
249
recv_node_idx : usize ,
252
- recv_reshares : & [ C :: ScalarField ] ,
250
+ reshares : impl ExactSizeIterator < Item = ( usize , C :: ScalarField , FeldmanCommitment < C > ) > + Clone ,
253
251
) -> Result < ( C :: ScalarField , FeldmanCommitment < C > ) , VssError > {
254
252
// input validation
255
253
let n = old_pp. n . get ( ) ;
256
- if send_node_indices . is_empty ( ) || row_commitments . is_empty ( ) || recv_reshares . is_empty ( ) {
254
+ if reshares . len ( ) == 0 {
257
255
return Err ( VssError :: EmptyReshare ) ;
258
256
}
259
- for idx in send_node_indices . iter ( ) {
260
- if * idx >= n {
261
- return Err ( VssError :: IndexOutOfBound ( n - 1 , * idx) ) ;
257
+ for ( idx, _ , _ ) in reshares . clone ( ) {
258
+ if idx >= n {
259
+ return Err ( VssError :: IndexOutOfBound ( n - 1 , idx) ) ;
262
260
}
263
261
}
264
262
@@ -267,24 +265,23 @@ impl<C: CurveGroup> KeyResharing<Self> for FeldmanVss<C> {
267
265
if recv_node_idx >= new_n {
268
266
return Err ( VssError :: IndexOutOfBound ( new_n - 1 , recv_node_idx) ) ;
269
267
}
270
- if row_commitments. iter ( ) . any ( |cm| cm. len ( ) != new_t) {
271
- return Err ( VssError :: InvalidCommitment ) ;
272
- }
273
-
274
- let subset_size = recv_reshares. len ( ) ;
275
- if send_node_indices. len ( ) != subset_size || row_commitments. len ( ) != subset_size {
276
- return Err ( VssError :: MismatchedInputLength ) ;
268
+ for ( _, _, row_commitment) in reshares. clone ( ) {
269
+ if row_commitment. len ( ) != new_t {
270
+ return Err ( VssError :: InvalidCommitment ) ;
271
+ }
277
272
}
278
273
279
274
// interpolate reshares to get new secret share
280
- let eval_points: Vec < _ > = send_node_indices
281
- . iter ( )
282
- . map ( |& idx| C :: ScalarField :: from ( idx as u64 + 1 ) )
275
+ let eval_points: Vec < _ > = reshares
276
+ . clone ( )
277
+ . map ( |( idx, _ , _ ) | C :: ScalarField :: from ( idx as u64 + 1 ) )
283
278
. collect ( ) ;
284
- let new_secret = interpolate :: < C > ( & eval_points, recv_reshares)
279
+ let recv_reshares: Vec < _ > = reshares. clone ( ) . map ( |( _, share, _) | share) . collect ( ) ;
280
+ let new_secret = interpolate :: < C > ( & eval_points, & recv_reshares)
285
281
. map_err ( |e| VssError :: FailedCombine ( e. to_string ( ) ) ) ?;
286
282
287
283
// interpolate in the exponent to get new Feldman commitment
284
+ let row_commitments: Vec < _ > = reshares. map ( |( _, _, commitment) | commitment) . collect ( ) ;
288
285
let new_commitment = ( 0 ..new_t)
289
286
. into_par_iter ( )
290
287
. map ( |j| {
@@ -455,15 +452,10 @@ mod tests {
455
452
let selected_row_commitments: Vec < FeldmanCommitment < _ > > =
456
453
( 0 ..old_t) . map ( |i| row_commitments[ i] . clone ( ) ) . collect ( ) ;
457
454
458
- let ( new_secret_share, new_commitment) = FeldmanVss :: < G1Projective > :: combine (
459
- & old_pp,
460
- & new_pp,
461
- & ( 0 ..old_t) . collect :: < Vec < _ > > ( ) ,
462
- & selected_row_commitments,
463
- j,
464
- & recv_reshares,
465
- )
466
- . unwrap ( ) ;
455
+ let reshares_iter =
456
+ ( 0 ..old_t) . map ( |i| ( i, recv_reshares[ i] , selected_row_commitments[ i] . clone ( ) ) ) ;
457
+ let ( new_secret_share, new_commitment) =
458
+ FeldmanVss :: < G1Projective > :: combine ( & old_pp, & new_pp, j, reshares_iter) . unwrap ( ) ;
467
459
468
460
new_shares. push ( new_secret_share) ;
469
461
new_commitments. push ( new_commitment) ;
0 commit comments