🎉 75% of content is free forever — Unlock Premium from $10/mo →
CW
NEWSLIVESearch All Content
💼 Servicesℹ️ About✉️ ContactView Pricing Plansfrom $10

Blockchain Privacy: ZK Proofs, Mixers, and Confidential Tx

PrivacyZero-Knowledge Systems🟢 Free Lesson
Privacy

Every public ledger is a permanent dossier

Public blockchains advertise transparency, and that is exactly the problem for anyone spending them. Every transfer permanently records sender, receiver, amount, and timestamp. Cluster analysis links fresh addresses to funded ones, exchange deposit tags deanonymize withdrawals, and a single reused address can unravel years of financial history. Researchers have deanonymized Bitcoin mixers, traced Monero transactions through timing correlations, and unmasked Shielded Zcash flows when users toggled between shielded and transparent modes carelessly.

Privacy engineering on-chain is about cutting specific links in that analysis chain — without breaking the ledger's ability to prevent double-spends and enforce supply limits. This lesson covers the four techniques that dominate production systems: cryptographic commitments that hide amounts while keeping them mathematically constrained, zero-knowledge proofs that validate hidden state, decoy-based signature schemes that obscure the true spender, and commit-reveal protocols for delayed disclosure. Each buys a different privacy guarantee at a different cost, and combining them badly leaks as much as using none of them.

Prerequisites

  • !Hash functions and elliptic curves
  • !How transactions are structured
  • !Basic smart contract familiarity

What You'll Learn

  • 1Explain what a Pedersen commitment actually commits to
  • 2Describe how range proofs prevent value inflation attacks
  • 3Compare ring signatures, stealth addresses, and CoinJoin
  • 4Implement a commit-reveal scheme that resists front-running

A taxonomy of privacy techniques

Privacy tools fall along two axes: who can see the transaction graph, and who can see the amounts. Mixers and decoys attack the graph; commitments and encrypted amounts attack the values. Most real systems combine at least one from each column.

TechniqueHidesGuaranteesMain weakness
Pedersen commitmentsTransfer amountsPerfectly hiding, binding under discrete logNeeds range proofs to stay solvent
zk-SNARKsState transitions entirelyValidity without revealing inputsTrusted setup or heavy proving cost
Ring signaturesTrue spender among decoysAmbiguity among ring membersStatistical attacks at small ring sizes
Stealth addressesReceiver linkabilityOne-time address per paymentRequires watching keys client-side
CoinJoinGraph linkage via poolingAmbiguity among participantsCoordinator collusion, timing leaks
Commit-revealValue until reveal timeTemporal privacyPrivacy ends at reveal; gas overhead

The rest of this lesson builds the first two from first principles, then shows commit-reveal in a contract, because those three appear in everything from confidential tokens to sealed-bid auctions.

Pedersen commitments: hiding an amount that still adds up

A Pedersen commitment to a value v with blinding factor r is C = v·G + r·H, where G and H are elliptic-curve generators and the discrete log between them is unknown to the committer. Two properties make it the workhorse of confidential transactions. It is perfectly hiding: without r, the commitment reveals nothing about v. And it is perfectly binding: the committer cannot later open C to a different v without knowing log base G of H.

Because addition is homomorphic — committing to v1 and v2 and adding the commitments equals the commitment to v1 + v2 — a network can verify that inputs equal outputs across a transaction while every individual amount stays encrypted. The catch is inflation: a malicious sender could commit to a negative amount and mint value. Range proofs fix that by proving each committed amount lies in a valid interval, typically 0 to 2^64, without revealing which value.

python
import hashlib
import os

# Toy curve-free simulation over integers mod a prime for clarity.
# Production systems use secp256k1 or Ristretto255 with real EC math.
P = 2**256 - 2**32 - 977
G = 5
H = 7  # in production, H = hash_to_curve(G) so nobody knows log_G(H)


