Skip to main content

API Reference

Complete API reference for the Privacy Boost Android SDK.

Generated Documentation

Full API documentation can be generated using cargo doc:
# From rust-sdk directory
make docs-rust

# Android-specific docs
cargo doc --no-deps -p privacy-boost-android

PrivacyBoostSdk

Main SDK class for Android.

Constructor

PrivacyBoostSdk(config: SdkConfig)
Creates a new SDK instance. Parameters:
  • config - SDK configuration

Properties

fun isConnected(): Boolean
fun isAuthenticated(): Boolean

Connection Methods

connect

fun connect(wallet: WalletDelegate): ConnectResult
Connect a wallet and derive privacy keys. Parameters:
  • wallet - Implementation of WalletDelegate interface
Returns: ConnectResult with wallet and privacy addresses Throws:
  • SDKError.ChainMismatch if wallet is on wrong network
  • SDKError.WalletError if signing fails

disconnect

fun disconnect()
Disconnect the current wallet and clear state.

Authentication Methods

login

fun login(): LoginResult
Authenticate with the Privacy Boost backend. Returns: LoginResult with privacy address and MPK Throws:
  • SDKError.NotConnected if wallet not connected
  • SDKError.NetworkError if backend unreachable

logout

fun logout()
Log out and clear authentication state.

State Accessors

fun getPrivacyAddress(): String?
fun getMpk(): String?
fun getWalletAddress(): String?

Balance Methods

getBalance

fun getBalance(tokenAddress: String): TokenBalance
Get balance for a specific token. Parameters:
  • tokenAddress - ERC-20 token contract address
Returns: TokenBalance with shielded and wallet amounts

getAllBalances

fun getAllBalances(): List<TokenBalance>
Get all token balances.

Vault Operations

deposit

fun deposit(tokenAddress: String, amount: String): DepositResult
Deposit tokens into the shielded pool. Parameters:
  • tokenAddress - Token contract address
  • amount - Amount in wei (as string)
Returns: DepositResult with transaction hash

withdraw

fun withdraw(tokenAddress: String, amount: String, recipient: String): WithdrawResult
Withdraw tokens from the shielded pool. Parameters:
  • tokenAddress - Token contract address
  • amount - Amount in wei (as string)
  • recipient - Recipient Ethereum address
Returns: WithdrawResult with transaction hash

send

fun send(tokenAddress: String, amount: String, recipientPrivacyAddress: String): TransferResult
Send a private transfer. Parameters:
  • tokenAddress - Token contract address
  • amount - Amount in wei (as string)
  • recipientPrivacyAddress - Recipient’s 194-char privacy address
Returns: TransferResult with transaction hash

Transaction History

fun getTransactionHistory(
    txType: String?,
    tokenAddress: String?,
    limit: UInt?
): List<Transaction>
Get transaction history. Parameters:
  • txType - Filter by type: “deposit”, “withdraw”, “transfer”
  • tokenAddress - Filter by token
  • limit - Maximum results

Session Persistence

exportSession

fun exportSession(): ExportedSession?
Export session data for persistence. Returns: ExportedSession or null if not authenticated

importSession

fun importSession(session: ExportedSession): Boolean
Import a previously exported session. Returns: true if session is valid and imported

Utilities

fun isValidPrivacyAddress(address: String): Boolean
fun isValidAddress(address: String): Boolean
fun parseAmount(amount: String, decimals: UByte): String
fun formatAmount(wei: String, decimals: UByte): String

Types

SdkConfig

data class SdkConfig(
    val indexerUrl: String,
    val proverUrl: String,
    val chainId: ULong,
    val shieldContract: String,
    val wethContract: String
)

ConnectResult

data class ConnectResult(
    val walletAddress: String,
    val privacyAddress: String,
    val mpk: String
)

LoginResult

data class LoginResult(
    val privacyAddress: String,
    val mpk: String
)

TokenBalance

data class TokenBalance(
    val tokenAddress: String,
    val shieldedBalance: String,
    val walletBalance: String,
    val symbol: String?,
    val decimals: UByte
)

DepositResult

data class DepositResult(
    val txHash: String,
    val commitment: String,
    val fee: String
)

WithdrawResult

data class WithdrawResult(
    val txHash: String,
    val fee: String
)

TransferResult

data class TransferResult(
    val txHash: String,
    val fee: String
)

Transaction

data class Transaction(
    val txHash: String,
    val txType: String,
    val tokenAddress: String,
    val amount: String,
    val direction: String,
    val senderPubKey: String,
    val receiverPubKeys: List<String>,
    val createdAt: ULong
)

ExportedSession

data class ExportedSession(
    val walletPublicKeyX: String,
    val walletPublicKeyY: String,
    val viewingKey: String,
    val viewingPublicKeyX: String,
    val viewingPublicKeyY: String,
    val nullifyingKey: String,
    val nullifyingPublicKeyX: String,
    val nullifyingPublicKeyY: String,
    val mpk: String,
    val jwt: String,
    val jwtExpiry: ULong,
    val walletAddress: String
)

WalletDelegate Interface

interface WalletDelegate {
    fun getAddress(): String
    fun getChainId(): ULong
    fun signMessage(message: String): String
    fun signTypedData(typedDataJson: String): String
    fun sendTransaction(toAddress: String, value: String, data: String): String
}

SDKError

sealed class SDKError : Exception() {
    object NotConnected : SDKError()
    object NotAuthenticated : SDKError()
    data class ChainMismatch(val expected: ULong, val actual: ULong) : SDKError()
    object InsufficientBalance : SDKError()
    object InvalidAmount : SDKError()
    object InvalidRecipient : SDKError()
    object InvalidPrivacyAddress : SDKError()
    object SessionExpired : SDKError()
    data class WalletError(override val message: String) : SDKError()
    data class NetworkError(override val message: String) : SDKError()
    data class ProofError(override val message: String) : SDKError()
    data class InternalError(override val message: String) : SDKError()
}

See Also