Skip to content
Open
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
43 changes: 39 additions & 4 deletions host-contracts/contracts/ACL.sol
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,12 @@ contract ACL is
/// @notice Returned if the handlesList array is empty.
error HandlesListIsEmpty();

/// @notice Returned if the invalidation timestamp is not greater than the current one.
error InvalidationTimestampTooLow();

/// @notice Returned if the invalidation timestamp is in the future.
error InvalidationTimestampInTheFuture();

/**
* @notice Returned if the the delegate contract is not already delegate for sender & delegator addresses.
* @param delegator The address of the account that delegates access to its handles.
Expand Down Expand Up @@ -135,6 +141,7 @@ contract ACL is
mapping(address delegate => mapping(address contractAddress => UserDecryptionDelegation delegation)))
userDecryptionDelegations;
mapping(address account => bool isDenied) denyList;
mapping(address account => uint256 invalidatedBefore) decryptionSignatureInvalidatedBefore;
}

/// @notice Name of the contract.
Expand All @@ -144,7 +151,7 @@ contract ACL is
uint256 private constant MAJOR_VERSION = 0;

/// @notice Minor version of the contract.
uint256 private constant MINOR_VERSION = 3;
uint256 private constant MINOR_VERSION = 4;

/// @notice Patch version of the contract.
uint256 private constant PATCH_VERSION = 0;
Expand All @@ -157,7 +164,7 @@ contract ACL is

/// Constant used for making sure the version number used in the `reinitializer` modifier is
/// identical between `initializeFromEmptyProxy` and the `reinitializeVX` method
uint64 private constant REINITIALIZER_VERSION = 4;
uint64 private constant REINITIALIZER_VERSION = 5;

/// keccak256(abi.encode(uint256(keccak256("fhevm.storage.ACL")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant ACLStorageLocation = 0xa688f31953c2015baaf8c0a488ee1ee22eb0e05273cc1fd31ea4cbee42febc00;
Expand All @@ -177,11 +184,11 @@ contract ACL is
}

/**
* @notice Re-initializes the contract from V2.
* @notice Re-initializes the contract from V3.
*/
/// @custom:oz-upgrades-unsafe-allow missing-initializer-call
/// @custom:oz-upgrades-validate-as-initializer
function reinitializeV3() public virtual reinitializer(REINITIALIZER_VERSION) {}
function reinitializeV4() public virtual reinitializer(REINITIALIZER_VERSION) {}

/**
* @notice Allows the use of `handle` for the address `account`.
Expand Down Expand Up @@ -228,6 +235,24 @@ contract ACL is
emit AllowedForDecryption(msg.sender, handlesList);
}

/**
* @notice Invalidates decryption signatures before a given timestamp for the caller.
* @param timestamp Oldest timestamp that remains valid. Passing 0 resolves to the current block timestamp.
*/
function invalidateDecryptionSignaturesBefore(uint256 timestamp) external virtual whenNotPaused {
uint256 resolvedTimestamp = timestamp == 0 ? block.timestamp : timestamp;
ACLStorage storage $ = _getACLStorage();
if (resolvedTimestamp <= $.decryptionSignatureInvalidatedBefore[msg.sender]) {
revert InvalidationTimestampTooLow();
}
if (resolvedTimestamp > block.timestamp) {
revert InvalidationTimestampInTheFuture();
}

$.decryptionSignatureInvalidatedBefore[msg.sender] = resolvedTimestamp;
emit DecryptionSignaturesInvalidated(msg.sender, resolvedTimestamp);
}

/**
* @notice Allows the use of `handle` by address `account` for this transaction.
* @dev The caller must not be in the deny list and must be allowed to use `handle` for allowTransient() to succeed.
Expand Down Expand Up @@ -390,6 +415,16 @@ contract ACL is
return userDecryptionDelegation.expirationDate;
}

/**
* @notice Returns the timestamp before which the account's decryption signatures are invalidated.
* @param account The account whose invalidation timestamp is queried.
* @return invalidatedBefore The oldest timestamp that remains valid.
*/
function decryptionSignatureInvalidatedBefore(address account) public view virtual returns (uint256) {
ACLStorage storage $ = _getACLStorage();
return $.decryptionSignatureInvalidatedBefore[account];
}

