@@ -252,7 +252,7 @@ impl<C: CurveGroup> KeyResharing<Self> for FeldmanVss<C> {
252
252
recv_reshares : & [ C :: ScalarField ] ,
253
253
) -> Result < ( C :: ScalarField , FeldmanCommitment < C > ) , VssError > {
254
254
// input validation
255
- let n = old_pp. n . get ( ) as usize ;
255
+ let n = old_pp. n . get ( ) ;
256
256
if send_node_indices. is_empty ( ) || row_commitments. is_empty ( ) || recv_reshares. is_empty ( ) {
257
257
return Err ( VssError :: EmptyReshare ) ;
258
258
}
@@ -262,8 +262,8 @@ impl<C: CurveGroup> KeyResharing<Self> for FeldmanVss<C> {
262
262
}
263
263
}
264
264
265
- let new_n = new_pp. n . get ( ) as usize ;
266
- let new_t = new_pp. t . get ( ) as usize ;
265
+ let new_n = new_pp. n . get ( ) ;
266
+ let new_t = new_pp. t . get ( ) ;
267
267
if recv_node_idx >= new_n {
268
268
return Err ( VssError :: IndexOutOfBound ( new_n - 1 , recv_node_idx) ) ;
269
269
}
@@ -387,14 +387,20 @@ mod tests {
387
387
}
388
388
389
389
// Core key resharing workflow
390
- fn run_reshare_scenario ( old_t : u32 , old_n : u32 , new_t : u32 , new_n : u32 , rng : & mut impl Rng ) {
390
+ fn run_reshare_scenario (
391
+ old_t : usize ,
392
+ old_n : usize ,
393
+ new_t : usize ,
394
+ new_n : usize ,
395
+ rng : & mut impl Rng ,
396
+ ) {
391
397
let old_pp = FeldmanVssPublicParam :: new (
392
- NonZeroU32 :: new ( old_t) . unwrap ( ) ,
393
- NonZeroU32 :: new ( old_n) . unwrap ( ) ,
398
+ NonZeroUsize :: new ( old_t) . unwrap ( ) ,
399
+ NonZeroUsize :: new ( old_n) . unwrap ( ) ,
394
400
) ;
395
401
let new_pp = FeldmanVssPublicParam :: new (
396
- NonZeroU32 :: new ( new_t) . unwrap ( ) ,
397
- NonZeroU32 :: new ( new_n) . unwrap ( ) ,
402
+ NonZeroUsize :: new ( new_t) . unwrap ( ) ,
403
+ NonZeroUsize :: new ( new_n) . unwrap ( ) ,
398
404
) ;
399
405
400
406
let secret = Fr :: rand ( rng) ;
@@ -420,8 +426,8 @@ mod tests {
420
426
}
421
427
422
428
// Verify reshares
423
- for i in 0 ..old_n as usize {
424
- for j in 0 ..new_n as usize {
429
+ for i in 0 ..old_n {
430
+ for j in 0 ..new_n {
425
431
assert ! (
426
432
FeldmanVss :: <G1Projective >:: verify_reshare(
427
433
& old_pp,
@@ -440,20 +446,19 @@ mod tests {
440
446
let mut new_shares = Vec :: new ( ) ;
441
447
let mut new_commitments = Vec :: new ( ) ;
442
448
443
- for j in 0 ..new_n as usize {
444
- let recv_reshares: Vec < Fr > = ( 0 ..old_t as usize )
449
+ for j in 0 ..new_n {
450
+ let recv_reshares: Vec < Fr > = ( 0 ..old_t)
445
451
. collect :: < Vec < _ > > ( )
446
452
. iter ( )
447
453
. map ( |& i| reshare_matrix[ i] [ j] )
448
454
. collect ( ) ;
449
- let selected_row_commitments: Vec < FeldmanCommitment < _ > > = ( 0 ..old_t as usize )
450
- . map ( |i| row_commitments[ i] . clone ( ) )
451
- . collect ( ) ;
455
+ let selected_row_commitments: Vec < FeldmanCommitment < _ > > =
456
+ ( 0 ..old_t) . map ( |i| row_commitments[ i] . clone ( ) ) . collect ( ) ;
452
457
453
458
let ( new_secret_share, new_commitment) = FeldmanVss :: < G1Projective > :: combine (
454
459
& old_pp,
455
460
& new_pp,
456
- & ( 0 ..old_t as usize ) . collect :: < Vec < _ > > ( ) ,
461
+ & ( 0 ..old_t) . collect :: < Vec < _ > > ( ) ,
457
462
& selected_row_commitments,
458
463
j,
459
464
& recv_reshares,
@@ -477,7 +482,7 @@ mod tests {
477
482
// Reconstruct secret
478
483
let reconstructed_secret = FeldmanVss :: < G1Projective > :: reconstruct (
479
484
& new_pp,
480
- ( 0 ..new_t as usize ) . map ( |i| ( i, new_shares[ i] ) ) ,
485
+ ( 0 ..new_t) . map ( |i| ( i, new_shares[ i] ) ) ,
481
486
)
482
487
. unwrap ( ) ;
483
488
0 commit comments