How it works?

Your private crypto wallet

Essentially, Hazy Wallet functions similarly to the user accounts on centralized exchanges:

  • You can deposit funds there from the regular blockchain accounts

  • You can swap between assets while keeping your funds obscured

  • You can pay or withdraw funds to the regular blockchain accounts on different blockchains, and the source of the funds will be also obscured

However, there is one crucial difference: Hazy Wallet is non-custodial and does not have free access to your funds. Every interaction with the account happens on-chain and can only be authorized by the owner of the funds.

Where are the funds stored?

All the funds for Hazy users are stored in one smart contract. For the outside observer, it is possible to view how many tokens are stored overall, as well as the details about the incoming and outgoing token transactions. But the actual balances and transfers of the individual users are not visible by simply looking at the contract.

From balances to hashes

Had the user account balances been stored openly in the smart contracts, it would be easy to track each transaction amount. By simply comparing the balance before and after the withdrawal transaction, you could have found out the exact amount.

Instead, Hazy Wallets stores the amount hashed with salt. Therefore, no balance information can be gained just by looking at the contract state.

Two-fold withdrawals

Every Hazy Wallet withdrawal occurs in two transactions. The first transaction modifies the smart contract's state, updating user balances (which are hashed) and storing information about the transfer amount and destination (which is also hashed).

After the random time interval trustless relayer submits the second transaction. Its function is to do the actual on-chain transfer. And since it is a regular transfer transaction, the amount and the recipient data is visible in the blockchain. However, since these transactions were separated, there is no direct link to the initial transaction which triggers the withdrawal.

Under the hood

Hazy Wallet also supports more complex operations, like swapping one token for another and bridging to a different blockchain. But how are these achieved in a non-custodial way?

The instructions on what to do with the funds are provided by the triggering transaction in the form of the hashed data. Only pre-approved actions are allowed when the relayer executes the second transaction. Here are some examples of what you can do with Hazy Wallet

  • Swap 2000 USDC to ETH and send ETH to the specified address

  • Swap 1000 MATIC to USDT and deposit them back to the user’s account on Hazy Wallet

  • Bridge 1000 USDT to Ethereum and send them to the specified address

The role of ZK proofs

As you can see, Hazy Wallet smart contract constantly works with the hashed data, be that amounts, addresses, or more complex instructions. While not knowing what kind of data it handles, it must ensure that all updates are consistent and valid.

For example, let’s consider updating the user balance before the withdrawal. Initially, the user had 1000 USDC on the account, and after the transfer was completed, only 500 USDC remained. But instead of the actual balances, smart contract operates with the hashed data.

The way the smart contract perceives the changes is the following: the balance was 20337472…32934893, and it was changed to 43992384…34398477, which to the outside observer are some random numbers. The smart contract does not have to make sense of these numbers, however, it needs to be sure the update was valid, and this is where the ZK proofs come in.

Along with the balance update comes the proof that can be verified on-chain and confirms that such balances indeed exist and the math between them is correct. This way, the smart contract can track the user balances even without knowing them.

Last updated