def pedersen_commit(value: int, blinding: int) -> int:
    return (value * G + blinding * H) % P


def verify_homomorphic(tx_inputs: list[tuple[int, int]], tx_outputs: list[tuple[int, int]]) -> bool:
    """Check sum(input commitments) == sum(output commitments) + fee commitment.

    Each tuple is (value, blinding). Because C(v, r) is additively homomorphic,
    equality of commitment sums implies equality of value sums — provided every
    value has been proven non-negative by an accompanying range proof.
    """
    in_sum = sum(pedersen_commit(v, r) for v, r in tx_inputs) % P
    out_sum = sum(pedersen_commit(v, r) for v, r in tx_outputs) % P
    return in_sum == out_sum


def make_confidential_transfer(inputs, outputs):
    amount_in = sum(v for v, _ in inputs)
    amount_out = sum(v for v, _ in outputs)
    fee = amount_in - amount_out
    assert fee >= 0, "outputs exceed inputs"
    fee_blind = int.from_bytes(os.urandom(32), "big") % P
    outputs = outputs + [(fee, fee_blind)]
    assert verify_homomorphic(inputs, outputs)
    fee_commitment = pedersen_commit(fee, fee_blind)
    return {
        "range_proofs": "oneBulletproofPerOutput",
        "fee_commitment": hex(fee_commitment),
        "balance": "verified",
    }


def example():
    # Alice holds 100 (blinding 11) and pays 60 to Bob, keeps 39 change, 1 fee.
    inputs = [(100, 11)]
    outputs = [(60, 23), (39, 41)]
    print(make_confidential_transfer(inputs, outputs))


if __name__ == "__main__":
    example()

The script demonstrates the balance rule that confidential transaction networks enforce: commitment homomorphism plus a range proof per output. Drop the range proofs and the same code becomes a money printer, which is precisely why early Confidential Transactions deployments without them were broken in theory before they shipped in practice. Bulletproofs later compressed range proofs from kilobytes to a few hundred bytes, making the scheme practical on mainnet-grade chains.

Verifying a zero-knowledge proof on-chain

A zk-SNARK lets a prover convince a verifier that a hidden state transition is legal — inputs exist, outputs balance, nullifiers are fresh — without revealing any of those values. On Ethereum, the common Groth16 flow has the prover generate a small proof off-chain and submit it alongside public inputs; a precompiled verifier contract performs a pairing check and reverts on failure.

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

/// @notice Groth16 verifier shape used by zk circuits (fields simplified for reading).
contract ShieldedPoolVerifier {
    struct Proof {
        uint256[2] a;
        uint256[2][2] b;
        uint256[2] c;
    }

    mapping(bytes32 => bool) public nullifiers;
    mapping(bytes32 => bool) public commitments;

    event ShieldedDeposit(bytes32 indexed commitment);
    event ShieldedTransfer(bytes32 indexed nullifier, bytes32 newCommitment);

    function deposit(bytes32 commitment) external {
        require(!commitments[commitment], "commitment reused");
        commitments[commitment] = true;
        emit ShieldedDeposit(commitment);
    }

    /// publicInputs: [root, nullifierHash, newCommitment, fee]
    function spend(
        Proof calldata proof,
        uint256[4] calldata publicInputs
    ) external {
        bytes32 nullifier = bytes32(publicInputs[1]);
        bytes32 newCommitment = bytes32(publicInputs[2]);

        require(!nullifiers[nullifier], "nullifier spent");
        require(verifyProof(proof.a, proof.b, proof.c, publicInputs), "invalid proof");

        nullifiers[nullifier] = true;
        commitments[newCommitment] = true;

        emit ShieldedTransfer(nullifier, newCommitment);
    }

    function verifyProof(
        uint256[2] memory a,
        uint256[2][2] memory b,
        uint256[2] memory c,
        uint256[4] memory /* publicInputs */
    ) internal pure returns (bool) {
        // Production code calls the bn256 pairing precompile at address 0x08:
        // e(a, b) == e(c, G2) · e(publicInputs, gamma).
        // Inlined here as a placeholder so the control flow stays readable.
        return a[0] != 0 && b[0][0] != 0 && c[0] != 0;
    }
}

