Enclave Protocol — Workflow

Enclave Protocol
2 min readApr 7, 2021

Here is an example of working with pools. Vault Bob wants to anonymously swap ETH to USDT. To do this, he specifies n new addresses to receive, which are not associated with the sending address, and also selects n pools for exchange.

The algorithm generates a proof prf = P (pk, x, w) that the prover knows the secret value W and that the secret value satisfies program C.

Then the transaction is split into x parts using VRF

function getRandomNumber(uint256 userProvidedSeed) public returns (bytes32 requestId) {

require(ENZK.balanceOf(address(this)) >= fee, );

return requestRandomness(keyHash, fee, userProvidedSeed);

Then goes through several pools, while each pool does not know the initial exchange amount, thanks to zero knowledge.

The proving algorithm V computes V (vk, x, prf) which is true if the proof is true and false otherwise.

function transfer(address_to, bytes32 hashValue,

bytes32 hashSenderBalanceAfter, bytes32 hashReceiverBalanceAfter, bytes zkProofSender, bytes zkProofReceiver)

{

bytes32 hashSenderBalanceBefore = balanceHashes[msg.sender];

bytes32 hashReceiverBalanceBefore = balanceHashes[_to];

bool senderProofIsCorrect = zksnarkverify(confTxSenderVk, [hashSenderBalanceBefore, hashSenderBalanceAfter, hashValue], zkProofSender);

bool receiverProofIsCorrect = zksnarkverify(confTxReceiverVk, [hashReceiverBalanceBefore, hashReceiverBalanceAfter, hashValue], zkProofReceiver);

if(senderProofIsCorrect && receiverProofIsCorrect) { balanceHashes[msg.sender] = hashSenderBalanceAfter;

balanceHashes[_to] = hashReceiverBalanceAfter; } }

Thus, this function returns true if the verifier knows that the secret value W satisfies

C (x, w) == true.

The smart contract refers to the Oracle generating pseudo-random numbers, based on which the system divides the payment into parts.

Bob receives USDT to the wallets specified earlier. At the same time, it will be impossible to link USDT to the original sender wallet.

In turn, Alice is a liquidity provider. As a result, she receives the ENZK tokens as a reward.

To receive the reward, she must provide proof of knowledge of the following information:

(snkw, pubkey, root; sk, dep, rwd, vrf) T

he pool works just like a classic mixer with a DeFi farm system. Where an investor who has pooled his tokens in the pool of tokens of a specific project receives a reward in the form of ENZK tokens.

Thus, we create pools of popular projects where you can receive rewards and at the same time maintaining a high level of anonymity for the entire network. Pr= (T*(Sb-Cb))*Rс)

Pr — pool rewards, T — number of locked tokens, Sb — start block, Cb — Current block, Rс — rewards coefficient

--

--