Skip to main content

API Reference

Complete API reference for the Privacy Boost iOS SDK.

Generated Documentation

Full API documentation can be generated using cargo doc:

PrivacyBoost

Main SDK class for iOS.

Constructor

Creates a new SDK instance. Parameters:
  • config - SDK configuration
Throws: SDKError.internalError if initialization fails

Properties

Connection & Authentication Methods

authenticate

Connect a wallet, derive privacy keys, and authenticate with the Privacy Boost backend in a single call. Parameters:
  • wallet - Implementation of WalletDelegate protocol
  • keySource - Optional key derivation source. If nil and no persistence is configured, defaults to .walletDerived. If nil with persistence configured and no existing vault, an error is thrown.
  • tokenProvider - Optional custom token provider. If nil, the SDK sends the login payload directly to the Privacy Boost backend. Supply a TokenProvider to route authentication through your own server.
Returns: AuthResult - either .authenticated(LoginResult) or .credentialRequired(CredentialChallenge) Throws:
  • SDKError.walletError if signing fails
  • SDKError.invalidConfig if configuration is invalid or keySource is required but missing
  • SDKError.networkError if backend unreachable

submitCredential

Submit a credential when authenticate() returns .credentialRequired. Parameters:
  • credential - The credential string
  • tokenProvider - Optional custom token provider for routing authentication through your own server
Returns: LoginResult with privacy address and MPK

logout

End session completely, clear all state.

clearSession

Clear JWT only, keep keys for quick re-auth.

State Accessors

Balance Methods

getBalance

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

getAllBalances

Get all token balances.

Vault Operations

deposit

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

withdraw

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

send

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

prepareShield

Build a deposit payload without submitting it — for callers that relay the transaction themselves (a gasless relayer, an EIP-7702 session key, or a plain raw transaction). Returns the calldata to relay plus the note commitment; nothing is sent on-chain and no wallet is used. After relaying, pass the mined receipt to the top-level finalizeShield(...) to recover the on-chain request id. Parameters:
  • tokenAddress - Token contract address (zero address = native ETH)
  • amount - Amount in wei (as string)
  • recipient - (Optional) recipient privacy address. Pass nil to shield to yourself.
Returns: PreparedShield with the calls to relay and the note commitment

Transaction History

Get transaction history. Parameters:
  • txType - Filter by type: “deposit”, “withdraw”, “transfer”
  • tokenAddress - Filter by token
  • limit - Maximum results

Session Persistence

exportSession

Export session data for persistence. Returns: ExportedSession or nil if not authenticated

importSession

Import a previously exported session. Returns: true if session is valid and imported

Address Lookup

resolveIdentity

Look up a user’s privacy address by MPK or Ethereum address. Parameters:
  • identifier - MPK or Ethereum address
Returns: IdentityResult with privacy address and public keys

Utilities


Module Functions

  • sdkVersion() — Returns the SDK version string
  • generateMnemonic() — Generates a random 12-word BIP-39 mnemonic

Stateless shield helpers

Top-level functions for building a deposit payload without a signed-in session — for a backend that holds only a recipient’s privacy address. No wallet, no private keys.
buildShieldPayload builds a recipient-targeted deposit payload from public material only. Resolve tokenId, shieldContractAddress, and teePublicKey from the token catalog / config. An ephemeral sender keypair is generated and discarded internally, and the note is spendable only by recipient. wethContractAddress is required only when shielding native ETH; minShieldAmount (per-token minimum in wei) rejects below-minimum deposits; emitApprove emits the ERC-20 approve call (pass true by default). finalizeShield recovers the on-chain shield request id from the mined receipt of a relayed deposit. Stateless — the caller obtained the receipt from its own relay/RPC. Throws if the deposit reverted or the DepositRequested log is absent.

Types

PrivacyBoostConfig

KeySource

Specifies how privacy keys are derived. Passed as an optional parameter to authenticate().
  • walletDerived - Derive keys from a deterministic wallet signature (default when no persistence configured)
  • mnemonic - Derive keys from a BIP-39 mnemonic phrase
  • rawSeed - Derive keys from raw hex entropy (for testing)

AuthResult

LoginResult

TokenBalance

ShieldResult

Returned by shield and finalizeShield.

UnshieldResult

TransferResult

For an ordinary send(), giftRecord and claimLink are nil; they are populated by the gift funding methods.

Call

A single on-chain call to relay. value and data are 0x-hex.

PreparedShield

Returned by prepareShield and buildShieldPayload.

TransactionReceipt