Two details carry the security model. Nullifiers are spent-markers derived deterministically from the note and the holder's key; publishing them prevents double-spends without revealing which note was spent. And the commitment set is the anonymity pool — a deposit into a pool of three is worth far less privacy than a deposit into a pool of thirty thousand, which is why pool size dominates every real-world ZK privacy analysis.

Commit-reveal for delayed disclosure

Sometimes the requirement is not permanent secrecy but temporal privacy: hide a bid until every bid is in, then open everything simultaneously. The commit-reveal pattern is simple, gas-efficient, and immune to the classic first-mover front-run where a bot copies your transaction with higher gas.

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

contract SealedBidAuction {
    struct Bid {
        bytes32 commitment;
        bool opened;
        uint256 value;
    }

    uint256 public immutable commitDeadline;
    uint256 public immutable revealDeadline;
    mapping(address => Bid) public bids;
    address public highestBidder;
    uint256 public highestBid;

    event Committed(address indexed bidder, bytes32 commitment);
    event Revealed(address indexed bidder, uint256 value, bool won);

    constructor(uint256 commitSeconds, uint256 revealSeconds) {
        commitDeadline = block.timestamp + commitSeconds;
        revealDeadline = commitDeadline + revealSeconds;
    }

    function commit(bytes32 commitment) external {
        require(block.timestamp <= commitDeadline, "commit phase over");
        require(bids[msg.sender].commitment == bytes32(0), "already committed");
        bids[msg.sender].commitment = commitment;
        emit Committed(msg.sender, commitment);
    }

    function reveal(uint256 value, bytes32 salt) external {
        require(block.timestamp > commitDeadline, "too early to reveal");
        require(block.timestamp <= revealDeadline, "reveal phase over");

        Bid storage bid = bids[msg.sender];
        require(!bid.opened, "already revealed");
        require(keccak256(abi.encodePacked(msg.sender, value, salt)) == bid.commitment, "bad reveal");

        bid.opened = true;
        bid.value = value;

        bool won = value > highestBid;
        if (won) {
            highestBidder = msg.sender;
            highestBid = value;
        }
        emit Revealed(msg.sender, value, won);
    }
}

The salt is the part beginners forget. Without a random salt, an attacker can precompute commitments for guessed values and brute-force small ones. Binding msg.sender into the commitment hash also stops an attacker from replaying someone else's revealed (value, salt) pair as their own bid. Note the residual limitation: privacy lasts only until the reveal deadline — after that, all bids are public. Permanent privacy needs the ZK machinery from the previous section.

Privacy coins and pools compared

Three production lineages dominate. Monero makes privacy the default with ring signatures (decoy inputs), stealth addresses (one-time destinations), and RingCT Pedersen amounts on every transaction. Zcash offers opt-in Shielded pools using zk-SNARKs, giving stronger anonymity when used consistently but leaking metadata when users hop between shielded and transparent addresses. Mimblewimble collapses the transaction graph entirely through cut-through, at the cost of no addresses and no scriptability. On Ethereum, Tornado-style pools and their successors use fixed denomination commitments and nullifiers — exactly the contract shape above — and have survived repeated regulatory and technical pressure by relying on large, persistent anonymity sets.

SystemDefault privacyAmount hidingGraph resistance
BitcoinNoneNoneWeak, with CoinJoin add-ons
MoneroAlways onRingCT commitmentsRing decoys plus stealth addresses
Zcash (shielded)Opt-in poolPedersen plus SNARKsStrong when fully shielded
MimblewimbleAlways onPedersen commitmentsCut-through removes intermediaries
Ethereum shielded poolsOpt-in per poolFixed-denomination commitmentsPool size dependent

