Skip to content

Commit

Permalink
replace assert with error
Browse files Browse the repository at this point in the history
  • Loading branch information
cbeck88 committed Apr 26, 2022
1 parent cdd2383 commit e43d042
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
5 changes: 4 additions & 1 deletion transaction/core/src/ring_signature/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

//! Errors which can occur in connection to ring signatures
use crate::range_proofs::error::Error as RangeProofError;
use crate::{range_proofs::error::Error as RangeProofError, TokenId};
use alloc::string::{String, ToString};
use displaydoc::Display;
use serde::{Deserialize, Serialize};
Expand Down Expand Up @@ -81,6 +81,9 @@ pub enum Error {

/// Missing expected range proofs (expected: {0}, found: {1})
MissingRangeProofs(usize, usize),

/// No commitments were found for {0}, this is a logic error
NoCommitmentsForTokenId(TokenId),
}

impl From<mc_util_repr_bytes::LengthMismatch> for Error {
Expand Down
7 changes: 3 additions & 4 deletions transaction/core/src/ring_signature/rct_bulletproofs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -510,10 +510,9 @@ fn sign_with_balance_check<CSPRNG: RngCore + CryptoRng>(
}))
.unzip();

assert!(
!values.is_empty(),
"logic error when accumulating commitments for token id"
);
if values.is_empty() {
return Err(Error::NoCommitmentsForTokenId(token_id));
}

let (range_proof, _commitments) =
generate_range_proofs(&values, &blindings, generator, rng)?;
Expand Down

0 comments on commit e43d042

Please sign in to comment.