The mined-receipt record passed to finalizeShield.

Transaction

IdentityResult

ExportedSession

data is an opaque serialized core session. Store and pass it back unchanged; do not parse or persist individual key fields.

WalletDelegate Protocol


TokenProvider Protocol

Implement this protocol to route authentication through your own server. The SDK serializes the login payload as a JSON string and passes it to getToken(). Your implementation should forward this payload to your backend, which adds its own credentials and calls the Privacy Boost API.

TokenResponse

Example


SDKError


Gift Methods

Claimable transfers (gifts). See the Claimable Transfers guide and the concept page.
Preview feature — pending external audit, and enabled per deployment. These methods may not be present in the checked-in generated Swift bindings.
Each fund/claim/refund method returns a TransferResult whose giftRecord and claimLink fields are populated for gift operations.

giftFundToWallet

Fund a gift bound to an Ethereum wallet address that may not be registered with Privacy Boost. Parameters:
  • tokenAddress - Token contract address
  • amount - Amount in wei (as string)
  • recipientWallet - Recipient’s Ethereum address the gift binds to
  • refundAfterBlock - Block height after which an unclaimed gift may be reclaimed
  • currentBlock - Current chain head; pre-validates the refund delay
Returns: TransferResult with claimLink and giftRecord populated

giftFund

Fund a gift when the recipient is already a Privacy Boost user, sealing the ciphertext to their viewing key. The argument label is recipientPrivacyAddress. Parameters:
  • recipientPrivacyAddress - Recipient’s 194-char privacy address (the ciphertext’s ECDH target)
  • Other parameters as in giftFundToWallet
Returns: TransferResult with claimLink and giftRecord populated

giftClaim

Claim a pending gift by its position in getPendingGifts(). Parameters:
  • index - Position in the pending-gifts list
  • acknowledgeUnknownSender - Must be true; acknowledges accepting funds from an unknown sender

giftClaimByCGift

Claim a pending gift by its stable commitment cGift (preferred when the list may shift as gifts settle).
Claim a gift directly from a pbgift:v1:... claim link, without a server lookup first.

giftRefundByRecord

Refund an unclaimed gift after its deadline, using a local gift record. index is the positional index into getGiftRecords().

giftRefund

Refund an unclaimed gift by supplying every field manually — the fallback when the local gift record is unavailable.

getPendingGifts

List the pending gifts addressed to the authenticated wallet.

getGiftRecords

Return the local records the SDK persisted for gifts you funded. These make a gift refundable and travel inside an exported session. Synchronous.
Decode a claim link into a preview offline, with no network call. Synchronous and throwing.
A third funding mode, giftFundSecretBearer, binds a gift to a secret instead of a wallet. It is experimental, disabled by default, and a bearer instrument (whoever holds the link can claim). See the concept page before considering it.

GiftRecord

PendingGift

GiftLinkPreview

The gift fields on TransferResult are documented under TransferResult.

Portal

Portal deposit addresses. See the Portal Deposits guide and the concept page.
Preview feature — pending external audit, and enabled per deployment. iOS exposes the portal lifecycle as methods on PrivacyBoost. Low-level portal functions are limited to custodial escape hatches.
The supported path is createPortal, which derives the portal EOA from the account seed and keeps the key inside core.

createPortal

Derive portal E, gaslessly delegate and register it via the server relays, then publish the discovery entry. Pass nil to use the next free derivation index.

listPortals

List the authenticated account’s portals with status and derivation index.

listPortalDeposits

List deposits observed at portal.

getPortalStatus

Return registry/on-chain status for one portal.

sweepPortal

Send requestPortalDeposit from the connected wallet and return the transaction hash.

reclaimPortalDeposit

Send cancelPortalDeposit from the connected wallet and return the transaction hash.

withdrawPortal

Build a signed EIP-1559 transaction that withdraws raw funds resting at the seed-derived portal E. Broadcast the returned raw transaction yourself.

Low-level escape hatches

These top-level functions are for custodial integrations that manage their own portal EOA key. The seed-derived createPortal flow does not expose a private key.

generatePortalEoa

Generate a fresh portal EOA E and its secret private key.

encodePortalWithdraw

Encode raw withdraw calldata for a custodial integration that already controls its own portal EOA.

publishPortalRegistry

Publish the discovery registry entry (E → blind) — the supported submit path so the indexer can credit deposits to the right account.

portalDelegateAddress

Return the portal delegate address advertised by the server’s /info, or nil if the server does not support portals.

PortalEoa


See Also