Engineering Shielded-Address Deposits and Withdrawals

    How to treat fully shielded deposits and withdrawals as a replayable funds path: address checks, proof verification, memos, note balances, key separation, reconciliation, compliance, and a practical rollout order.

    Private-asset transfers do not have to expose the payer, the payee, and the amount on a public ledger at the same time. For exchanges, custody platforms, and self-hosted wallets, “supporting shielded deposits and withdrawals” is not just another address format. Address parsing, zero-knowledge proof checks, memo fields, balance state, and audit records have to form one replayable funds path. The sections below cover the design points and rollout order for fully shielded flows from an engineering perspective.

    1. Separate three address capabilities

    The difference between a transparent address and a shielded address is not whether coins can be received. It is how much information is visible on-chain.

    • Transparent address: any node can read the payer, the payee, and the amount. This fits simple reconciliation and high-disclosure use cases.
    • Shielded address: the transfer carries a zero-knowledge proof that the spend is valid, the amount is conserved, and there is no double-spend, without publishing the specific parties or the amount to the whole network.
    • Fully shielded path: assets move from the user’s shielded address into the platform’s shielded address, then back from the platform’s shielded address to the user’s shielded address, without being forced to land on a transparent address in between.

    “Deposit support” covers only inbound funds. “Withdrawal support” also covers outbound address checks, whether fees are paid on a shielded or transparent path, and failure rollback. A one-way implementation still exposes pooling relationships at the other end of the ledger, and the privacy gain is canceled by the counterparty address type.

    2. What a fully shielded deposit actually does in the system

    The user creates a transaction to the platform’s shielded receiving address and places a deposit identifier the platform can recognize in the memo or an agreed field. The platform cannot treat “there is an inbound transfer on-chain” as sufficient. It must decide all of the following:

    1. Address type matches: the recipient is a shielded address controlled by the platform, not a transparent address the user filled in by mistake or an address that has already been rotated out.
    2. The proof verifies: under the current consensus rules the transaction proof is valid, the spent note commitment has not been used, and the amount is conserved.
    3. Viewing capability is separate: the platform holds the viewing material for that receiving address and can decrypt memos and amounts that belong to it. Without that material, a synced node only knows that a valid shielded transaction occurred and cannot credit the user automatically.
    4. Crediting is idempotent: the same on-chain identifier can be credited only once. A reorg or a repeated proof submission must not increase the user balance again.

    A schematic credit decision can be written as pure logic, not as a vendor API:

    1. on_shielded_tx(tx):
    2. if not verify_proof(tx): return reject
    3. note = try_decrypt_incoming(tx, viewing_material)
    4. if note is empty: return ignore_unrelated
    5. if not match_deposit_tag(note.memo, user_index): return hold_for_review
    6. if already_credited(note.commitment): return duplicate
    7. credit(user_index, note.value, tx_id=note.commitment)

    The function names are not the point. Three independent facts are: the proof is valid, the platform can decrypt the memo, and the commitment has not already been credited. If any one is missing, the on-chain event must not become a user balance.

    3. Withdrawals add state that deposits do not

    A withdrawal is the platform paying a user’s shielded address from its own shielded funds. Beyond a correct address format, it must handle:

    • Spend authorization: payment must be signed with the platform’s spend key, or an equivalent authorization. Viewing material can read; it cannot spend.
    • Change and pooling: shielded funds exist as notes. A single note’s value may not equal the withdrawal amount, so several notes may be selected and a change note may be created. Change must return to the platform’s own shielded address, not to an operator’s personal address.
    • Fee path: if network fees still have to be paid in a transparent asset, the fee source leaves a hot-wallet trace on the public ledger. The product should state this clearly: a fully shielded path covers the principal, not every fee path automatically.
    • Failure semantics: if proof generation fails, inclusion times out, or the chain rolls back, the user balance may only be in one of “frozen,” “debited,” or “unfrozen after failure.” It must not sit indefinitely in an unexplained intermediate state.

    Internal state should be an explicit state machine: requested, frozen by risk control, proof generated, broadcast, confirmed, failed and unfrozen. Each step records only the commitment identifier, the amount, and the operator. Spend keys must not be written to business logs.

    4. Split keys and materials

    A shielded-address system should distinguish at least four kinds of material. Mixing them is the most common source of incidents.

    • Spend key: can move funds. It should appear only in a signing service or a hardware-isolated environment. Business databases, tickets, and logs must not store it.
    • Proof parameters and the proving service: build validity proofs. The work is compute-heavy and latency-sensitive, and it can scale horizontally, but it must not hold long-term spend authority.
    • Full viewing key: can decrypt historically related notes. Its privilege is close to “can read all inbound funds.” Limit it to operations and audit roles, and keep an access record.
    • Incoming viewing material: can only recognize newly received funds. It fits a deposit listener. Leakage does not by itself let someone move existing balances, but it does expose historical deposit privacy, so it still has to be protected as sensitive data.

    When rotating addresses, old viewing material cannot be destroyed immediately, or historical deposits cannot be reviewed. The correct approach is: the new address takes incremental funds, old material moves to read-only archive, and a minimum retention period plus access approval are defined.

    5. Balances, reconciliation, and what users see

    The platform’s internal ledger is still double-entry: user liabilities increase and custodied assets increase. On-chain invisibility does not mean internal books can skip reconciliation. Three checks are worth running daily:

    • Commitment set: credited commitments match decryptable on-chain deposits, with no duplicates and no missing items.
    • Note set: the sum of unspent note values equals the hot pool’s available balance, plus amounts in freeze, plus confirmed change.
    • User balances: available, frozen, and withdrawn amounts match the liability account.

    For the user, show the deposit identifier, confirmation count, amount, and status. Do not, and should not, echo decrypted content from other people’s transactions on the page. Support troubleshooting should look only at memo-match records for that user.

    6. Compliance and privacy should not cancel each other

    A fully shielded flow reduces public exposure to unrelated third parties. It does not remove the platform’s own identity checks, limits, or suspicious-activity monitoring. Engineering should separate “unreadable outside” from “auditable inside”:

    • Outside: the chain does not publish the specific parties or the amount.
    • Inside: accounts, devices, address ownership, and tickets can be linked under authorization, so freezes, record requests, and user appeals can be handled.
    • External disclosure: export only the minimum fields required by policy. Do not export viewing material or full notes into an open environment.

    If the jurisdiction does not allow shielded deposits, the feature switch should be turned off by region and account type. Hiding a button in the client while the server still accepts funds is not enough. The supported-address list, public notices, and API error codes should agree, so a user is not left unable to credit funds after sending them.

    7. Minimum checks before launch

    Launch does not have to cover every address version at once, but the following should be completed on a test network or with small real funds:

    • Shielded-to-shielded deposits with a correct memo, a wrong memo, and a missing memo: credit, hold, and ignore, respectively.
    • Repeated notification of the same commitment credits only once.
    • A successful withdrawal, a failed proof, and a reorg after broadcast leave the balance confirmed or unfrozen, as appropriate.
    • Change returns to the platform’s shielded address, and the hot-pool note total is conserved.
    • The spend key does not appear in plaintext in application logs, crash dumps, or database backups.
    • After viewing material is rotated, old deposits can still be reviewed, and new deposits use only the new material.

    These checks show that funds state is correct. They do not show that a brand “supports privacy.” Metrics should promise only confirmation thresholds and timeout policies that have actually been measured. Do not publish a theoretical proving time as production latency.

    8. A safer rollout order

    A steadier order is: read-only sync and decryption first, until deposits can be recognized; then manual crediting; then automated crediting with idempotency; and only then self-service withdrawals and change pooling. Run the proving service and the signing service as separate processes. The business service submits only “which shielded address to pay, what amount, and which freeze record.” If any step fails, the flow can stop in the frozen state instead of retrying with an uncertain on-chain side effect.

    The professional bar for fully shielded deposits and withdrawals is whether proof checks, viewing capability, note conservation, and internal audit all hold at once. Without proofs, invalid transactions get credited. Without viewing material, funds that belong to the platform are missed. Without a state machine, failures cause double payouts or balances that cannot be unfrozen. Implemented inside those boundaries, a privacy path is an operable, explainable engineering capability, not an address-format switch.