Skip to content

Commit

Permalink
add mixability validation support
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffro256 committed Mar 11, 2024
1 parent e915921 commit 944bf7c
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
7 changes: 7 additions & 0 deletions src/seraphis_main/tx_validation_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,13 @@ class TxValidationContext
*/
virtual void get_reference_set_proof_elements_v2(const std::vector<std::uint64_t> &indices,
rct::keyV &proof_elements_out) const = 0;
/**
* @brief gets the total number of on-chain, non-Seraphis enotes for a given amount in the validation context
*
* @param amount the output enote amount to get information for, with 0 meaning the RingCT dist
* @return std::uint64_t the current total number of on-chain enotes for the given amount
*/
virtual std::uint64_t get_cryptonote_global_ref_set_size(const std::uint64_t amount) const = 0;
};

} //namespace sp
18 changes: 13 additions & 5 deletions src/seraphis_main/txtype_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,24 +63,32 @@ static bool validate_txs_impl(const std::vector<const SpTxType*> &txs, const TxV
if (!validate_tx_version(*tx, tx_validation_context))
return false;

// Validate as many non-cryptographic static semantic rules against tx's nominal version as possible
// Validate as many non-cryptographic static semantic rules against tx's nominal version
// as possible
if (!validate_tx_semantics(*tx))
return false;

// Validate non-cryptographic semantic rules for this tx which are dependent on the fork version (i.e. most
// Cryptonote/RingCT rules)
// Validate non-cryptographic semantic rules for this tx which are dependent on the fork
// version (i.e. most Cryptonote/RingCT rules)
if (!validate_tx_semantics_fork_dependent(*tx, tx_validation_context))
return false;

// Validate that the key images do not exist in this validation context (and are otherwise valid)
// Validate that the key images do not exist in this validation context (and are
// otherwise valid)
if (!validate_tx_key_images(*tx, tx_validation_context))
return false;

// Validate amount balances: plaintext or confidential
if (!validate_tx_amount_balance(*tx))
return false;

// Validate membership proofs, ring sigs, etc against live data (unless done in validate_txs_batchable)
// Validate that the transaction's ring sizes and signature types are allowed given the
// current size of the on-chain global output enote sets' sizes.
if (!validate_tx_mixability(*tx, tx_validation_context))
return false;

// Validate membership proofs, ring sigs, etc against live data (unless done in
// validate_txs_batchable())
if (!validate_tx_input_proofs(*tx, tx_validation_context))
return false;
}
Expand Down
2 changes: 2 additions & 0 deletions src/seraphis_main/txtype_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ bool validate_tx_key_images(const SpTxType &tx, const TxValidationContext &tx_va
template <typename SpTxType>
bool validate_tx_amount_balance(const SpTxType &tx);
template <typename SpTxType>
bool validate_tx_mixability(const SpTxType &tx, const TxValidationContext &tx_validation_context);
template <typename SpTxType>
bool validate_tx_input_proofs(const SpTxType &tx, const TxValidationContext &tx_validation_context);
template <typename SpTxType>
bool validate_txs_batchable(const std::vector<const SpTxType*> &txs, const TxValidationContext &tx_validation_context);
Expand Down

0 comments on commit 944bf7c

Please sign in to comment.