Skip to content

Commit c7149ea

Browse files
committed
Avoid using Result<bool>
1 parent 3cfa4e1 commit c7149ea

File tree

2 files changed

+22
-15
lines changed

2 files changed

+22
-15
lines changed

timeboost-crypto/src/feldman.rs

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -230,11 +230,17 @@ impl<C: CurveGroup> KeyResharing<Self> for FeldmanVss<C> {
230230
old_commitment: &FeldmanCommitment<C>,
231231
row_commitment: &FeldmanCommitment<C>,
232232
reshare: &C::ScalarField,
233-
) -> Result<bool, VssError> {
233+
) -> Result<(), VssError> {
234234
let old_public_share = Self::derive_public_share(old_pp, send_node_idx, old_commitment)?;
235235
let new_public_share = Self::derive_public_share(new_pp, recv_node_idx, row_commitment)?;
236-
Ok(C::generator().mul(reshare) == new_public_share
237-
&& row_commitment[0] == old_public_share.into_affine())
236+
237+
if C::generator().mul(reshare) == new_public_share
238+
&& row_commitment[0] == old_public_share.into_affine()
239+
{
240+
Ok(())
241+
} else {
242+
Err(VssError::FailedVerification)
243+
}
238244
}
239245

240246
fn combine(
@@ -416,17 +422,18 @@ mod tests {
416422
// Verify reshares
417423
for i in 0..old_n as usize {
418424
for j in 0..new_n as usize {
419-
let is_valid = FeldmanVss::<G1Projective>::verify_reshare(
420-
&old_pp,
421-
&new_pp,
422-
i,
423-
j,
424-
&old_commitment,
425-
&row_commitments[i],
426-
&reshare_matrix[i][j],
427-
)
428-
.unwrap();
429-
assert!(is_valid);
425+
assert!(
426+
FeldmanVss::<G1Projective>::verify_reshare(
427+
&old_pp,
428+
&new_pp,
429+
i,
430+
j,
431+
&old_commitment,
432+
&row_commitments[i],
433+
&reshare_matrix[i][j],
434+
)
435+
.is_ok()
436+
);
430437
}
431438
}
432439

timeboost-crypto/src/traits/dkg.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ pub trait KeyResharing<VSS: VerifiableSecretSharing> {
8888
old_commitment: &VSS::Commitment,
8989
row_commitment: &VSS::Commitment,
9090
reshare: &VSS::SecretShare,
91-
) -> Result<bool, VssError>;
91+
) -> Result<(), VssError>;
9292

9393
/// Combine resharings to derive the new secret share
9494
fn combine(

0 commit comments

Comments
 (0)