diff --git a/transaction/core/src/ring_signature/error.rs b/transaction/core/src/ring_signature/error.rs index 7676a3660d..3d86a69763 100644 --- a/transaction/core/src/ring_signature/error.rs +++ b/transaction/core/src/ring_signature/error.rs @@ -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}; @@ -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 for Error { diff --git a/transaction/core/src/ring_signature/rct_bulletproofs.rs b/transaction/core/src/ring_signature/rct_bulletproofs.rs index 6d8c02c6f1..a3938579a3 100644 --- a/transaction/core/src/ring_signature/rct_bulletproofs.rs +++ b/transaction/core/src/ring_signature/rct_bulletproofs.rs @@ -510,10 +510,9 @@ fn sign_with_balance_check( })) .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)?;