receiver -> recipient

This commit is contained in:
poma 2019-11-07 10:04:29 +03:00
parent 4d6dca78b2
commit c4dded8a20
7 changed files with 81 additions and 81 deletions

View File

@ -29,7 +29,7 @@ template CommitmentHasher() {
template Withdraw(levels) { template Withdraw(levels) {
signal input root; signal input root;
signal input nullifierHash; signal input nullifierHash;
signal input receiver; // not taking part in any computations signal input recipient; // not taking part in any computations
signal input relayer; // not taking part in any computations signal input relayer; // not taking part in any computations
signal input fee; // not taking part in any computations signal input fee; // not taking part in any computations
signal input refund; // not taking part in any computations signal input refund; // not taking part in any computations

34
cli.js
View File

@ -66,7 +66,7 @@ async function depositErc20() {
return note return note
} }
async function withdrawErc20(note, receiver, relayer) { async function withdrawErc20(note, recipient, relayer) {
let buf = Buffer.from(note.slice(2), 'hex') let buf = Buffer.from(note.slice(2), 'hex')
let deposit = createDeposit(bigInt.leBuff2int(buf.slice(0, 31)), bigInt.leBuff2int(buf.slice(31, 62))) let deposit = createDeposit(bigInt.leBuff2int(buf.slice(0, 31)), bigInt.leBuff2int(buf.slice(31, 62)))
@ -98,7 +98,7 @@ async function withdrawErc20(note, receiver, relayer) {
// public // public
root: root, root: root,
nullifierHash, nullifierHash,
receiver: bigInt(receiver), recipient: bigInt(recipient),
relayer: bigInt(relayer), relayer: bigInt(relayer),
fee: bigInt(web3.utils.toWei('0.01')), fee: bigInt(web3.utils.toWei('0.01')),
refund: bigInt(0), refund: bigInt(0),
@ -120,7 +120,7 @@ async function withdrawErc20(note, receiver, relayer) {
const args = [ const args = [
toHex(input.root), toHex(input.root),
toHex(input.nullifierHash), toHex(input.nullifierHash),
toHex(input.receiver, 20), toHex(input.recipient, 20),
toHex(input.relayer, 20), toHex(input.relayer, 20),
toHex(input.fee), toHex(input.fee),
toHex(input.refund) toHex(input.refund)
@ -129,20 +129,20 @@ async function withdrawErc20(note, receiver, relayer) {
console.log('Done') console.log('Done')
} }
async function getBalance(receiver) { async function getBalance(recipient) {
const balance = await web3.eth.getBalance(receiver) const balance = await web3.eth.getBalance(recipient)
console.log('Balance is ', web3.utils.fromWei(balance)) console.log('Balance is ', web3.utils.fromWei(balance))
} }
async function getBalanceErc20(receiver, relayer) { async function getBalanceErc20(recipient, relayer) {
const balanceReceiver = await web3.eth.getBalance(receiver) const balanceRecipient = await web3.eth.getBalance(recipient)
const balanceRelayer = await web3.eth.getBalance(relayer) const balanceRelayer = await web3.eth.getBalance(relayer)
const tokenBalanceReceiver = await erc20.methods.balanceOf(receiver).call() const tokenBalanceRecipient = await erc20.methods.balanceOf(recipient).call()
const tokenBalanceRelayer = await erc20.methods.balanceOf(relayer).call() const tokenBalanceRelayer = await erc20.methods.balanceOf(relayer).call()
console.log('Receiver eth Balance is ', web3.utils.fromWei(balanceReceiver)) console.log('Recipient eth Balance is ', web3.utils.fromWei(balanceRecipient))
console.log('Relayer eth Balance is ', web3.utils.fromWei(balanceRelayer)) console.log('Relayer eth Balance is ', web3.utils.fromWei(balanceRelayer))
console.log('Receiver token Balance is ', web3.utils.fromWei(tokenBalanceReceiver.toString())) console.log('Recipient token Balance is ', web3.utils.fromWei(tokenBalanceRecipient.toString()))
console.log('Relayer token Balance is ', web3.utils.fromWei(tokenBalanceRelayer.toString())) console.log('Relayer token Balance is ', web3.utils.fromWei(tokenBalanceRelayer.toString()))
} }
@ -153,7 +153,7 @@ function toHex(number, length = 32) {
return str return str
} }
async function withdraw(note, receiver) { async function withdraw(note, recipient) {
// Decode hex string and restore the deposit object // Decode hex string and restore the deposit object
let buf = Buffer.from(note.slice(2), 'hex') let buf = Buffer.from(note.slice(2), 'hex')
let deposit = createDeposit(bigInt.leBuff2int(buf.slice(0, 31)), bigInt.leBuff2int(buf.slice(31, 62))) let deposit = createDeposit(bigInt.leBuff2int(buf.slice(0, 31)), bigInt.leBuff2int(buf.slice(31, 62)))
@ -188,7 +188,7 @@ async function withdraw(note, receiver) {
// Public snark inputs // Public snark inputs
root: root, root: root,
nullifierHash, nullifierHash,
receiver: bigInt(receiver), recipient: bigInt(recipient),
relayer: bigInt(0), relayer: bigInt(0),
fee: bigInt(0), fee: bigInt(0),
refund: bigInt(0), refund: bigInt(0),
@ -210,7 +210,7 @@ async function withdraw(note, receiver) {
const args = [ const args = [
toHex(input.root), toHex(input.root),
toHex(input.nullifierHash), toHex(input.nullifierHash),
toHex(input.receiver, 20), toHex(input.recipient, 20),
toHex(input.relayer, 20), toHex(input.relayer, 20),
toHex(input.fee), toHex(input.fee),
toHex(input.refund) toHex(input.refund)
@ -273,8 +273,8 @@ function printHelp(code = 0) {
Submit a deposit from default eth account and return the resulting note Submit a deposit from default eth account and return the resulting note
$ ./cli.js deposit $ ./cli.js deposit
Withdraw a note to 'receiver' account Withdraw a note to 'recipient' account
$ ./cli.js withdraw <note> <receiver> $ ./cli.js withdraw <note> <recipient>
Check address balance Check address balance
$ ./cli.js balance <address> $ ./cli.js balance <address>
@ -293,8 +293,8 @@ if (inBrowser) {
window.deposit = deposit window.deposit = deposit
window.withdraw = async () => { window.withdraw = async () => {
const note = prompt('Enter the note to withdraw') const note = prompt('Enter the note to withdraw')
const receiver = (await web3.eth.getAccounts())[0] const recipient = (await web3.eth.getAccounts())[0]
await withdraw(note, receiver) await withdraw(note, recipient)
} }
init() init()
} else { } else {

View File

@ -31,15 +31,15 @@ contract ERC20Mixer is Mixer {
_safeErc20TransferFrom(msg.sender, address(this), denomination); _safeErc20TransferFrom(msg.sender, address(this), denomination);
} }
function _processWithdraw(address payable _receiver, address payable _relayer, uint256 _fee, uint256 _refund) internal { function _processWithdraw(address payable _recipient, address payable _relayer, uint256 _fee, uint256 _refund) internal {
require(msg.value == _refund, "Incorrect refund amount received by the contract"); require(msg.value == _refund, "Incorrect refund amount received by the contract");
_safeErc20Transfer(_receiver, denomination - _fee); _safeErc20Transfer(_recipient, denomination - _fee);
if (_fee > 0) { if (_fee > 0) {
_safeErc20Transfer(_relayer, _fee); _safeErc20Transfer(_relayer, _fee);
} }
if (_refund > 0) { if (_refund > 0) {
_receiver.transfer(_refund); _recipient.transfer(_refund);
} }
} }

View File

@ -26,12 +26,12 @@ contract ETHMixer is Mixer {
require(msg.value == denomination, "Please send `mixDenomination` ETH along with transaction"); require(msg.value == denomination, "Please send `mixDenomination` ETH along with transaction");
} }
function _processWithdraw(address payable _receiver, address payable _relayer, uint256 _fee, uint256 _refund) internal { function _processWithdraw(address payable _recipient, address payable _relayer, uint256 _fee, uint256 _refund) internal {
// sanity checks // sanity checks
require(msg.value == 0, "Message value is supposed to be zero for ETH mixer"); require(msg.value == 0, "Message value is supposed to be zero for ETH mixer");
require(_refund == 0, "Refund value is supposed to be zero for ETH mixer"); require(_refund == 0, "Refund value is supposed to be zero for ETH mixer");
_receiver.transfer(denomination - _fee); _recipient.transfer(denomination - _fee);
if (_fee > 0) { if (_fee > 0) {
_relayer.transfer(_fee); _relayer.transfer(_fee);
} }

View File

@ -80,22 +80,22 @@ contract Mixer is MerkleTreeWithHistory {
`input` array consists of: `input` array consists of:
- merkle root of all deposits in the mixer - merkle root of all deposits in the mixer
- hash of unique deposit nullifier to prevent double spends - hash of unique deposit nullifier to prevent double spends
- the receiver of funds - the recipient of funds
- optional fee that goes to the transaction sender (usually a relay) - optional fee that goes to the transaction sender (usually a relay)
*/ */
function withdraw(bytes calldata _proof, bytes32 _root, bytes32 _nullifierHash, address payable _receiver, address payable _relayer, uint256 _fee, uint256 _refund) external payable { function withdraw(bytes calldata _proof, bytes32 _root, bytes32 _nullifierHash, address payable _recipient, address payable _relayer, uint256 _fee, uint256 _refund) external payable {
require(_fee <= denomination, "Fee exceeds transfer value"); require(_fee <= denomination, "Fee exceeds transfer value");
require(!nullifierHashes[_nullifierHash], "The note has been already spent"); require(!nullifierHashes[_nullifierHash], "The note has been already spent");
require(isKnownRoot(_root), "Cannot find your merkle root"); // Make sure to use a recent one require(isKnownRoot(_root), "Cannot find your merkle root"); // Make sure to use a recent one
require(verifier.verifyProof(_proof, [uint256(_root), uint256(_nullifierHash), uint256(_receiver), uint256(_relayer), _fee, _refund]), "Invalid withdraw proof"); require(verifier.verifyProof(_proof, [uint256(_root), uint256(_nullifierHash), uint256(_recipient), uint256(_relayer), _fee, _refund]), "Invalid withdraw proof");
nullifierHashes[_nullifierHash] = true; nullifierHashes[_nullifierHash] = true;
_processWithdraw(_receiver, _relayer, _fee, _refund); _processWithdraw(_recipient, _relayer, _fee, _refund);
emit Withdrawal(_receiver, _nullifierHash, _relayer, _fee); emit Withdrawal(_recipient, _nullifierHash, _relayer, _fee);
} }
/** @dev this function is defined in a child contract */ /** @dev this function is defined in a child contract */
function _processWithdraw(address payable _receiver, address payable _relayer, uint256 _fee, uint256 _refund) internal; function _processWithdraw(address payable _recipient, address payable _relayer, uint256 _fee, uint256 _refund) internal;
/** @dev whether a note is already spent */ /** @dev whether a note is already spent */
function isSpent(bytes32 _nullifierHash) external view returns(bool) { function isSpent(bytes32 _nullifierHash) external view returns(bool) {

View File

@ -35,12 +35,12 @@ function generateDeposit() {
return deposit return deposit
} }
function getRandomReceiver() { function getRandomRecipient() {
let receiver = rbigint(20) let recipient = rbigint(20)
while (toHex(receiver.toString()).length !== 42) { while (toHex(recipient.toString()).length !== 42) {
receiver = rbigint(20) recipient = rbigint(20)
} }
return receiver return recipient
} }
function toFixedHex(number, length = 32) { function toFixedHex(number, length = 32) {
@ -63,7 +63,7 @@ contract('ERC20Mixer', accounts => {
let tree let tree
const fee = bigInt(ETH_AMOUNT).shr(1) || bigInt(1e17) const fee = bigInt(ETH_AMOUNT).shr(1) || bigInt(1e17)
const refund = ETH_AMOUNT || '1000000000000000000' // 1 ether const refund = ETH_AMOUNT || '1000000000000000000' // 1 ether
const receiver = getRandomReceiver() const recipient = getRandomRecipient()
const relayer = accounts[1] const relayer = accounts[1]
let groth16 let groth16
let circuit let circuit
@ -141,7 +141,7 @@ contract('ERC20Mixer', accounts => {
root, root,
nullifierHash: pedersenHash(deposit.nullifier.leInt2Buff(31)), nullifierHash: pedersenHash(deposit.nullifier.leInt2Buff(31)),
relayer, relayer,
receiver, recipient,
fee, fee,
refund, refund,
@ -158,10 +158,10 @@ contract('ERC20Mixer', accounts => {
const balanceMixerBefore = await token.balanceOf(mixer.address) const balanceMixerBefore = await token.balanceOf(mixer.address)
const balanceRelayerBefore = await token.balanceOf(relayer) const balanceRelayerBefore = await token.balanceOf(relayer)
const balanceRecieverBefore = await token.balanceOf(toHex(receiver.toString())) const balanceRecieverBefore = await token.balanceOf(toHex(recipient.toString()))
const ethBalanceOperatorBefore = await web3.eth.getBalance(operator) const ethBalanceOperatorBefore = await web3.eth.getBalance(operator)
const ethBalanceRecieverBefore = await web3.eth.getBalance(toHex(receiver.toString())) const ethBalanceRecieverBefore = await web3.eth.getBalance(toHex(recipient.toString()))
const ethBalanceRelayerBefore = await web3.eth.getBalance(relayer) const ethBalanceRelayerBefore = await web3.eth.getBalance(relayer)
let isSpent = await mixer.isSpent(toFixedHex(input.nullifierHash)) let isSpent = await mixer.isSpent(toFixedHex(input.nullifierHash))
isSpent.should.be.equal(false) isSpent.should.be.equal(false)
@ -171,7 +171,7 @@ contract('ERC20Mixer', accounts => {
const args = [ const args = [
toFixedHex(input.root), toFixedHex(input.root),
toFixedHex(input.nullifierHash), toFixedHex(input.nullifierHash),
toFixedHex(input.receiver, 20), toFixedHex(input.recipient, 20),
toFixedHex(input.relayer, 20), toFixedHex(input.relayer, 20),
toFixedHex(input.fee), toFixedHex(input.fee),
toFixedHex(input.refund) toFixedHex(input.refund)
@ -181,8 +181,8 @@ contract('ERC20Mixer', accounts => {
const balanceMixerAfter = await token.balanceOf(mixer.address) const balanceMixerAfter = await token.balanceOf(mixer.address)
const balanceRelayerAfter = await token.balanceOf(relayer) const balanceRelayerAfter = await token.balanceOf(relayer)
const ethBalanceOperatorAfter = await web3.eth.getBalance(operator) const ethBalanceOperatorAfter = await web3.eth.getBalance(operator)
const balanceRecieverAfter = await token.balanceOf(toHex(receiver.toString())) const balanceRecieverAfter = await token.balanceOf(toHex(recipient.toString()))
const ethBalanceRecieverAfter = await web3.eth.getBalance(toHex(receiver.toString())) const ethBalanceRecieverAfter = await web3.eth.getBalance(toHex(recipient.toString()))
const ethBalanceRelayerAfter = await web3.eth.getBalance(relayer) const ethBalanceRelayerAfter = await web3.eth.getBalance(relayer)
const feeBN = toBN(fee.toString()) const feeBN = toBN(fee.toString())
balanceMixerAfter.should.be.eq.BN(toBN(balanceMixerBefore).sub(toBN(tokenDenomination))) balanceMixerAfter.should.be.eq.BN(toBN(balanceMixerBefore).sub(toBN(tokenDenomination)))
@ -217,7 +217,7 @@ contract('ERC20Mixer', accounts => {
root, root,
nullifierHash: pedersenHash(deposit.nullifier.leInt2Buff(31)), nullifierHash: pedersenHash(deposit.nullifier.leInt2Buff(31)),
relayer, relayer,
receiver, recipient,
fee, fee,
refund, refund,
@ -235,7 +235,7 @@ contract('ERC20Mixer', accounts => {
const args = [ const args = [
toFixedHex(input.root), toFixedHex(input.root),
toFixedHex(input.nullifierHash), toFixedHex(input.nullifierHash),
toFixedHex(input.receiver, 20), toFixedHex(input.recipient, 20),
toFixedHex(input.relayer, 20), toFixedHex(input.relayer, 20),
toFixedHex(input.fee), toFixedHex(input.fee),
toFixedHex(input.refund) toFixedHex(input.refund)
@ -284,7 +284,7 @@ contract('ERC20Mixer', accounts => {
root, root,
nullifierHash: pedersenHash(deposit.nullifier.leInt2Buff(31)), nullifierHash: pedersenHash(deposit.nullifier.leInt2Buff(31)),
relayer: operator, relayer: operator,
receiver, recipient,
fee, fee,
refund, refund,
@ -302,8 +302,8 @@ contract('ERC20Mixer', accounts => {
const balanceMixerBefore = await usdtToken.balanceOf(mixer.address) const balanceMixerBefore = await usdtToken.balanceOf(mixer.address)
const balanceRelayerBefore = await usdtToken.balanceOf(relayer) const balanceRelayerBefore = await usdtToken.balanceOf(relayer)
const ethBalanceOperatorBefore = await web3.eth.getBalance(operator) const ethBalanceOperatorBefore = await web3.eth.getBalance(operator)
const balanceRecieverBefore = await usdtToken.balanceOf(toHex(receiver.toString())) const balanceRecieverBefore = await usdtToken.balanceOf(toHex(recipient.toString()))
const ethBalanceRecieverBefore = await web3.eth.getBalance(toHex(receiver.toString())) const ethBalanceRecieverBefore = await web3.eth.getBalance(toHex(recipient.toString()))
let isSpent = await mixer.isSpent(input.nullifierHash.toString(16).padStart(66, '0x00000')) let isSpent = await mixer.isSpent(input.nullifierHash.toString(16).padStart(66, '0x00000'))
isSpent.should.be.equal(false) isSpent.should.be.equal(false)
@ -313,7 +313,7 @@ contract('ERC20Mixer', accounts => {
const args = [ const args = [
toFixedHex(input.root), toFixedHex(input.root),
toFixedHex(input.nullifierHash), toFixedHex(input.nullifierHash),
toFixedHex(input.receiver, 20), toFixedHex(input.recipient, 20),
toFixedHex(input.relayer, 20), toFixedHex(input.relayer, 20),
toFixedHex(input.fee), toFixedHex(input.fee),
toFixedHex(input.refund) toFixedHex(input.refund)
@ -323,8 +323,8 @@ contract('ERC20Mixer', accounts => {
const balanceMixerAfter = await usdtToken.balanceOf(mixer.address) const balanceMixerAfter = await usdtToken.balanceOf(mixer.address)
const balanceRelayerAfter = await usdtToken.balanceOf(relayer) const balanceRelayerAfter = await usdtToken.balanceOf(relayer)
const ethBalanceOperatorAfter = await web3.eth.getBalance(operator) const ethBalanceOperatorAfter = await web3.eth.getBalance(operator)
const balanceRecieverAfter = await usdtToken.balanceOf(toHex(receiver.toString())) const balanceRecieverAfter = await usdtToken.balanceOf(toHex(recipient.toString()))
const ethBalanceRecieverAfter = await web3.eth.getBalance(toHex(receiver.toString())) const ethBalanceRecieverAfter = await web3.eth.getBalance(toHex(recipient.toString()))
const feeBN = toBN(fee.toString()) const feeBN = toBN(fee.toString())
balanceMixerAfter.should.be.eq.BN(toBN(balanceMixerBefore).sub(toBN(tokenDenomination))) balanceMixerAfter.should.be.eq.BN(toBN(balanceMixerBefore).sub(toBN(tokenDenomination)))
balanceRelayerAfter.should.be.eq.BN(toBN(balanceRelayerBefore)) balanceRelayerAfter.should.be.eq.BN(toBN(balanceRelayerBefore))
@ -373,7 +373,7 @@ contract('ERC20Mixer', accounts => {
root, root,
nullifierHash: pedersenHash(deposit.nullifier.leInt2Buff(31)), nullifierHash: pedersenHash(deposit.nullifier.leInt2Buff(31)),
relayer: operator, relayer: operator,
receiver, recipient,
fee, fee,
refund, refund,
@ -391,8 +391,8 @@ contract('ERC20Mixer', accounts => {
const balanceMixerBefore = await token.balanceOf(mixer.address) const balanceMixerBefore = await token.balanceOf(mixer.address)
const balanceRelayerBefore = await token.balanceOf(relayer) const balanceRelayerBefore = await token.balanceOf(relayer)
const ethBalanceOperatorBefore = await web3.eth.getBalance(operator) const ethBalanceOperatorBefore = await web3.eth.getBalance(operator)
const balanceRecieverBefore = await token.balanceOf(toHex(receiver.toString())) const balanceRecieverBefore = await token.balanceOf(toHex(recipient.toString()))
const ethBalanceRecieverBefore = await web3.eth.getBalance(toHex(receiver.toString())) const ethBalanceRecieverBefore = await web3.eth.getBalance(toHex(recipient.toString()))
let isSpent = await mixer.isSpent(input.nullifierHash.toString(16).padStart(66, '0x00000')) let isSpent = await mixer.isSpent(input.nullifierHash.toString(16).padStart(66, '0x00000'))
isSpent.should.be.equal(false) isSpent.should.be.equal(false)
@ -402,7 +402,7 @@ contract('ERC20Mixer', accounts => {
const args = [ const args = [
toFixedHex(input.root), toFixedHex(input.root),
toFixedHex(input.nullifierHash), toFixedHex(input.nullifierHash),
toFixedHex(input.receiver, 20), toFixedHex(input.recipient, 20),
toFixedHex(input.relayer, 20), toFixedHex(input.relayer, 20),
toFixedHex(input.fee), toFixedHex(input.fee),
toFixedHex(input.refund) toFixedHex(input.refund)
@ -413,8 +413,8 @@ contract('ERC20Mixer', accounts => {
const balanceMixerAfter = await token.balanceOf(mixer.address) const balanceMixerAfter = await token.balanceOf(mixer.address)
const balanceRelayerAfter = await token.balanceOf(relayer) const balanceRelayerAfter = await token.balanceOf(relayer)
const ethBalanceOperatorAfter = await web3.eth.getBalance(operator) const ethBalanceOperatorAfter = await web3.eth.getBalance(operator)
const balanceRecieverAfter = await token.balanceOf(toHex(receiver.toString())) const balanceRecieverAfter = await token.balanceOf(toHex(recipient.toString()))
const ethBalanceRecieverAfter = await web3.eth.getBalance(toHex(receiver.toString())) const ethBalanceRecieverAfter = await web3.eth.getBalance(toHex(recipient.toString()))
const feeBN = toBN(fee.toString()) const feeBN = toBN(fee.toString())
balanceMixerAfter.should.be.eq.BN(toBN(balanceMixerBefore).sub(toBN(tokenDenomination))) balanceMixerAfter.should.be.eq.BN(toBN(balanceMixerBefore).sub(toBN(tokenDenomination)))
balanceRelayerAfter.should.be.eq.BN(toBN(balanceRelayerBefore)) balanceRelayerAfter.should.be.eq.BN(toBN(balanceRelayerBefore))

View File

@ -43,12 +43,12 @@ function BNArrayToStringArray(array) {
return arrayToPrint return arrayToPrint
} }
function getRandomReceiver() { function getRandomRecipient() {
let receiver = rbigint(20) let recipient = rbigint(20)
while (toHex(receiver.toString()).length !== 42) { while (toHex(recipient.toString()).length !== 42) {
receiver = rbigint(20) recipient = rbigint(20)
} }
return receiver return recipient
} }
function snarkVerify(proof) { function snarkVerify(proof) {
@ -75,7 +75,7 @@ contract('ETHMixer', accounts => {
let tree let tree
const fee = bigInt(ETH_AMOUNT).shr(1) || bigInt(1e17) const fee = bigInt(ETH_AMOUNT).shr(1) || bigInt(1e17)
const refund = bigInt(0) const refund = bigInt(0)
const receiver = getRandomReceiver() const recipient = getRandomRecipient()
const relayer = accounts[1] const relayer = accounts[1]
let groth16 let groth16
let circuit let circuit
@ -152,7 +152,7 @@ contract('ETHMixer', accounts => {
nullifierHash: pedersenHash(deposit.nullifier.leInt2Buff(31)), nullifierHash: pedersenHash(deposit.nullifier.leInt2Buff(31)),
nullifier: deposit.nullifier, nullifier: deposit.nullifier,
relayer: operator, relayer: operator,
receiver, recipient,
fee, fee,
refund, refund,
secret: deposit.secret, secret: deposit.secret,
@ -209,7 +209,7 @@ contract('ETHMixer', accounts => {
root, root,
nullifierHash: pedersenHash(deposit.nullifier.leInt2Buff(31)), nullifierHash: pedersenHash(deposit.nullifier.leInt2Buff(31)),
relayer: operator, relayer: operator,
receiver, recipient,
fee, fee,
refund, refund,
@ -227,7 +227,7 @@ contract('ETHMixer', accounts => {
const balanceMixerBefore = await web3.eth.getBalance(mixer.address) const balanceMixerBefore = await web3.eth.getBalance(mixer.address)
const balanceRelayerBefore = await web3.eth.getBalance(relayer) const balanceRelayerBefore = await web3.eth.getBalance(relayer)
const balanceOperatorBefore = await web3.eth.getBalance(operator) const balanceOperatorBefore = await web3.eth.getBalance(operator)
const balanceRecieverBefore = await web3.eth.getBalance(toHex(receiver.toString())) const balanceRecieverBefore = await web3.eth.getBalance(toHex(recipient.toString()))
let isSpent = await mixer.isSpent(toFixedHex(input.nullifierHash)) let isSpent = await mixer.isSpent(toFixedHex(input.nullifierHash))
isSpent.should.be.equal(false) isSpent.should.be.equal(false)
@ -237,7 +237,7 @@ contract('ETHMixer', accounts => {
const args = [ const args = [
toFixedHex(input.root), toFixedHex(input.root),
toFixedHex(input.nullifierHash), toFixedHex(input.nullifierHash),
toFixedHex(input.receiver, 20), toFixedHex(input.recipient, 20),
toFixedHex(input.relayer, 20), toFixedHex(input.relayer, 20),
toFixedHex(input.fee), toFixedHex(input.fee),
toFixedHex(input.refund) toFixedHex(input.refund)
@ -247,7 +247,7 @@ contract('ETHMixer', accounts => {
const balanceMixerAfter = await web3.eth.getBalance(mixer.address) const balanceMixerAfter = await web3.eth.getBalance(mixer.address)
const balanceRelayerAfter = await web3.eth.getBalance(relayer) const balanceRelayerAfter = await web3.eth.getBalance(relayer)
const balanceOperatorAfter = await web3.eth.getBalance(operator) const balanceOperatorAfter = await web3.eth.getBalance(operator)
const balanceRecieverAfter = await web3.eth.getBalance(toHex(receiver.toString())) const balanceRecieverAfter = await web3.eth.getBalance(toHex(recipient.toString()))
const feeBN = toBN(fee.toString()) const feeBN = toBN(fee.toString())
balanceMixerAfter.should.be.eq.BN(toBN(balanceMixerBefore).sub(toBN(value))) balanceMixerAfter.should.be.eq.BN(toBN(balanceMixerBefore).sub(toBN(value)))
balanceRelayerAfter.should.be.eq.BN(toBN(balanceRelayerBefore)) balanceRelayerAfter.should.be.eq.BN(toBN(balanceRelayerBefore))
@ -275,7 +275,7 @@ contract('ETHMixer', accounts => {
nullifierHash: pedersenHash(deposit.nullifier.leInt2Buff(31)), nullifierHash: pedersenHash(deposit.nullifier.leInt2Buff(31)),
nullifier: deposit.nullifier, nullifier: deposit.nullifier,
relayer: operator, relayer: operator,
receiver, recipient,
fee, fee,
refund, refund,
secret: deposit.secret, secret: deposit.secret,
@ -287,7 +287,7 @@ contract('ETHMixer', accounts => {
const args = [ const args = [
toFixedHex(input.root), toFixedHex(input.root),
toFixedHex(input.nullifierHash), toFixedHex(input.nullifierHash),
toFixedHex(input.receiver, 20), toFixedHex(input.recipient, 20),
toFixedHex(input.relayer, 20), toFixedHex(input.relayer, 20),
toFixedHex(input.fee), toFixedHex(input.fee),
toFixedHex(input.refund) toFixedHex(input.refund)
@ -309,7 +309,7 @@ contract('ETHMixer', accounts => {
nullifierHash: pedersenHash(deposit.nullifier.leInt2Buff(31)), nullifierHash: pedersenHash(deposit.nullifier.leInt2Buff(31)),
nullifier: deposit.nullifier, nullifier: deposit.nullifier,
relayer: operator, relayer: operator,
receiver, recipient,
fee, fee,
refund, refund,
secret: deposit.secret, secret: deposit.secret,
@ -321,7 +321,7 @@ contract('ETHMixer', accounts => {
const args = [ const args = [
toFixedHex(input.root), toFixedHex(input.root),
toFixedHex(toBN(input.nullifierHash).add(toBN('21888242871839275222246405745257275088548364400416034343698204186575808495617'))), toFixedHex(toBN(input.nullifierHash).add(toBN('21888242871839275222246405745257275088548364400416034343698204186575808495617'))),
toFixedHex(input.receiver, 20), toFixedHex(input.recipient, 20),
toFixedHex(input.relayer, 20), toFixedHex(input.relayer, 20),
toFixedHex(input.fee), toFixedHex(input.fee),
toFixedHex(input.refund) toFixedHex(input.refund)
@ -342,7 +342,7 @@ contract('ETHMixer', accounts => {
nullifierHash: pedersenHash(deposit.nullifier.leInt2Buff(31)), nullifierHash: pedersenHash(deposit.nullifier.leInt2Buff(31)),
nullifier: deposit.nullifier, nullifier: deposit.nullifier,
relayer: operator, relayer: operator,
receiver, recipient,
fee: oneEtherFee, fee: oneEtherFee,
refund, refund,
secret: deposit.secret, secret: deposit.secret,
@ -355,7 +355,7 @@ contract('ETHMixer', accounts => {
const args = [ const args = [
toFixedHex(input.root), toFixedHex(input.root),
toFixedHex(input.nullifierHash), toFixedHex(input.nullifierHash),
toFixedHex(input.receiver, 20), toFixedHex(input.recipient, 20),
toFixedHex(input.relayer, 20), toFixedHex(input.relayer, 20),
toFixedHex(input.fee), toFixedHex(input.fee),
toFixedHex(input.refund) toFixedHex(input.refund)
@ -376,7 +376,7 @@ contract('ETHMixer', accounts => {
root, root,
nullifier: deposit.nullifier, nullifier: deposit.nullifier,
relayer: operator, relayer: operator,
receiver, recipient,
fee, fee,
refund, refund,
secret: deposit.secret, secret: deposit.secret,
@ -390,7 +390,7 @@ contract('ETHMixer', accounts => {
const args = [ const args = [
toFixedHex(randomHex(32)), toFixedHex(randomHex(32)),
toFixedHex(input.nullifierHash), toFixedHex(input.nullifierHash),
toFixedHex(input.receiver, 20), toFixedHex(input.recipient, 20),
toFixedHex(input.relayer, 20), toFixedHex(input.relayer, 20),
toFixedHex(input.fee), toFixedHex(input.fee),
toFixedHex(input.refund) toFixedHex(input.refund)
@ -411,7 +411,7 @@ contract('ETHMixer', accounts => {
nullifierHash: pedersenHash(deposit.nullifier.leInt2Buff(31)), nullifierHash: pedersenHash(deposit.nullifier.leInt2Buff(31)),
nullifier: deposit.nullifier, nullifier: deposit.nullifier,
relayer: operator, relayer: operator,
receiver, recipient,
fee, fee,
refund, refund,
secret: deposit.secret, secret: deposit.secret,
@ -423,7 +423,7 @@ contract('ETHMixer', accounts => {
const args = [ const args = [
toFixedHex(input.root), toFixedHex(input.root),
toFixedHex(input.nullifierHash), toFixedHex(input.nullifierHash),
toFixedHex(input.receiver, 20), toFixedHex(input.recipient, 20),
toFixedHex(input.relayer, 20), toFixedHex(input.relayer, 20),
toFixedHex(input.fee), toFixedHex(input.fee),
toFixedHex(input.refund) toFixedHex(input.refund)
@ -431,7 +431,7 @@ contract('ETHMixer', accounts => {
let incorrectArgs let incorrectArgs
const originalProof = proof.slice() const originalProof = proof.slice()
// receiver // recipient
incorrectArgs = [ incorrectArgs = [
toFixedHex(input.root), toFixedHex(input.root),
toFixedHex(input.nullifierHash), toFixedHex(input.nullifierHash),
@ -447,7 +447,7 @@ contract('ETHMixer', accounts => {
incorrectArgs = [ incorrectArgs = [
toFixedHex(input.root), toFixedHex(input.root),
toFixedHex(input.nullifierHash), toFixedHex(input.nullifierHash),
toFixedHex(input.receiver, 20), toFixedHex(input.recipient, 20),
toFixedHex(input.relayer, 20), toFixedHex(input.relayer, 20),
toFixedHex('0x000000000000000000000000000000000000000000000000015345785d8a0000'), toFixedHex('0x000000000000000000000000000000000000000000000000015345785d8a0000'),
toFixedHex(input.refund) toFixedHex(input.refund)
@ -459,7 +459,7 @@ contract('ETHMixer', accounts => {
incorrectArgs = [ incorrectArgs = [
toFixedHex(input.root), toFixedHex(input.root),
toFixedHex('0x00abdfc78211f8807b9c6504a6e537e71b8788b2f529a95f1399ce124a8642ad'), toFixedHex('0x00abdfc78211f8807b9c6504a6e537e71b8788b2f529a95f1399ce124a8642ad'),
toFixedHex(input.receiver, 20), toFixedHex(input.recipient, 20),
toFixedHex(input.relayer, 20), toFixedHex(input.relayer, 20),
toFixedHex(input.fee), toFixedHex(input.fee),
toFixedHex(input.refund) toFixedHex(input.refund)
@ -487,7 +487,7 @@ contract('ETHMixer', accounts => {
root, root,
nullifier: deposit.nullifier, nullifier: deposit.nullifier,
relayer: operator, relayer: operator,
receiver, recipient,
fee, fee,
refund: bigInt(1), refund: bigInt(1),
secret: deposit.secret, secret: deposit.secret,
@ -501,7 +501,7 @@ contract('ETHMixer', accounts => {
const args = [ const args = [
toFixedHex(input.root), toFixedHex(input.root),
toFixedHex(input.nullifierHash), toFixedHex(input.nullifierHash),
toFixedHex(input.receiver, 20), toFixedHex(input.recipient, 20),
toFixedHex(input.relayer, 20), toFixedHex(input.relayer, 20),
toFixedHex(input.fee), toFixedHex(input.fee),
toFixedHex(input.refund) toFixedHex(input.refund)