ZK-IdentitySwap

Private asset swaps using ZK proofs to link wallets without revealing identities

ZK-IdentitySwap

Created At

Unite Defi

Project Description

Project Description: ZK-IdentitySwap (or GhostProof) ZK-IdentitySwap is a privacy-preserving asset transfer system that allows users to transfer funds between their own wallets without revealing the connection between them. It leverages zero-knowledge proofs (ZK-SNARKs) to cryptographically prove that the sender owns both wallets, while keeping their identities and wallet addresses confidential.

Inspired by the concept behind Tornado Cash but designed to be legally compliant, the system introduces a new form of identity-linked private transfers. Instead of mixing assets blindly, users generate a ZK proof of ownership link between two wallets using Semaphore or Noir, and only if this proof is valid, they can execute a privateSwap() function on the smart contract.

The core flow involves:

A user creates a private identity (e.g., Semaphore identity).

The user generates a ZK proof that they control both source and target wallets.

The smart contract (PrivateSwap.sol) verifies the proof on-chain before executing the token transfer.

At no point are the actual wallet addresses or identity details revealed.

The project includes:

A ZK circuit to prove wallet ownership linkage.

A smart contract with on-chain verification logic.

A frontend interface where users can generate identities, proofs, and initiate stealth transfers.

By combining ZK, identity, and compliance, this project unlocks a novel primitive in DeFi: accountable privacy — where the user’s actions are verifiable, but their identity remains confidential.

How it's Made

Harika! İşte "How It’s Made" bölümü için detaylı, teknik bir açıklama. Bu bölüm jüriye gerçekten projeyi nasıl inşa ettiğini göstermek için kritik — ZK, identity, on-chain interaction ve frontend entegrasyonu gibi tüm bileşenleri kapsıyor:

🛠️ How It’s Made This project is built using a combination of ZK-SNARKs, identity primitives, and smart contracts to enable private and verifiable wallet-to-wallet transfers.

🔐 Zero-Knowledge Proofs (ZK-SNARKs) We used Semaphore to generate ZK identities and build Merkle proofs of membership. Semaphore provided a ready-to-use circuit and tooling to construct ZK proofs that a user belongs to a certain group (e.g., “wallets I own”), without revealing which one.

Semaphore Identity is generated client-side using elliptic curve commitments.

Merkle Group: We add the user's identity commitment into a Merkle tree, enabling privacy-preserving group membership proof.

ZK Proof: The user proves they are the same person behind two different wallet addresses, without exposing them.

📄 Smart Contracts We deployed two smart contracts:

ProofVerifier.sol – A basic verifier contract based on Semaphore's verifier template that validates ZK-SNARK proofs on-chain using the verifyProof function.

PrivateSwap.sol – A contract that exposes a privateSwap() function. This checks that:

The ZK proof is valid,

The user hasn’t reused the nullifier (prevents double-spending),

Only then proceeds to transfer ERC-20 tokens (mocked for now).

These contracts are built and tested using Hardhat.

🧪 ZK Toolchain We used:

semaphore-protocol (for identity and circuit tools)

snarkjs for proof generation and verification setup

circom for custom circuit logic (optionally used if Noir wasn’t picked)

Optionally explored Noir by Aztec for building custom ZK circuits (work-in-progress).

🖥️ Frontend Stack Next.js 15 (app router) for building the UI

Users can:

Generate a ZK identity and store it locally

Join a group (register commitment to a Merkle tree)

Select source & target wallet addresses

Generate a ZK proof that they control both wallets

Submit the proof to the smart contract for transfer

We used Wagmi + Ethers.js to connect wallets and interact with contracts

Toast & modal alerts for proof verification result and error display

⚡ Notable Hacks Built an off-chain group coordinator to manage Semaphore identity commitments and Merkle root updates — this acts like a trusted sequencer (can be decentralized later).

Used dummy nullifier hash prevention logic to avoid double transfers.

Emulated wallet linkage using local signatures to simulate ownership without exposing private keys.

🤝 Partner Technologies Semaphore (by Privacy & Scaling Explorations, Ethereum Foundation) provided a perfect starting point for identity-based ZK circuits.

Hardhat + Ethers.js enabled fast prototyping and contract debugging.

We considered integrating Biconomy or Particle Network for gasless UX (optional extension).

background image mobile

Join the mailing list

Get the latest news and updates