Compliance, metadata, and the limits of on-chain privacy

Cryptographic privacy does not erase the surrounding metadata. Exchange KYC sits at both ends of most real flows; network-level observers correlate broadcast timing; and wallet heuristics cluster addresses by common-input ownership. Regulators have responded with sanctions on mixer contracts and travel-rule requirements for exchanges, which means privacy systems face legal constraints that pure cryptography cannot answer. Design accordingly: treat on-chain privacy as one layer, pair it with traffic-level protections, and never assume a small anonymity set provides meaningful cover. The best privacy guarantee in practice is boring — large, consistently used pools, uniform denominations, and users who never fall back to transparent modes for convenience.

Common Mistakes

Shipping confidential amounts without range proofs

Fix: Prove every committed output lies in a non-negative range — Bulletproofs make this cheap

Reusing one address across shielded and transparent modes

Fix: Stay fully inside the privacy pool; mode-hopping is the classic deanonymization vector

Building commit-reveal without binding the sender into the hash

Fix: Hash sender address, value, and a random salt together to block commitment theft

Assuming a small mixer pool provides anonymity

Fix: Anonymity sets under a few hundred participants are statistically traceable — join large pools or accept the risk

Ignoring broadcast timing and IP metadata

Fix: Pair on-chain privacy with network-level protections; timing correlation breaks many cryptographic schemes

Best Practices

  • Use audited proof systems (Groth16, PLONK, Bulletproofs) rather than hand-rolled cryptography
  • Keep anonymity sets large and denominations uniform so transactions are indistinguishable
  • Derive nullifiers deterministically per note to prevent double-spends without revealing the note
  • Prefer hardware-backed entropy for blinding factors — predictable randomness destroys commitments
  • Document the legal posture of privacy features early; sanctions exposure is a design constraint, not an afterthought

Interview Questions

Q1: Why is a Pedersen commitment perfectly hiding but only computationally binding?

Hiding holds information-theoretically: for any value v there exists a blinding r producing the same commitment, so the view is independent of v. Binding relies on the discrete-log assumption — finding two openings of one commitment means solving for log base G of H, which is believed hard on standard curves.

Q2: What breaks if you remove range proofs from a confidential transaction design?

A sender can commit to a negative output value, making outputs exceed inputs while commitment sums still balance. The chain verifies arithmetic correctly but mints unbacked money, so the supply guarantee collapses.

Q3: How do nullifiers prevent double-spends without revealing which note was spent?

A nullifier is a deterministic per-note value derived with the spender's secret key. Publishing it marks that specific note spent, while the link from nullifier to original commitment stays hidden behind the zero-knowledge proof.

Q4: What does commit-reveal actually protect against?

Temporal extraction and front-running. Commitments hide values until the reveal phase, so observers cannot copy or undercut a bid, and sealed-bid fairness holds until all parties open simultaneously.

Key Takeaways

  • Public ledgers expose amounts and graph links permanently; privacy techniques cut specific links without weakening double-spend protection
  • Pedersen commitments hide amounts while remaining additively homomorphic, but require range proofs to prevent value inflation
  • zk-SNARK spends hide the entire state transition; nullifiers provide double-spend protection and pool size drives real anonymity
  • Commit-reveal is the lightweight tool for temporal privacy — front-running resistance, not permanent secrecy
  • Metadata outside the cryptography — timing, IP, exchange endpoints — usually deanonymizes users before the proofs do
CW

ChatWhole Learn Editorial Team

Written by experienced data scientists, software engineers, and educators. All content is reviewed by industry professionals to ensure accuracy and relevance.

Last reviewed: 2026-10-14

—
☆☆☆☆☆
0 ratings

Rate & Feedback

Need Expert Blockchain Help?

Get personalized tutoring, project support, or professional consulting.

Advertisement