Skip to content

Private RPC (Verifiable PIR)

Standard Ethereum JSON-RPC leaks every address a wallet or agent checks to the RPC provider. POA supports Verifiable Single-Server Private Information Retrieval (PIR) over plinko-rpc: the client retrieves account state without revealing which address it queried, and cryptographically verifies every answer against the committed block state_root.

Deployment status (chain 77): https://rpc.poa.net (returning committed stateRoot in block headers), GET https://poa.net/77/api/v2/blocks/:id/state-root-opening (returning the 576-byte state_root opening), and the public test 2d-pir-server endpoint (https://pir.poa.net, hosted alongside the verifier database on aya with OHTTP enabled) are live on production POA.

2d-pir-rpc-adapter sits between your wallet (or agent) and the network. It exposes a standard Ethereum JSON-RPC 2.0 interface (Chain ID 77) and enforces fail-closed privacy rules:

MethodHow it is servedAddress leaked to RPC?
eth_getBalance, eth_getTransactionCountPlinko 2-level PIR over state.accounts + Subtree-Cut SMT proofNo (anonymity set = all accounts in state.accounts)
eth_call (PqAccountRegistry: hasPqKey, getPqKeyHash)Local execution against PIR-verified account recordNo
eth_getBlockBy*, eth_getTransaction*, eth_getLogs, eth_feeHistoryLocal rolling BlockCache populated from public block streamsNo (per-address log filtering happens locally)
eth_chainId, net_version, eth_gasPrice, eth_estimateGas, eth_getCodeLocal deterministic rules and precompile registryNo
eth_sendRawTransactionForwarded only to explicit --tx-relay (never silent fallback)Signed transaction is public once broadcast
Historical/uncached state, block, log, or fee-history queries and unsupported eth_call targetsRejected fail-closed with JSON-RPC error -32098 (unknown JSON-RPC methods return -32601)No

Cryptographic verification and trust boundaries

