Skip to content

Commit

Permalink
feat: moved input and key image uniqueness checks to blst-ringct
Browse files Browse the repository at this point in the history
  • Loading branch information
grumbach authored and dan-da committed Feb 23, 2022
1 parent 1458127 commit df4da9e
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 16 deletions.
3 changes: 0 additions & 3 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,6 @@ pub enum Error {
#[error("OutputProof not found in transaction outputs")]
OutputProofNotFound,

#[error("key image is not unique across all transaction inputs")]
KeyImageNotUniqueAcrossInputs,

#[error("public key is not unique across all transaction outputs")]
PublicKeyNotUniqueAcrossOutputs,

Expand Down
14 changes: 1 addition & 13 deletions src/validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,22 +75,10 @@ impl TransactionValidator {
transaction_hash: Hash,
spent_proofs: &BTreeSet<SpentProof>,
) -> Result<(), Error> {
if transaction.mlsags.is_empty() {
return Err(Error::TransactionMustHaveAnInput);
} else if spent_proofs.len() != transaction.mlsags.len() {
if spent_proofs.len() != transaction.mlsags.len() {
return Err(Error::SpentProofInputMismatch);
}

// Verify that each KeyImage is unique in this tx.
let keyimage_unique: BTreeSet<KeyImage> = transaction
.mlsags
.iter()
.map(|m| m.key_image.into())
.collect();
if keyimage_unique.len() != transaction.mlsags.len() {
return Err(Error::KeyImageNotUniqueAcrossInputs);
}

// Verify that each pubkey is unique in this transaction.
let pubkey_unique: BTreeSet<KeyImage> = transaction
.outputs
Expand Down

0 comments on commit df4da9e

Please sign in to comment.