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.
What Verifiable PIR protects
Section titled “What Verifiable PIR protects”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:
| Method | How it is served | Address leaked to RPC? |
|---|---|---|
eth_getBalance, eth_getTransactionCount | Plinko 2-level PIR over state.accounts + Subtree-Cut SMT proof | No (anonymity set = all accounts in state.accounts) |
eth_call (PqAccountRegistry: hasPqKey, getPqKeyHash) | Local execution against PIR-verified account record | No |
eth_getBlockBy*, eth_getTransaction*, eth_getLogs, eth_feeHistory | Local rolling BlockCache populated from public block streams | No (per-address log filtering happens locally) |
eth_chainId, net_version, eth_gasPrice, eth_estimateGas, eth_getCode | Local deterministic rules and precompile registry | No |
eth_sendRawTransaction | Forwarded 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 targets | Rejected 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”- 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 againstaccounts_root. The adapter fetches the block’sstate_rootfrom the trusted public chain RPC (https://rpc.poa.net), fetches the 576-byte opening fromGET https://poa.net/77/api/v2/blocks/:id/state-root-opening, verifieskeccak256(opening) == block.state_root, and checks the PIR proof againstsub_roots[0](accounts_root). - Fail-closed poison latch (
-32099): if a PIR answer or delta ever fails cryptographic verification, the adapter permanently latchespoisoned = true, stops serving reads, and returns-32099instead of falling back to an unverified RPC. - Freshness gating (
-32098):"latest"reads are bound toeth_blockNumberfrom--chain-rpc-url. If the PIR origin rolls back or lags beyond--max-tip-lag-blocks(default32),"latest"reads fail closed with-32098. - Anonymity set even with a single user: PIR hides which bucket of
state.accountsis queried from the server. Privacy holds against the PIR operator even when only one user is active. - What PIR does not hide on its own: PIR hides which address you read from the PIR server, not your IP address on
eth_sendRawTransactionor 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 varsPIR_OHTTP_RELAY_URL+PIR_OHTTP_KEYS_HEX, built into2d-pir-rpc-adapter).
Recommended setup: personal container on Railway
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.
1. Generate a private owner token
Section titled “1. Generate a private owner token”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):
openssl rand -hex 322. Deploy on Railway
Section titled “2. Deploy on Railway”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-detectsDockerfilein 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:
| Variable | Value |
|---|---|
PIR_RPC_SECRET_TOKEN | Your 64-hex-char token from step 1 |
PIR_ORIGIN_URL | https://pir.poa.net |
CHAIN_RPC_URL | https://rpc.poa.net |
EXPLORER_API_URL | https://poa.net/77 |
TX_RELAY_URL | https://rpc.poa.net |
PIR_ALLOW_REMOTE_BIND | true |
PIR_IDLE_PAUSE_SECS | 300 |
PIR_SYNC_THREADS | 1 |
CHAIN_ID | 77 |
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.
3. Add to MetaMask or Rabby
Section titled “3. Add to MetaMask or Rabby”Add a custom network in MetaMask or Rabby:
| Setting | Value |
|---|---|
| Network Name | POA — Private (PIR) |
| RPC URL | https://<your-railway-domain>/rpc/<PIR_RPC_SECRET_TOKEN> |
| Chain ID | 77 |
| Currency Symbol | USDC |
| Block Explorer | https://poa.net/77 |
Operational notes for hosted mode
Section titled “Operational notes for hosted mode”- 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 /returns401; JSON-RPC is accepted only atPOST /rpc/<token>using constant-time comparison. Browser webOriginheaders are rejected with403(wallet extension origins and native HTTP clients are allowed). - Health checks:
GET /healthzstays 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 atGET /rpc/<token>/healthzwithCache-Control: no-store. - Platform access logs: because MetaMask and Rabby do not support custom
Authorizationheaders, 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 rotatePIR_RPC_SECRET_TOKENif logs are ever exported. - Wake-up timing:
--idle-pause-secsreduces idle cost, but public metadata fetches upon wake can indicate when the container became active (queried addresses remain hidden behind PIR). OmitPIR_IDLE_PAUSE_SECSif 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 withfly secrets set --app <your-app> --config deploy/fly.toml ..., and runfly deploy --app <your-app> --config deploy/fly.toml(or updateapp = "<your-app>"indeploy/fly.toml).deploy/fly.tomlusesauto_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:
cd native/pir_rpc_adaptercargo 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.netThen connect MetaMask or Rabby to http://127.0.0.1:8545 (Chain ID 77).
Corporate treasuries and AI agents (x402)
Section titled “Corporate treasuries and AI agents (x402)”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-65key registration before signing a transfer or honoring anx402invoice without revealing watched accounts to external RPC operators. - Cryptographic pre-flight verification: every balance and nonce read is proven against the
stateRootfetched from your trustedCHAIN_RPC_URL, preventing a malicious or compromised PIR server from spoofing counterparty solvency (ifCHAIN_RPC_URLitself is compromised, run your own verifier node as the trusted chain RPC). - Strict fail-closed behavior: set no
--upstreamfallback; if verification fails (-32099) or freshness degrades (-32098), the agent halts the payment flow instead of acting on unverified state.
Running 2d-pir-server (operator sidecar)
Section titled “Running 2d-pir-server (operator sidecar)”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:
cd native/pir_rpc_adaptercargo run --release --features server --bin 2d-pir-server -- \ --bind 127.0.0.1 \ --port 8080 \ --enable-ohttp2d-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-rpcbinary 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-ohttpis set)GET /healthz
Protocol and code references
Section titled “Protocol and code references”- State root opening API:
GET https://poa.net/77/api/v2/blocks/:id/state-root-opening(returns the 576-byte opening whose hash matchesblock.state_root, withaccounts_rootatsub_roots[0]; see State roots) - Adapter and server crate:
native/pir_rpc_adapterinigor53627/2d - Plinko PIR and
plinko-rpclibrary:igor53627/plinko-rs - Architecture decision:
backlog/decisions/decision-10inigor53627/2d