Skip to main content

Crate darkpool_client

Crate darkpool_client 

Source
Expand description

DarkPool client SDK: identity, key management, note operations, proof generation, fee calculation, transaction building, and unified privacy client.

Re-exports§

pub use identity::BjjKeypair;
pub use identity::ClientIdentity;
pub use identity::DarkAccount;
pub use identity::X25519Keypair;
pub use key_repository::KeyRepository;
pub use key_repository::DEFAULT_LOOKAHEAD;
pub use note_factory::ChangeNoteResult;
pub use note_factory::DepositNoteResult;
pub use note_factory::NoteFactory;
pub use note_factory::NoteFactoryError;
pub use note_factory::SpendingInputs;
pub use note_factory::TransferNoteResult;
pub use note_processor::EventType;
pub use note_processor::NoteProcessor;
pub use note_processor::UnprocessedEvent;
pub use note_processor::WalletNote;
pub use merkle_tree::LocalMerkleTree;
pub use merkle_tree::MerklePath;
pub use merkle_tree::TREE_DEPTH;
pub use persistence::load_wallet_state;
pub use persistence::save_wallet_state;
pub use persistence::PersistenceError;
pub use persistence::WalletState;
pub use scan_engine::DarkPoolEvent;
pub use scan_engine::PublicMemoInfo;
pub use scan_engine::ScanEngine;
pub use scan_engine::ScanError;
pub use scan_engine::ScanResult;
pub use utxo_store::IUtxoRepository;
pub use utxo_store::OwnedNote;
pub use utxo_store::UtxoStore;
pub use crypto_helpers::calculate_public_memo_id;
pub use crypto_helpers::decrypt_note_from_fields;
pub use crypto_helpers::derive_nullifier_path_a;
pub use crypto_helpers::derive_nullifier_path_b;
pub use crypto_helpers::encrypt_note_for_deposit_aes;
pub use crypto_helpers::generate_dleq_proof;
pub use crypto_helpers::pack_ciphertext_to_fields;
pub use crypto_helpers::pack_note_plaintext;
pub use crypto_helpers::recipient_decrypt_3party;
pub use crypto_helpers::unpack_ciphertext_from_fields;
pub use crypto_helpers::unpack_note_plaintext;
pub use crypto_helpers::DleqResult;
pub use proof_inputs::DLEQProof;
pub use proof_inputs::DepositInputs;
pub use proof_inputs::GasPaymentInputs;
pub use proof_inputs::JoinInputs;
pub use proof_inputs::NotePlaintext;
pub use proof_inputs::ProverInput;
pub use proof_inputs::PublicClaimInputs;
pub use proof_inputs::SplitInputs;
pub use proof_inputs::TransferInputs;
pub use proof_inputs::WithdrawInputs;
pub use economics::FeeConfig;
pub use economics::FeeEstimate;
pub use economics::FeeManager;
pub use economics::PriceData;
pub use prover::circuits;
pub use prover::ClientProver;
pub use builder::compute_execution_hash;
pub use builder::convert_public_inputs_to_bytes32;
pub use builder::encode_multicall;
pub use builder::format_proof_for_solidity;
pub use builder::format_public_inputs_for_solidity;
pub use builder::BuilderConfig;
pub use builder::BuilderError;
pub use builder::DepositProofBundle;
pub use builder::GasPaymentBundle;
pub use builder::JoinProofBundle;
pub use builder::MulticallBundle;
pub use builder::PublicClaimProofBundle;
pub use builder::SplitProofBundle;
pub use builder::TransactionBuilder;
pub use builder::TransferProofBundle;
pub use builder::WithdrawProofBundle;
pub use config::DarkPoolConfig;
pub use config::GasLimits;
pub use config::PrivacyTxResult;
pub use privacy_client::PrivacyClient;
pub use privacy_client::PrivacyClientError;
pub use privacy_client::Transport;

Modules§

builder
ZK proof generation and transaction encoding for DarkPool operations.
config
Configuration types for DarkPool client operations.
crypto_helpers
Note-specific crypto: packing, encryption, nullifier derivation. Re-exports pure primitives from darkpool_crypto.
economics
Fee calculation: gas costs to payment-asset fees with configurable premium.
identity
Cryptographic identity management: BJJ keypairs (note ownership), X25519 keypairs (mixnet routing), and hierarchical DarkAccount key derivation.
key_repository
Ephemeral and incoming key management for blockchain event scanning. Registers lookahead keys to detect deposits (ephemeral PK match) and transfers (tag match) belonging to this wallet.
merkle_tree
32-level Lean IMT with Poseidon2 hashing, mirroring the on-chain DarkPool commitment tree. Lean IMT: sibling=0 means “empty” and propagates without hashing (matches Noir circuit).
note_factory
Note creation with encryption, commitment computation, and nullifier derivation.
note_processor
Processes blockchain events to recover notes belonging to this wallet. Path A (NewNote): deposits/change via ephemeral PK match. Path B (NewMemo): transfers via tag match + 3-party ECDH.
persistence
Save/load wallet state (UTXOs, Merkle leaves, sync checkpoint) to JSON.
privacy_client
Unified client interface for the DarkPool protocol. Combines key management, UTXO tracking, proof generation, and transport into a single API.
proof_inputs
Typed structs for ZK proof generation, formatted for NoirProver.
prover
Typed proof generation methods for all DarkPool circuits, wrapping an IProverService backend.
scan_engine
Watches DarkPool events (NewNote, NewPrivateMemo, NewPublicMemo, NullifierSpent) and syncs local note state via decryption and Merkle tree updates.
utxo_store
In-memory UTXO management with nullifier tracking and note selection.

Enums§

CryptoError

Functions§

address_to_field
Convert an Ethereum address to a field element.
aes128_decrypt
Decrypt 208-byte AES-128-CBC ciphertext, returning 192 bytes on success.
aes128_encrypt
Encrypt 192-byte plaintext using AES-128-CBC with PKCS#7 padding. Returns 208 bytes.
bjj_scalar_mul
scalar * point with full validation (on-curve + subgroup check).
derive_shared_secret_bjj
ECDH shared secret derivation. Returns X coordinate of sk * pk.
field_to_address
Convert a field element back to an Ethereum address (last 20 bytes).
fr_to_u256
Convert ark_bn254::Fr to ethers U256.
from_noir_hex
Parse a Noir hex string (0x-prefixed or raw) back to U256.
kdf_to_aes_key_iv
Derive AES key (last 16 bytes of Poseidon) and IV from shared secret.
poseidon_hash
Poseidon2 hash over U256 values. Output matches std::hash::poseidon2 in Noir.
random_field
Generate a random BN254 scalar field element.
to_noir_decimal
Convert U256 to Noir decimal string.
to_noir_hex
Convert U256 to Noir-compatible hex string (0x-prefixed, 64 chars, lowercase).
u256_to_fr
Convert ethers U256 to ark_bn254::Fr. Values >= modulus are silently reduced.