DEV Community

flat cash
flat cash

Posted on

Explainer: BearerSwap — how private crypto transfers work

Explainer: BearerSwap – How Private Crypto Transfers Work

Ever feel like your crypto transactions are happening in a glass house? That’s because, on most public blockchains, they are! Every transaction, every balance – it's all out there for anyone to see. While transparency is a core tenet of blockchain, it’s not always ideal for personal financial privacy. This is where BearerSwap comes in, offering a clever way to transfer crypto with a much-needed dose of privacy.

The Public Problem with Private Money

Imagine carrying cash. When you hand someone a twenty-dollar bill, that transaction is private. No one records it in a public ledger, and no one knows your bank balance. Now, compare that to a typical blockchain transaction. If you send ETH to a friend, anyone can look up your address and see exactly how much ETH you sent, when you sent it, and even your remaining balance. This level of transparency, while great for auditing, can be a major privacy concern for many.

Bearer Instruments: The Inspiration

BearerSwap draws its inspiration from the concept of "bearer instruments" – think physical cash or a bearer bond. These instruments represent value that is transferred simply by possessing and handing them over. There's no public registry of ownership, just the physical transfer. BearerSwap aims to bring this concept of private value transfer to the digital world.

How BearerSwap Works Its Magic

BearerSwap uses a clever combination of cryptographic techniques to enable private transfers. Here's a breakdown:

Commit-Reveal Scheme: The Core Mechanism

At its heart, BearerSwap utilizes a commit-reveal scheme. Think of it like this:

  1. The Commitment: The sender first "commits" to a transfer by sending funds to a special BearerSwap contract. But here’s the trick: they don't reveal the recipient's address yet. Instead, they create a cryptographic "hash" of the recipient's address combined with a secret "preimage" (a random, unique string of data). This hash is like a locked box – you can see there's something inside, but you can't open it without the key (the preimage). This commitment is public on the blockchain, but it doesn't reveal the actual recipient.

  2. The Reveal: Once the commitment is made, a "relayer" (a third-party service that facilitates the transfer) picks up on this. The relayer then sends the funds to the actual recipient. Critically, the relayer also "reveals" the preimage on-chain, proving that they fulfilled the commitment. This reveal links the original commitment to the actual recipient, but only the relayer can make this link. The sender's and recipient's addresses are never directly connected on the public blockchain.

Hash-Locked Transfers: Ensuring Security

The commitment is "hash-locked," meaning the funds are secured by the hash. Only by revealing the correct preimage can the funds be unlocked and sent to the recipient. This ensures that the relayer can't just run off with the committed funds; they are cryptographically bound to fulfill the transfer by revealing the preimage.

Gas Stipend: Incentivizing Relayers

To incentivize relayers to perform these transfers, the sender includes a small "gas stipend" with their commitment. This covers the relayer's transaction fees and provides a small profit for their service.

What Tokens are Supported?

BearerSwap currently supports native bearer transfers for ETH, FLAT, SAVE, and RISE. This means you can send these specific tokens privately using the BearerSwap protocol.

The Privacy Model: Unlinking Sender and Recipient

The beauty of BearerSwap's privacy model lies in the fact that the sender's and recipient's addresses are not directly linked on-chain. While the commitment and reveal transactions are public, the actual connection between the original sender and the final recipient is obscured. The relayer acts as an intermediary, breaking the direct on-chain link.

Limitations to Consider

While BearerSwap

Top comments (0)