Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.privacyboost.io/llms.txt

Use this file to discover all available pages before exploring further.

Android SDK

The Privacy Boost Android SDK is a native Kotlin library that wraps the Rust core via UniFFI. It exposes idiomatic Kotlin APIs (suspend functions, sealed classes, data classes) for shielding, unshielding, and private transfers.

Features

  • Native Kotlin library — no JavaScript bridge, no WebView
  • suspend functions integrated with Kotlin coroutines
  • SdkException sealed class — exhaustive when matching on error variants
  • Drop-in defaults for Android Keystore, CredentialManager Passkey (Android 14+), and BiometricPrompt
  • Wallet-agnostic — implement WalletDelegate once for any signer
  • Identical core to the TypeScript / iOS / React Native SDKs (same proofs, same network protocol)

Installation

Add the Maven artifact to your build.gradle.kts. See the installation guide for full details.
dependencies {
    implementation("io.sunnyside:privacy-boost-android:0.2.0")
}
Then import:
import com.privacyboost.sdk.PrivacyBoost
import com.privacyboost.sdk.PrivacyBoostConfig
import com.privacyboost.defaults.withPlatformDefaults  // optional — Keystore + Passkey

Quick Example

import com.privacyboost.sdk.*

val config = PrivacyBoostConfig(
    serverUrl = "https://test-api.privacyboost.io",
    chainId = null,                  // discovered from server
    shieldContractAddress = null,    // discovered from server
    wethContractAddress = "0x4200000000000000000000000000000000000006",
    teePublicKey = null,
    appId = "app_abc123xyz",
    persistenceStorage = null,
    persistenceUnlock = null
)

val sdk = PrivacyBoost(config)

// Authenticate with a WalletDelegate you implement
val result = sdk.authenticate(
    wallet = myWalletDelegate,
    keySource = KeySource.WalletDerived(),
    tokenProvider = null
)

when (result) {
    is AuthResult.Authenticated -> {
        println("Privacy address: ${result.loginResult.privacyAddress}")
    }
    is AuthResult.CredentialRequired -> {
        // Prompt user for PIN/biometric, then call sdk.submitCredential(...)
    }
    is AuthResult.MnemonicGenerated -> {
        // First-time user — display mnemonic, then call sdk.proceedAfterMnemonic(...)
    }
    is AuthResult.RecoveryRequired -> {
        // Vault is in a recovery state — see Authentication concepts
    }
}

// Shield 1 ETH-equivalent of WETH
val amount = sdk.parseAmount("1.0", decimals = 18u)
val shielded = sdk.shield(
    tokenAddress = "0x4200000000000000000000000000000000000006",
    amount = amount
)
println("Shield tx: ${shielded.txHash}")

Core Operations

MethodPurpose
sdk.shield(tokenAddress, amount)Deposit tokens into the shielded pool
sdk.unshield(tokenAddress, amount, recipient)Withdraw to a public address
sdk.send(tokenAddress, amount, recipientPrivacyAddress)Private transfer
sdk.getBalance(tokenAddress)Single-token shielded + wallet balance
sdk.getAllBalances()All tracked balances
sdk.getTransactionHistory(...)Paginated history
sdk.resolveIdentity(identifier)Look up a privacy address
All operations are suspend functions — call them from a coroutine scope (lifecycleScope, viewModelScope, etc.).

Documentation

Getting Started

Guides

Advanced

Reference

Requirements

  • Android API 26+ (Android 8.0 Oreo)
  • API 34+ (Android 14) required for Passkey defaults
  • Kotlin 1.9+
  • AndroidX