From 2d546adf623a692adc09d41c28fd5c2a71098670 Mon Sep 17 00:00:00 2001 From: Andrew Richardson Date: Fri, 20 Sep 2024 14:50:47 -0400 Subject: [PATCH] Add "data" parameter to encrypted transfer methods/events Signed-off-by: Andrew Richardson --- .../contracts/lib/interfaces/izeto_encrypted.sol | 3 ++- solidity/contracts/zeto_anon_enc.sol | 6 ++++-- solidity/contracts/zeto_anon_enc_nullifier.sol | 6 ++++-- solidity/contracts/zeto_anon_enc_nullifier_kyc.sol | 6 ++++-- .../zeto_anon_enc_nullifier_non_repudiation.sol | 9 ++++++--- solidity/test/zeto_anon_enc.ts | 11 ++++++++++- solidity/test/zeto_anon_enc_nullifier.ts | 12 +++++++++++- solidity/test/zeto_anon_enc_nullifier_kyc.ts | 3 ++- .../test/zeto_anon_enc_nullifier_non_repudiation.ts | 13 ++++++++++++- 9 files changed, 55 insertions(+), 14 deletions(-) diff --git a/solidity/contracts/lib/interfaces/izeto_encrypted.sol b/solidity/contracts/lib/interfaces/izeto_encrypted.sol index c39a5ec..798e740 100644 --- a/solidity/contracts/lib/interfaces/izeto_encrypted.sol +++ b/solidity/contracts/lib/interfaces/izeto_encrypted.sol @@ -23,6 +23,7 @@ interface IZetoEncrypted is IZetoBase { uint256[] outputs, uint256 encryptionNonce, uint256[] encryptedValues, - address indexed submitter + address indexed submitter, + bytes data ); } diff --git a/solidity/contracts/zeto_anon_enc.sol b/solidity/contracts/zeto_anon_enc.sol index f6a5506..fc6ae8d 100644 --- a/solidity/contracts/zeto_anon_enc.sol +++ b/solidity/contracts/zeto_anon_enc.sol @@ -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), @@ -112,7 +113,8 @@ contract Zeto_AnonEnc is IZetoEncrypted, ZetoBase, ZetoFungibleWithdraw, UUPSUpg outputArray, encryptionNonce, encryptedValuesArray, - msg.sender + msg.sender, + data ); return true; } diff --git a/solidity/contracts/zeto_anon_enc_nullifier.sol b/solidity/contracts/zeto_anon_enc_nullifier.sol index 9b143ce..d262f08 100644 --- a/solidity/contracts/zeto_anon_enc_nullifier.sol +++ b/solidity/contracts/zeto_anon_enc_nullifier.sol @@ -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), @@ -127,7 +128,8 @@ contract Zeto_AnonEncNullifier is outputArray, encryptionNonce, encryptedValuesArray, - msg.sender + msg.sender, + data ); return true; } diff --git a/solidity/contracts/zeto_anon_enc_nullifier_kyc.sol b/solidity/contracts/zeto_anon_enc_nullifier_kyc.sol index c85ed40..05bdb0c 100644 --- a/solidity/contracts/zeto_anon_enc_nullifier_kyc.sol +++ b/solidity/contracts/zeto_anon_enc_nullifier_kyc.sol @@ -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), @@ -133,7 +134,8 @@ contract Zeto_AnonEncNullifierKyc is outputArray, encryptionNonce, encryptedValuesArray, - msg.sender + msg.sender, + data ); return true; } diff --git a/solidity/contracts/zeto_anon_enc_nullifier_non_repudiation.sol b/solidity/contracts/zeto_anon_enc_nullifier_non_repudiation.sol index cc49c1a..991b9ab 100644 --- a/solidity/contracts/zeto_anon_enc_nullifier_non_repudiation.sol +++ b/solidity/contracts/zeto_anon_enc_nullifier_non_repudiation.sol @@ -44,7 +44,8 @@ contract Zeto_AnonEncNullifierNonRepudiation is uint256 encryptionNonce, uint256[] encryptedValuesForReceiver, uint256[] encryptedValuesForAuthority, - address indexed submitter + address indexed submitter, + bytes data ); Groth16Verifier_AnonEncNullifierNonRepudiation verifier; @@ -100,7 +101,8 @@ contract Zeto_AnonEncNullifierNonRepudiation is uint256 encryptionNonce, uint256[4] memory encryptedValuesForReceiver, uint256[16] memory encryptedValuesForAuthority, - Commonlib.Proof calldata proof + Commonlib.Proof calldata proof, + bytes calldata data ) public returns (bool) { require( validateTransactionProposal(nullifiers, outputs, root), @@ -174,7 +176,8 @@ contract Zeto_AnonEncNullifierNonRepudiation is encryptionNonce, encryptedValuesReceiverArray, encryptedValuesAuthorityArray, - msg.sender + msg.sender, + data ); return true; } diff --git a/solidity/test/zeto_anon_enc.ts b/solidity/test/zeto_anon_enc.ts index 11236fd..b2e6e1f 100644 --- a/solidity/test/zeto_anon_enc.ts +++ b/solidity/test/zeto_anon_enc.ts @@ -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) { diff --git a/solidity/test/zeto_anon_enc_nullifier.ts b/solidity/test/zeto_anon_enc_nullifier.ts index 6903498..de80627 100644 --- a/solidity/test/zeto_anon_enc_nullifier.ts +++ b/solidity/test/zeto_anon_enc_nullifier.ts @@ -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; diff --git a/solidity/test/zeto_anon_enc_nullifier_kyc.ts b/solidity/test/zeto_anon_enc_nullifier_kyc.ts index 4791e23..509de0a 100644 --- a/solidity/test/zeto_anon_enc_nullifier_kyc.ts +++ b/solidity/test/zeto_anon_enc_nullifier_kyc.ts @@ -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( diff --git a/solidity/test/zeto_anon_enc_nullifier_non_repudiation.ts b/solidity/test/zeto_anon_enc_nullifier_non_repudiation.ts index c9a7fc7..4cceead 100644 --- a/solidity/test/zeto_anon_enc_nullifier_non_repudiation.ts +++ b/solidity/test/zeto_anon_enc_nullifier_non_repudiation.ts @@ -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;