IObscuraDispatcherTrait
Fully qualified path: obscura::interface::IObscuraDispatcherTrait
pub trait IObscuraDispatcherTrait<T>
Trait functions
register
Registers a new account in the privacy system.This function allows users to register their public key for encrypted communication. Only the owner of the account can register it, ensuring proper key management. # Arguments * account
- The account information containing owner address and public key # Events Emits a PublicKey
event with the registered account information. # Security - Only the account owner can register their own account - Public key is stored for encrypted communication
Fully qualified path: obscura::interface::IObscuraDispatcherTrait::register
fn register(self: T, account: Account)
transact
Executes a privacy-preserving transaction using zero-knowledge proofs.This is the core function for privacy-preserving transactions. It verifies zero-knowledge proofs, processes token transfers, and updates the Merkle tree. # Arguments * args
- The zero-knowledge proof and transaction data * ext_data
- External data for deposits/withdrawals and fee handling # Process 1. Verifies the zero-knowledge proof is valid 2. Checks that input nullifiers haven't been spent 3. Processes external token transfers (deposits/withdrawals) 4. Updates the Merkle tree with new commitments 5. Emits events for commitments and nullifiers # Security - All cryptographic proofs are verified externally - Double-spending is prevented through nullifier tracking - External data consistency is enforced
Fully qualified path: obscura::interface::IObscuraDispatcherTrait::transact
fn transact(self: T, args: Proof, ext_data: ExtData)
register_and_transact
Combines account registration and transaction execution in a single call.This convenience function allows new users to register and immediately perform their first privacy-preserving transaction. # Arguments * account
- The account information to register * args
- The zero-knowledge proof and transaction data * ext_data
- External data for deposits/withdrawals and fee handling # Process 1. Registers the account (equivalent to calling register
) 2. Executes the transaction (equivalent to calling transact
) # Use Case - Optimizes gas usage for new users - Reduces the number of required transactions
Fully qualified path: obscura::interface::IObscuraDispatcherTrait::register_and_transact
fn register_and_transact(self: T, account: Account, args: Proof, ext_data: ExtData)
configure_limits
Configures system limits and parameters (owner-only function).This administrative function allows the contract owner to update system parameters such as maximum deposit amounts. # Arguments * maximum_deposit_amount
- The new maximum amount allowed for deposits # Access Control - Only the contract owner can call this function - Used for system maintenance and parameter updates
Fully qualified path: obscura::interface::IObscuraDispatcherTrait::configure_limits
fn configure_limits(self: T, maximum_deposit_amount: u256)
calculate_public_amount
Calculates the public amount for zero-knowledge proof verification.This function computes the public amount that must be consistent with the external data and zero-knowledge proof for transaction validation. # Arguments * ext_amount
- The external amount (positive for deposits, negative for withdrawals) * fee
- The transaction fee paid to the relayer # Returns * The calculated public amount for proof verification # Formula public_amount = ext_amount - fee (with proper field arithmetic)
Fully qualified path: obscura::interface::IObscuraDispatcherTrait::calculate_public_amount
fn calculate_public_amount(self: T, ext_amount: I256, fee: u256) -> u256
is_spent
Checks if a nullifier has already been spent.This function verifies whether a specific nullifier has been used in a previous transaction, preventing double-spending. # Arguments * nullifier_hash
- The nullifier hash to check # Returns * true
if the nullifier has been spent, false
otherwise # Security - Critical for preventing double-spending attacks - Used during transaction verification
Fully qualified path: obscura::interface::IObscuraDispatcherTrait::is_spent
fn is_spent(self: T, nullifier_hash: u256) -> bool
field_size
Returns the finite field size used in cryptographic operations.This function provides access to the system's mathematical foundation for external verification and compatibility checks. # Returns * The field size constant used in zero-knowledge proofs
Fully qualified path: obscura::interface::IObscuraDispatcherTrait::field_size
fn field_size(self: T) -> u256
max_ext_amount
Returns the maximum allowed external amount for transactions.This function provides the current system limit for deposits and withdrawals to ensure compliance. # Returns * The maximum external amount constant
Fully qualified path: obscura::interface::IObscuraDispatcherTrait::max_ext_amount
fn max_ext_amount(self: T) -> u256
min_ext_amount
Returns the minimum allowed external amount for transactions.This function provides the current system minimum for deposits and withdrawals to prevent dust attacks. # Returns * The minimum external amount constant
Fully qualified path: obscura::interface::IObscuraDispatcherTrait::min_ext_amount
fn min_ext_amount(self: T) -> u256
max_fee
Returns the maximum allowed fee amount for transactions.This function provides the current system limit for transaction fees to prevent economic attacks. # Returns * The maximum fee constant
Fully qualified path: obscura::interface::IObscuraDispatcherTrait::max_fee
fn max_fee(self: T) -> u256