Skip to content

Commit

Permalink
Add "data" parameter to encrypted transfer methods/events
Browse files Browse the repository at this point in the history
Signed-off-by: Andrew Richardson <[email protected]>
  • Loading branch information
awrichar committed Sep 20, 2024
1 parent 371b5db commit e09ae65
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 11 deletions.
3 changes: 2 additions & 1 deletion solidity/contracts/lib/interfaces/izeto_encrypted.sol
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ interface IZetoEncrypted is IZetoBase {
uint256[] outputs,
uint256 encryptionNonce,
uint256[] encryptedValues,
address indexed submitter
address indexed submitter,
bytes data
);
}
6 changes: 4 additions & 2 deletions solidity/contracts/zeto_anon_enc.sol
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ contract Zeto_AnonEnc is IZetoEncrypted, ZetoBase, ZetoFungibleWithdraw, UUPSUpg
uint256[2] memory outputs,
uint256 encryptionNonce,
uint256[4] memory encryptedValues,
Commonlib.Proof calldata proof
Commonlib.Proof calldata proof,
bytes calldata data
) public returns (bool) {
require(
validateTransactionProposal(inputs, outputs, proof),
Expand Down Expand Up @@ -112,7 +113,8 @@ contract Zeto_AnonEnc is IZetoEncrypted, ZetoBase, ZetoFungibleWithdraw, UUPSUpg
outputArray,
encryptionNonce,
encryptedValuesArray,
msg.sender
msg.sender,
data
);
return true;
}
Expand Down
6 changes: 4 additions & 2 deletions solidity/contracts/zeto_anon_enc_nullifier.sol
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ contract Zeto_AnonEncNullifier is
uint256 root,
uint256 encryptionNonce,
uint256[4] memory encryptedValues,
Commonlib.Proof calldata proof
Commonlib.Proof calldata proof,
bytes calldata data
) public returns (bool) {
require(
validateTransactionProposal(nullifiers, outputs, root),
Expand Down Expand Up @@ -127,7 +128,8 @@ contract Zeto_AnonEncNullifier is
outputArray,
encryptionNonce,
encryptedValuesArray,
msg.sender
msg.sender,
data
);
return true;
}
Expand Down
6 changes: 4 additions & 2 deletions solidity/contracts/zeto_anon_enc_nullifier_kyc.sol
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ contract Zeto_AnonEncNullifierKyc is
uint256 root,
uint256 encryptionNonce,
uint256[4] memory encryptedValues,
Commonlib.Proof calldata proof
Commonlib.Proof calldata proof,
bytes calldata data
) public returns (bool) {
require(
validateTransactionProposal(nullifiers, outputs, root),
Expand Down Expand Up @@ -133,7 +134,8 @@ contract Zeto_AnonEncNullifierKyc is
outputArray,
encryptionNonce,
encryptedValuesArray,
msg.sender
msg.sender,
data
);
return true;
}
Expand Down
11 changes: 10 additions & 1 deletion solidity/test/zeto_anon_enc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,16 @@ describe("Zeto based fungible token with anonymity and encryption", function ()
encryptionNonce: BigNumberish,
encodedProof: any
) {
const tx = await zeto.connect(signer.signer).transfer(inputCommitments, outputCommitments, encryptionNonce, encryptedValues, encodedProof);
const tx = await zeto
.connect(signer.signer)
.transfer(
inputCommitments,
outputCommitments,
encryptionNonce,
encryptedValues,
encodedProof,
"0x"
);
const results: ContractTransactionReceipt | null = await tx.wait();

for (const input of inputCommitments) {
Expand Down
12 changes: 11 additions & 1 deletion solidity/test/zeto_anon_enc_nullifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,17 @@ describe("Zeto based fungible token with anonymity using nullifiers and encrypti
encodedProof: any
) {
const startTx = Date.now();
const tx = await zeto.connect(signer.signer).transfer(nullifiers, outputCommitments, root, encryptionNonce, encryptedValues, encodedProof);
const tx = await zeto
.connect(signer.signer)
.transfer(
nullifiers,
outputCommitments,
root,
encryptionNonce,
encryptedValues,
encodedProof,
"0x"
);
const results: ContractTransactionReceipt | null = await tx.wait();
console.log(`Time to execute transaction: ${Date.now() - startTx}ms. Gas used: ${results?.gasUsed}`);
return results;
Expand Down
3 changes: 2 additions & 1 deletion solidity/test/zeto_anon_enc_nullifier_kyc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -953,7 +953,8 @@ describe('Zeto based fungible token with anonymity using nullifiers and encrypti
root,
encryptionNonce,
encryptedValues,
encodedProof
encodedProof,
"0x"
);
const results: ContractTransactionReceipt | null = await tx.wait();
console.log(
Expand Down
13 changes: 12 additions & 1 deletion solidity/test/zeto_anon_enc_nullifier_non_repudiation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,18 @@ describe("Zeto based fungible token with anonymity using nullifiers and encrypti
const startTx = Date.now();
const encryptedValuesForReceiver = encryptedValues.slice(0, 4);
const encryptedValuesForRegulator = encryptedValues.slice(4, 20);
const tx = await zeto.connect(signer.signer).transfer(nullifiers, outputCommitments, root, encryptionNonce, encryptedValuesForReceiver, encryptedValuesForRegulator, encodedProof);
const tx = await zeto
.connect(signer.signer)
.transfer(
nullifiers,
outputCommitments,
root,
encryptionNonce,
encryptedValuesForReceiver,
encryptedValuesForRegulator,
encodedProof,
"0x"
);
const results: ContractTransactionReceipt | null = await tx.wait();
console.log(`Time to execute transaction: ${Date.now() - startTx}ms. Gas used: ${results?.gasUsed}`);
return results;
Expand Down

0 comments on commit e09ae65

Please sign in to comment.