/**
* @notice Checks whether the account is allowed to use the handle in the
* same transaction (transient).
Expand Down
5 changes: 5 additions & 0 deletions host-contracts/contracts/ACLEvents.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ contract ACLEvents {
/// @param handlesList List of handles allowed for decryption.
event AllowedForDecryption(address indexed caller, bytes32[] handlesList);

/// @notice Emitted when an account invalidates older decryption signatures.
/// @param account The account invalidating its signatures.
/// @param beforeTimestamp The oldest timestamp that remains valid.
event DecryptionSignaturesInvalidated(address indexed account, uint256 beforeTimestamp);

/// @notice Emitted when an account is delegated for user decryption.
/// @param delegator The address of the account that delegates access to its handles.
/// @param delegate The address of the account that receives the delegation.
Expand Down
14 changes: 13 additions & 1 deletion host-contracts/docs/contract_selectors.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ ACL
|----------+---------------------------------------------------------------------------+--------------------------------------------------------------------|
| Function | cleanTransientStorage() | 0x35334c23 |
|----------+---------------------------------------------------------------------------+--------------------------------------------------------------------|
| Function | decryptionSignatureInvalidatedBefore(address) | 0x0dff1525 |
|----------+---------------------------------------------------------------------------+--------------------------------------------------------------------|
| Function | delegateForUserDecryption(address,address,uint64) | 0x04f61a95 |
|----------+---------------------------------------------------------------------------+--------------------------------------------------------------------|
| Function | getFHEVMExecutorAddress() | 0x268d6d31 |
Expand All @@ -31,6 +33,8 @@ ACL
|----------+---------------------------------------------------------------------------+--------------------------------------------------------------------|
| Function | initializeFromEmptyProxy() | 0x39f73810 |
|----------+---------------------------------------------------------------------------+--------------------------------------------------------------------|
| Function | invalidateDecryptionSignaturesBefore(uint256) | 0x9718b695 |
|----------+---------------------------------------------------------------------------+--------------------------------------------------------------------|
| Function | isAccountDenied(address) | 0x9edc01ec |
|----------+---------------------------------------------------------------------------+--------------------------------------------------------------------|
| Function | isAllowed(bytes32,address) | 0x82027b6d |
Expand All @@ -55,7 +59,7 @@ ACL
|----------+---------------------------------------------------------------------------+--------------------------------------------------------------------|
| Function | proxiableUUID() | 0x52d1902d |
|----------+---------------------------------------------------------------------------+--------------------------------------------------------------------|
| Function | reinitializeV3() | 0xbac22bb8 |
| Function | reinitializeV4() | 0x123abb28 |
|----------+---------------------------------------------------------------------------+--------------------------------------------------------------------|
| Function | renounceOwnership() | 0x715018a6 |
|----------+---------------------------------------------------------------------------+--------------------------------------------------------------------|
Expand All @@ -75,6 +79,8 @@ ACL
|----------+---------------------------------------------------------------------------+--------------------------------------------------------------------|
| Event | BlockedAccount(address) | 0x8632489584ac3cfc9b78cc6c2197c31ca9e3821bfa5ca5c9af28917b92db24d9 |
|----------+---------------------------------------------------------------------------+--------------------------------------------------------------------|
| Event | DecryptionSignaturesInvalidated(address,uint256) | 0xf1b88c0a8124fa1aeb743677c229b610ff4d00ceb3df459794e540d7b9a52a3d |
|----------+---------------------------------------------------------------------------+--------------------------------------------------------------------|
| Event | DelegatedForUserDecryption(address,address,address,uint64,uint64,uint64) | 0x527b025d7ff06689c1ab9d32dfd7881c964cce72ce8ac5b2fe1d3be8cfda5bfc |
|----------+---------------------------------------------------------------------------+--------------------------------------------------------------------|
| Event | Initialized(uint64) | 0xc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d2 |
Expand Down Expand Up @@ -121,6 +127,10 @@ ACL
|----------+---------------------------------------------------------------------------+--------------------------------------------------------------------|
| Error | InvalidInitialization() | 0xf92ee8a9 |
|----------+---------------------------------------------------------------------------+--------------------------------------------------------------------|
| Error | InvalidationTimestampInTheFuture() | 0x9018203f |
|----------+---------------------------------------------------------------------------+--------------------------------------------------------------------|
| Error | InvalidationTimestampTooLow() | 0x832306ac |
|----------+---------------------------------------------------------------------------+--------------------------------------------------------------------|
| Error | NotDelegatedYet(address,address,address) | 0xc227e905 |
|----------+---------------------------------------------------------------------------+--------------------------------------------------------------------|
| Error | NotInitializing() | 0xd7e6bcf8 |
Expand Down Expand Up @@ -158,6 +168,8 @@ ACLEvents
|-------+---------------------------------------------------------------------------+--------------------------------------------------------------------|
| Event | BlockedAccount(address) | 0x8632489584ac3cfc9b78cc6c2197c31ca9e3821bfa5ca5c9af28917b92db24d9 |
|-------+---------------------------------------------------------------------------+--------------------------------------------------------------------|
| Event | DecryptionSignaturesInvalidated(address,uint256) | 0xf1b88c0a8124fa1aeb743677c229b610ff4d00ceb3df459794e540d7b9a52a3d |
|-------+---------------------------------------------------------------------------+--------------------------------------------------------------------|
| Event | DelegatedForUserDecryption(address,address,address,uint64,uint64,uint64) | 0x527b025d7ff06689c1ab9d32dfd7881c964cce72ce8ac5b2fe1d3be8cfda5bfc |
|-------+---------------------------------------------------------------------------+--------------------------------------------------------------------|
| Event | RevokedDelegationForUserDecryption(address,address,address,uint64,uint64) | 0x7aca80b6b7928b9038f186e3d9922a0fc5d52c398fbf144725c142c52a5277e4 |
Expand Down
2 changes: 1 addition & 1 deletion host-contracts/examples/ACLUpgradedExample.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ contract ACLUpgradedExample is ACL {

/// @notice Version of the contract
uint256 private constant MAJOR_VERSION = 0;
uint256 private constant MINOR_VERSION = 4;
uint256 private constant MINOR_VERSION = 5;
uint256 private constant PATCH_VERSION = 0;

/// @notice Getter for the name and version of the contract
Expand Down
2 changes: 1 addition & 1 deletion host-contracts/examples/ACLUpgradedExample2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ contract ACLUpgradedExample2 is ACL {

/// @notice Version of the contract
uint256 private constant MAJOR_VERSION = 0;
uint256 private constant MINOR_VERSION = 5;
uint256 private constant MINOR_VERSION = 6;
uint256 private constant PATCH_VERSION = 0;

/// @notice Getter for the name and version of the contract
Expand Down
Loading
Loading