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 06070b0 commit 2d546ad
Show file tree
Hide file tree
Showing 9 changed files with 55 additions and 14 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
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -174,7 +176,8 @@ contract Zeto_AnonEncNullifierNonRepudiation is
encryptionNonce,
encryptedValuesReceiverArray,
encryptedValuesAuthorityArray,
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 2d546ad

Please sign in to comment.