we built a bitcoin dark pools prototype 🪄
tl;dr - we built a privacy-preserving, bitcoin exchange using
@mercurylayer, nostr, and a zk-execution network. the bitcoin transfer is completed offchain via a blind co-signer. the stablecoin network only reveals hashes of inputs and outputs, no amounts or user addresses. orders are matched peer-to-peer using nostr identities. exchange is atomic & privacy-preserving. deets:
this protocol is built on the following:
- statechains, a way to transfer ownership for bitcoin utxos offchain by reassigning spending keys
- private stablecoin network with flexible zk-circuits/contracts that lock funds to a specific sha256 hash
- a blind co-signer that facilitates ownership transfer for bitcoin utxos offchain per a specific order
the exchange builds upon mercury layers’ latch protocol. the seller locks their offchain "utxo" into an order that they create. the order specifies that an offchain transfer to the buyer’s offchain address should occur after buyer & seller commit to it. an order with a hash is created.
the order hash is then used to lock stablecoins on the zk network. meaning, the buyer must lock their funds into an escrow contract where the funds are only claimable by revealing the preimage for the order’s sha256 hash (or they refund the buyer after a timelock).
after these stables (or any other shitcoin, tbh) are locked on the zk side, the buyer submits the tx hash to the seller. after verifying that stables are locked in escrow, the seller calls the co-signer to unlock the transfer to the buyer. after verifying that the seller has committed this, the buyer also calls the co-signer to unlock the transfer. the co-signer reassigns the statechain multisig spending key to the buyer and tweaks their keyshare. the co-signer then deletes their key with the seller.
after the statechain transfer, the co-signer then reveals the preimage for the order to the seller. the seller uses that to claim the stables on the zk network out of the escrow contract. swap completed. buyer trusts signer deleted their keyshare up until the point the exit the statechain back to bitcoin.
we’ve taken this swap protocol and developed an RFQ protocol using nostr identities. in the exchange application, users create a nostr identity and submit buy and sell orders. only their npub, and the amount of their respective order, is revealed. no bitcoin addresses or other pii is exposed. when a user finds an suitable offer in the orderbook, they submit an encrypted firm quote with exact amounts and prices. only the counterparty in the trade can decrypt this message.
from an onchain perspective, there is no onchain bitcoin transaction. on the stablecoin side, zk magic only see hashes of inputs and outputs publicly available. you can’t even discern which token was involved in the trade.
the co-signer is blind and dumb. validation is done peer-to-peer between countparties. co-signer only signs when its told to.
this is a demo and opinionated design. in our view, it’s extremely privacy-preserving and makes nice tradeoffs wrt user self-custody.
we’ll building more optimized versions that make different tradeoffs, but wanted to share this example. all code will be open-sourced in the future.
🪄