Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .github/workflows/test-suite-e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,11 @@ jobs:
run: |
./fhevm-cli test user-decryption

- name: Delegated User Decryption test
working-directory: test-suite/fhevm
run: |
./fhevm-cli test delegated-user-decryption

- name: ERC20 test
working-directory: test-suite/fhevm
run: |
Expand All @@ -205,11 +210,6 @@ jobs:
run: |
./fhevm-cli test public-decrypt-http-mixed

- name: Delegate User Decryption (partial test)
working-directory: test-suite/fhevm
run: |
./fhevm-cli test delegate-user-decryption

- name: Random operators test (subset)
working-directory: test-suite/fhevm
run: |
Expand Down
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 0 additions & 11 deletions test-suite/e2e/contracts/DelegateUserDecryptDelegate.sol

This file was deleted.

28 changes: 0 additions & 28 deletions test-suite/e2e/contracts/DelegateUserDecryptDelegator.sol

This file was deleted.

73 changes: 73 additions & 0 deletions test-suite/e2e/contracts/SmartWalletWithDelegation.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
// SPDX-License-Identifier: BSD-3-Clause-Clear
pragma solidity ^0.8.24;

import "@fhevm/solidity/lib/FHE.sol";
import {E2ECoprocessorConfig} from "./E2ECoprocessorConfigLocal.sol";

/// @notice SmartWallet contract that supports delegated user decryption.
contract SmartWalletWithDelegation is E2ECoprocessorConfig {
struct Transaction {
address target;
bytes data;
}

event ProposedTx(uint256 indexed txId, address target, bytes data);

uint256 public txCounter;
address public owner;
mapping(uint256 => Transaction) public transactions;
mapping(uint256 => bool) public executed;

constructor(address _owner) {
require(_owner != address(0), "Owner cannot be zero address");
owner = _owner;
}

modifier onlyOwner() {
require(msg.sender == owner, "Sender is not the owner");
_;
}

/// @notice Propose a transaction and assume as approved (since there's only one owner).
/// @param target The target contract address
/// @param data The calldata to execute
function proposeTx(address target, bytes calldata data) external onlyOwner returns (uint256) {
txCounter++;
uint256 txId = txCounter;
transactions[txCounter] = Transaction({target: target, data: data});
emit ProposedTx(txId, target, data);
return txId;
}

/// @notice Execute a previously proposed transaction.
/// @param txId The transaction ID to execute.
function executeTx(uint256 txId) external onlyOwner {
require(txId != 0 && txId <= txCounter, "Invalid txId");
require(!executed[txId], "tx has already been executed");
Transaction memory transaction = transactions[txId];

(bool success, ) = (transaction.target).call(transaction.data);
require(success, "tx reverted");
executed[txId] = true;
}

/// @notice Delegate user decryption for a specific contract.
/// @dev This allows an EOA to decrypt confidential data owned by this smart wallet.
/// @param delegate The address that will be able to user decrypt.
/// @param delegateContractAddress The contract address for which delegation applies.
/// @param expirationTimestamp When the delegation expires.
function delegateUserDecryption(
address delegate,
address delegateContractAddress,
uint64 expirationTimestamp
) external onlyOwner {
FHE.delegateUserDecryption(delegate, delegateContractAddress, expirationTimestamp);
}

/// @notice Revoke a previously granted delegation.
/// @param delegate The address to revoke delegation from.
/// @param delegateContractAddress The contract address for which to revoke delegation.
function revokeUserDecryptionDelegation(address delegate, address delegateContractAddress) external onlyOwner {
FHE.revokeUserDecryptionDelegation(delegate, delegateContractAddress);
}
}
4 changes: 2 additions & 2 deletions test-suite/e2e/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
"dependencies": {
"@fhevm/solidity": "*",
"@openzeppelin/contracts": "^5.3.0",
"@zama-fhe/relayer-sdk": "0.4.0-4",
"@zama-fhe/relayer-sdk": "^0.4.0-5",
"bigint-buffer": "^1.1.5",
"dotenv": "^16.0.3",
"encrypted-types": "^0.0.4"
}
}
}

This file was deleted.

Loading