feat(frontend): shielded balances, private swap, note vault backup and unshield UX #1586
Labels
No labels
agent:fix_bugfix
agent:fix_conflicts
agent:fix_security
agent:gap_analysis
agent:implement
agent:implement
agent:implement
agent:open_issues
agent:ready
agent:research
agent:security_audit
agent:verify
architecture
backend
blocker:hybrid
blocker:launch
blocker:limit-orders
blocker:v2
block:log_only
block:security
bug
ci
contracts
correctness
deploy
dev
devops
docs
documentation
duplicate
e2e
enhancement
epic
feature
frontend
functional-completion
gas
good first issue
governance
help wanted
high-risk
hooks
hybrid
indexer
infra
infrastructure
integrators
invalid
launch-blocker
limit-orders
localnet
localterra
low priority
missing-implementation
needs-design
ops
performance
priority
high
priority
medium
product
qa
QA
question
ready
ready
research
scripts
security
security-hardening
smartcontracts
tech-debt
testing
ux
UX
v2
verification
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
code/cl8y-dex-terraclassic#1586
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem and scope
Give users a complete, accessible, privacy-honest client for the shielded pool (#1583) and private swaps (#1584): shield (deposit), shielded balance and note management, private swap, unshield, note backup and restore. The client must never send the user's wallet address, note key or note data to the indexer, must keep note keys out of plaintext storage, and must make the limits of the privacy model explicit so users do not mistake pooled notes for an anonymity system.
This issue covers:
It does not implement the contracts (#1583, #1584), the indexer (#1585) or the security/abuse program (#1587). It consumes their interfaces as specified and must not invent a fallback that weakens them.
Current codebase and investigation
Reviewed checkout:
38c154958; frontend is Vite + React underfrontend-dapp/.frontend-dapp/src/pages/SwapPage.tsx(andTradeMarketOrderPanel.tsx) implement the ordinary swap: quote → review → sign, with the connected wallet sent astradertoGET /api/v1/route/solve(src/services/indexer/client.tslines ~715–760),LOCAL_QUOTE_SIGNING_WINDOW_MS= 30 minutes (src/utils/localQuoteWindow.ts), route display, L9 max spread, positive post-hookmin_return, final minimum receive, and the shared risk notices (#1500/#1560).src/services/terraclassic/wallet.ts,terraBroadcast.ts,terraWalletSignLock.ts,terraWalletSignTxRaw.ts,terraMsgDeadline.ts,terraGas.ts,terraGasRetailInventory.ts; wallet UI insrc/components/wallet/; store insrc/stores/dex.ts; WalletConnect mobile pairing perskills/AGENTS_FRONTEND_WALLETCONNECT_MOBILE.md./portfolio(PortfolioPage.tsx),/trader/:address(TraderPage.tsx),/charts(ChartsPage.tsx),GET /api/v1/traders/...and CSV helpers insrc/services/indexer/client.ts(lines ~476–557), and/api/v1/compliance/blacklist-check?wallet=.docs/design-system.md#accessibility-policy, skillsAGENTS_FRONTEND_A11Y_CI.md,AGENTS_FRONTEND_A11Y_FOCUS.md,AGENTS_FRONTEND_COPY_COGNITIVE_LOAD.md; productionVITE_DEV_MODEguard (#695); CSP builderfrontend-dapp/viteCsp.ts; lazy-chunk recovery (#706); legal clickwrap/footer; Open Graph allowlist (#578); offline swap budget (#1480); local quote window (30 min) and persistent, textual errors.shieldedpage, route, vault, note store, ed25519 signing, note scanning, relayer client, or privacy notice. No client-side crypto beyond wallet/WebCrypto primitives is present;ed25519signing must be added with a reviewed dependency (e.g.@noble/ed25519) or WebCrypto where available.viteCsp.ts) andconnect-srclimited to the configured LCD/RPC/indexer/WalletConnect hosts. New endpoints must be added to that list; do not broaden it tohttps:.make dev(Node 24), Playwright, Simulated Wallet, Keplr/LocalTerra (docs/localterra-sdk53.md,skills/AGENTS_E2E_STRICT_CHAIN.md),make verify-issue-<N>conventions anddocs/qa/issue-<N>/README.md.Why a new implementation is needed
The existing swap UX is built around a connected wallet: the wallet address is sent with the quote, the pair records it, the indexer attributes volume/positions, and the wallet appears as the trader. Re-pointing that flow at the pool without changes would leak the wallet in the quote request, the preflight, the analytics and the history views, defeating the purpose of shielded balances.
Notes are also a new custody model for this dApp: the only secret is the note key. A plaintext note list, a browser password manager, or a lost backup means irreversible loss. Users need an explicit, accessible backup/restore flow, a clear warning that no support or contract admin can recover notes, and a UI that never silently reuses a key across deposits.
Finally, a "shielded" label invites overclaiming. The client must present what is actually hidden (the DEX's attribution of the trade) and what is not (amounts, deposit tx, note graph, chain analysis), with no anonymity, mixer or "untraceable" wording.
Relevant files
frontend-dapp/src/pages/ShieldedPage.tsx(+ tests),components/shielded/*(vault gate, shield form, unshield form, private swap panel, note list, backup/restore, privacy notice),src/services/shielded/{vault,notes,pool,swap,relayer}.ts,src/utils/shielded/*(note encoding, digest display, amount/decimals, status),src/hooks/useShielded*.src/App.tsx(or the router entry), header/footer links,SwapPage/PortfolioPageentry points.src/services/indexer/client.ts(new shielded note/quote helpers; no wallet param),src/services/indexer/*parsers.src/services/terraclassic/*(CW20Sendbuilder, spend broadcast, fee/gas, deadline, sign lock),viteCsp.ts,vite.config.ts,.envdocumentation.docs/shielded-pool.md(privacy claims),docs/frontend.md,docs/design-system.md,docs/qa/issue-<N>/README.md,skills/AGENTS_FRONTEND_SHIELDED.md.frontend-dapp/; existing wallet/swap test utilities.Recommended direction
Route and entry points. Add
/shielded(and a clear link from Swap and Portfolio). The page has three primary actions — Shield, Private swap, Unshield — plus a shielded balance/notes list. Do not add a wizard, a second navigation system, or permanent explanatory walls; follow the existing compact design system and copy rules.Vault and keys. Generate a fresh note key pair per deposit (ed25519) in the browser; store only the encrypted vault in IndexedDB/localStorage:
{version, kdf: PBKDF2-SHA256 (>= 600k iterations, random salt), cipher: AES-GCM (random IV), ciphertext}. The vault contains note keys and note metadata but no wallet address, no seed phrase, no note plaintext on disk outside the ciphertext. Require a passphrase to unlock; lock on tab hide/idle with a generous timeout (never a short reaction window); zero sensitive buffers where feasible. Provide Export encrypted backup and Import; the backup file is encrypted with the same passphrase and carries a version and pool/chain id. There is no server-side recovery, no email reset, no support override; show that before the first deposit and require an explicit acknowledgement. Do not derive the note key from a wallet signature (Ledger/WalletConnect support is inconsistent and it is a phishing-shaped prompt); do not use the wallet key.Deposit (shield). Build a CW20
Send { contract: pool, amount, msg: { shield_note: { owner_pubkey, blinding } } }from the connected wallet. Use a fresh key and a fresh 32-byte blinding. Preview the exact amount, the token contract address, the pool address, any transfer tax the token will charge (the note is credited post-tax), the caps and the deposit delay. The wallet address is necessarily visible in this transaction; say so in the notice. Do not request a tier discount, do not call per-wallet indexer endpoints, and do not add the wallet to quote requests.Note status and scanning. After deposit, show
pendinguntil the note event is indexed/observed, thenavailable. On import/restore, scan the indexer's range-based shielded note endpoint (#1585) from the deployment leaf, filter locally by the vault's public keys, and verify the commitment locally against the returned fields; never trust an indexer "balance". Reconcile against a direct poolNote/Liabilityread only where the existing read policy allows it. Handle reorg/re-ingest, duplicate leafs, unknown note versions and notes inserted while offline.Private swap. Reuse the ordinary quote and risk components but request the quote with the pool as trader (or no trader) and never the connected wallet. Show the reviewed route, the input notes, the expected output note, change, sell/buy/transfer tax, the pair fee, the relayer fee (if any) and the deadline. Build the signed spend digest exactly as #1584 defines it, display a short human-readable summary of what is being signed (token, amount, output, destination for unshield, fee, deadline) and sign with the note key, not the wallet. If the user broadcasts themselves, warn that their wallet appears as the fee payer and the calldata contains the note opening; prefer the relayer for users who need submission privacy. Keep the 30-minute reviewed-quote window and the existing L9/floors; do not introduce a shorter confirmation timer.
Unshield. Sign a spend with
destination, amount, fee and deadline bound. Display the destination, fee, the arrival amount and the fact that withdrawing to an address already linked to the deposit source reduces privacy. If a relayer is used, show its fee and that it sees the request; do not auto-select a relayer without consent. Provide a self-broadcast path for users with a funded fresh address and an explicit explanation of the trade-off.Relayer client. A relayer request contains the fully formed pool message (signed spend) and the user's chosen fee; the relayer may only attach the outer transaction fee/gas and broadcast. The client must verify that the returned/echoed calldata matches what it signed (operations, destination, fee, deadline, nullifier) before showing success, and must handle: refusal, timeout, nonce/gas errors, ambiguous broadcast, duplicate submit and retry. A relayer must never receive the vault passphrase or any other note keys. If no relayer is available, fail closed with a clear self-broadcast option, not a silent fallback that links the wallet.
No leakage in the client. On shielded routes: no analytics/product events with wallet, note key, amount or route (aggregate-only, if any; reference the #1202 privacy-reviewed scope and do not add new identifiers); no wallet address in URLs,
Referer, query strings,localStoragekeys, error reports or logs; no per-wallet indexer endpoints (/traders/...,blacklist-check?wallet=, tier health) during shielded flows; no third-party scripts, fonts, images or prefetch on the page; CSPconnect-srcextended only with the exact shielded endpoint(s). Do not cache note payloads in a service worker; clear them on lock. Disable Open Graph sharing for note/destination data.Privacy notice and copy. A short, persistent, accessible notice states: the deposit transaction is public and links the source address to the shield key; the DEX's own tape/indexer will not attribute the trade to the wallet, but amounts and the note graph are public chain data; the pool is not an anonymity system or mixer; notes are bearer instruments and a lost key/backup is unrecoverable; using the same destination/deposit address or correlated amounts/timing weakens privacy. No "untraceable", "anonymous", "private money" or tax-evasion implications. Localize carefully if translations exist; keep it within the existing legal/risk surfaces.
Accessibility and mobile. Follow
docs/design-system.md#accessibility-policyand the A11Y skills: keyboard and screen-reader operation for all three flows;aria-live/role=statusfor pending/confirmed/failed states; persistent textual errors, never sound/colour only; no short reaction timers; the 30-minute reviewed window applies to the reviewed swap/unshield; 200% root text zoom, 320–430 px widths, both themes, reduced motion; focus management for the vault unlock, backup and relayer dialogs; WalletConnect same-device and extension flows with the existing pairing patterns; no QR-only path.Failure and recovery. Cover: vault forgotten/locked, corrupted backup, wrong passphrase, missing notes after restore, pending deposit never indexed, note already spent elsewhere, stale quote/expired deadline, pool paused deposits, pair paused, token frozen/blacklisted, launch-guard rejection, insufficient gas for self-broadcast, relayer refusal, reverted transaction, ambiguous broadcast and duplicate submit. Every state must be text, persistent, actionable, and must not suggest retrying a signed spend that could double-spend (nullifier prevents it; explain the outcome instead).
Constraints and guardrails
sender, tier or blacklist wallet. Do not reusegetRouteSolveunchanged if it would attachtrader; add a shielded-specific call with an explicit contract test.min_return, final minimum receive, deadline, 30% Expert or ≥99% non-waivable guard; no hidden "retry with more slippage".docs/shielded-pool.md; no anonymity/mixer/tax-evasion language; no claims that the DEX cannot see public chain data.@noble/ed25519(or equivalent) is added, pin the version, review the licence/supply chain (docs/supply-chain-security.md), and keep it out of the main bundle until the shielded route loads. Do not weaken the CSP or add third-party origins.Acceptance criteria
/shieldedsupports shield, private swap and unshield end-to-end on LocalTerra withcw20-mintableand a community-tax-token; the pool sees no user wallet in swap/unshield calldata, the output and change notes appear in the vault, and the user's wallet is not sent to any shielded indexer request.docs/shielded-pool.mdand contain no anonymity claim.aria-livestates, persistent text errors, no short reaction timers, 200% zoom, 320–430 px, both themes and reduced motion; the vault, backup and relayer dialogs manage focus and are dismissible.Referer, localStorage keys, console/error reports, CSP reports or third-party requests; a request-capture test proves it.docs/frontend.md,docs/shielded-pool.md(client section),docs/design-system.md(accessibility/privacy note),docs/qa/issue-<N>/README.mdandskills/AGENTS_FRONTEND_SHIELDED.mdare updated;make verify-issue-<N>exists.Test plan: functional paths
Referer, localStorage/IndexedDB inspection, console/network logs, CSP reports, analytics absence, third-party resource absence, Open Graph/sharing disabled.VITE_DEV_MODE, no dev mnemonic, lazy-loaded shielded chunk, stale-chunk recovery, offline behaviour, no service-worker note cache.Test plan: attacks, hacks and abuse
trader,blacklist-check, tier checks,Referer, prefetch, error reports, push notifications, service worker, Open Graph), correlate amounts/timing, reuse a destination, or query note ranges that identify a user. Prove no client-generated link and provide the honest notice.min_outputat 1 raw unit, and a token whose decimals change. Validate with integer raw units and display human scale per #1259.connect-src, chunk recovery and no note caching.Verification criteria
make verify-issue-<N>runs frontend types, lint, Vitest (unit/component), production build, CSP/build guards and doc cross-links; Playwright specs cover the three flows against a stubbed indexer and, with the chain flag, against LocalTerra.cw20-mintableand a community-tax token, plus restore-from-backup and relayer failure. Record hashes and assertions indocs/qa/issue-<N>/README.mdwithout wallet-owner identity or personal data.docs/qa/issue-<N>/README.mdrecords executed checks and explicit skips (e.g. physical device, funded mainnet) with scope. Executed failures remain FAIL; unavailable checks may be explicit SKIP with PASS WITH SKIPS without claiming deployed acceptance.Out of scope / follow-ups