Section titled “Cryptographic verification and trust boundaries”
  1. Zero trust in the PIR server (2d-pir-server) for correctness: every PIR reply carries a Subtree-Cut Sparse Merkle Tree inclusion or non-inclusion proof against accounts_root. The adapter fetches the block’s state_root from the trusted public chain RPC (https://rpc.poa.net), fetches the 576-byte opening from GET https://poa.net/77/api/v2/blocks/:id/state-root-opening, verifies keccak256(opening) == block.state_root, and checks the PIR proof against sub_roots[0] (accounts_root).
  2. Fail-closed poison latch (-32099): if a PIR answer or delta ever fails cryptographic verification, the adapter permanently latches poisoned = true, stops serving reads, and returns -32099 instead of falling back to an unverified RPC.
  3. Freshness gating (-32098): "latest" reads are bound to eth_blockNumber from --chain-rpc-url. If the PIR origin rolls back or lags beyond --max-tip-lag-blocks (default 32), "latest" reads fail closed with -32098.
  4. Anonymity set even with a single user: PIR hides which bucket of state.accounts is queried from the server. Privacy holds against the PIR operator even when only one user is active.
  5. What PIR does not hide on its own: PIR hides which address you read from the PIR server, not your IP address on eth_sendRawTransaction or transport-level timing on public metadata fetches (/pir/v1/manifest, /pir/v1/2d/epochs, snapshots, deltas). To unlink your IP from private PIR queries, enable RFC 9458 Oblivious HTTP (--ohttp-relay + --ohttp-keys-hex, or env vars PIR_OHTTP_RELAY_URL + PIR_OHTTP_KEYS_HEX, built into 2d-pir-rpc-adapter).
Section titled “Recommended setup: personal container on Railway”

Because MetaMask and Rabby cannot run native Rust PIR hint generation inside the browser extension without heavy memory overhead, the recommended way to use PIR is a personal single-owner container on Railway (or Fly.io). Only you hold the URL secret, and the container sleeps automatically when your wallet is idle.

Generate a 32-byte random token once and save it in your password manager (you will need the exact value for both Railway and your wallet):

Terminal window
openssl rand -hex 32

Create a new Railway service connected to the igor53627/2d repository and configure it in Railway Service Settings (for newly created services, configure these fields in the Railway UI or a Railway Template rather than relying on railway.toml Config as Code):

  • Source -> Root Directory: native/pir_rpc_adapter (Railway auto-detects Dockerfile in that directory)
  • Deploy -> Healthcheck Path: /healthz
  • Deploy -> Serverless / App Sleeping: Enabled
  • Networking -> Public Networking: click Generate Domain (or attach a custom domain) so the service gets a public HTTPS hostname (<your-railway-domain>)

Set the following service variables:

VariableValue
PIR_RPC_SECRET_TOKENYour 64-hex-char token from step 1
PIR_ORIGIN_URLhttps://pir.poa.net
CHAIN_RPC_URLhttps://rpc.poa.net
EXPLORER_API_URLhttps://poa.net/77
TX_RELAY_URLhttps://rpc.poa.net
PIR_ALLOW_REMOTE_BINDtrue
PIR_IDLE_PAUSE_SECS300
PIR_SYNC_THREADS1
CHAIN_ID77

With App Sleeping enabled in Railway Service Settings and PIR_IDLE_PAUSE_SECS=300, the adapter pauses background block polling after 5 minutes without wallet JSON-RPC traffic so Railway puts the container to sleep. The next wallet request wakes the container, triggers a catch-up sync (waiting up to 10 seconds), and resumes private reads.

Add a custom network in MetaMask or Rabby:

SettingValue
Network NamePOA — Private (PIR)
RPC URLhttps://<your-railway-domain>/rpc/<PIR_RPC_SECRET_TOKEN>
Chain ID77
Currency SymbolUSDC
Block Explorerhttps://poa.net/77
  • Token authentication: in remote-bind mode (--allow-remote-bind), startup fails unless --rpc-secret-token (32 to 256 URL-safe ASCII bytes) is configured. POST / returns 401; JSON-RPC is accepted only at POST /rpc/<token> using constant-time comparison. Browser web Origin headers are rejected with 403 (wallet extension origins and native HTTP clients are allowed).
  • Health checks: GET /healthz stays unauthenticated for Railway/Fly liveness probes, never resets the idle timer, and returns only {"ok", "poisoned"} so third parties cannot observe wallet activity. Full diagnostics live at GET /rpc/<token>/healthz with Cache-Control: no-store.
  • Platform access logs: because MetaMask and Rabby do not support custom Authorization headers, the credential lives in the URL path (/rpc/<token>). Hosting platforms log request paths by default: run the container in a personal account without shared log drains, and rotate PIR_RPC_SECRET_TOKEN if logs are ever exported.
  • Wake-up timing: --idle-pause-secs reduces idle cost, but public metadata fetches upon wake can indicate when the container became active (queried addresses remain hidden behind PIR). Omit PIR_IDLE_PAUSE_SECS if you prefer continuous background polling.

Alternative: Fly.io or local loopback (127.0.0.1:8545)

Section titled “Alternative: Fly.io or local loopback (127.0.0.1:8545)”
  • Fly.io: from native/pir_rpc_adapter/, create a uniquely named app (fly apps create <your-app>), set the same secrets with fly secrets set --app <your-app> --config deploy/fly.toml ..., and run fly deploy --app <your-app> --config deploy/fly.toml (or update app = "<your-app>" in deploy/fly.toml). deploy/fly.toml uses auto_stop_machines = "suspend" (256 MB RAM) so PIR hints stay warm in suspended RAM and resume in ~300 ms.
  • Local machine (no cloud hosting): run the binary directly on loopback:
Terminal window
cd native/pir_rpc_adapter
cargo run --release --bin 2d-pir-rpc-adapter -- \
--pir-origin https://pir.poa.net \
--chain-rpc-url https://rpc.poa.net \
--explorer-api-url https://poa.net/77 \
--tx-relay https://rpc.poa.net

Then connect MetaMask or Rabby to http://127.0.0.1:8545 (Chain ID 77).

Treasuries, market makers, and autonomous x402 agents can run 2d-pir-rpc-adapter as a private sidecar container (on loopback or inside a private VPC):

  • Private counterparty checks: verify balances, nonces, and ML-DSA-65 key registration before signing a transfer or honoring an x402 invoice without revealing watched accounts to external RPC operators.
  • Cryptographic pre-flight verification: every balance and nonce read is proven against the stateRoot fetched from your trusted CHAIN_RPC_URL, preventing a malicious or compromised PIR server from spoofing counterparty solvency (if CHAIN_RPC_URL itself is compromised, run your own verifier node as the trusted chain RPC).
  • Strict fail-closed behavior: set no --upstream fallback; if verification fails (-32099) or freshness degrades (-32098), the agent halts the payment flow instead of acting on unverified state.

Operators running a POA verifier or archive node can serve a Verifiable PIR endpoint from a read-only PostgreSQL replica (history.blocks and state.accounts) using consistent REPEATABLE READ READ ONLY MVCC snapshots:

Terminal window
cd native/pir_rpc_adapter
cargo run --release --features server --bin 2d-pir-server -- \
--database-url "postgres://[email protected]:5432/chain_prod" \
--bind 127.0.0.1 \
--port 8080 \
--enable-ohttp

2d-pir-server validates every snapshot’s PoaAccountSmt root against the block’s 576-byte state_root_opening before publishing, auto-scales (cut_depth, bucket_capacity) on bucket overflow with zero plaintext overflow leaks, and exposes:

  • GET /pir/v1/manifest, GET /pir/v1/tables/{name}/{table_epoch}/snapshots/{epoch}, GET /pir/v1/tables/{name}/{table_epoch}/deltas/{from}..{to}, POST /pir/v1/tables/{name}/query (plinko-rpc binary wire format)
  • GET /pir/v1/2d/epochs (epoch-to-block anchor list)
  • GET /pir/v1/ohttp-keys, POST /pir/v1/ohttp (RFC 9458 OHTTP gateway when --enable-ohttp is set)
  • GET /healthz
  • State root opening API: GET https://poa.net/77/api/v2/blocks/:id/state-root-opening (returns the 576-byte opening whose hash matches block.state_root, with accounts_root at sub_roots[0]; see State roots)
  • Adapter and server crate: native/pir_rpc_adapter in igor53627/2d
  • Plinko PIR and plinko-rpc library: igor53627/plinko-rs
  • Architecture decision: backlog/decisions/decision-10 in igor53627/2d