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
70 changes: 70 additions & 0 deletions contracts/FHE.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3320,6 +3320,55 @@ library FHE {
ITaskManager(TASK_MANAGER_ADDRESS).allowTransient(uint256(eaddress.unwrap(ctHash)), account);
}

/// @notice Marks the encrypted boolean value as allowed for decryption
/// @dev Signals the decrypt network that this ciphertext may be decrypted; the caller must already be allowed to use the handle
/// @param ctHash The encrypted boolean value to allow decryption for
function allowForDecryption(ebool ctHash) internal {
ITaskManager(TASK_MANAGER_ADDRESS).allowForDecryption(uint256(ebool.unwrap(ctHash)));
}

/// @notice Marks the encrypted 8-bit unsigned integer as allowed for decryption
/// @dev Signals the decrypt network that this ciphertext may be decrypted; the caller must already be allowed to use the handle
/// @param ctHash The encrypted uint8 value to allow decryption for
function allowForDecryption(euint8 ctHash) internal {
ITaskManager(TASK_MANAGER_ADDRESS).allowForDecryption(uint256(euint8.unwrap(ctHash)));
}

/// @notice Marks the encrypted 16-bit unsigned integer as allowed for decryption
/// @dev Signals the decrypt network that this ciphertext may be decrypted; the caller must already be allowed to use the handle
/// @param ctHash The encrypted uint16 value to allow decryption for
function allowForDecryption(euint16 ctHash) internal {
ITaskManager(TASK_MANAGER_ADDRESS).allowForDecryption(uint256(euint16.unwrap(ctHash)));
}

/// @notice Marks the encrypted 32-bit unsigned integer as allowed for decryption
/// @dev Signals the decrypt network that this ciphertext may be decrypted; the caller must already be allowed to use the handle
/// @param ctHash The encrypted uint32 value to allow decryption for
function allowForDecryption(euint32 ctHash) internal {
ITaskManager(TASK_MANAGER_ADDRESS).allowForDecryption(uint256(euint32.unwrap(ctHash)));
}

/// @notice Marks the encrypted 64-bit unsigned integer as allowed for decryption
/// @dev Signals the decrypt network that this ciphertext may be decrypted; the caller must already be allowed to use the handle
/// @param ctHash The encrypted uint64 value to allow decryption for
function allowForDecryption(euint64 ctHash) internal {
ITaskManager(TASK_MANAGER_ADDRESS).allowForDecryption(uint256(euint64.unwrap(ctHash)));
}

/// @notice Marks the encrypted 128-bit unsigned integer as allowed for decryption
/// @dev Signals the decrypt network that this ciphertext may be decrypted; the caller must already be allowed to use the handle
/// @param ctHash The encrypted uint128 value to allow decryption for
function allowForDecryption(euint128 ctHash) internal {
ITaskManager(TASK_MANAGER_ADDRESS).allowForDecryption(uint256(euint128.unwrap(ctHash)));
}

/// @notice Marks the encrypted address as allowed for decryption
/// @dev Signals the decrypt network that this ciphertext may be decrypted; the caller must already be allowed to use the handle
/// @param ctHash The encrypted address value to allow decryption for
function allowForDecryption(eaddress ctHash) internal {
ITaskManager(TASK_MANAGER_ADDRESS).allowForDecryption(uint256(eaddress.unwrap(ctHash)));
}

// ********** PUBLISH DECRYPT RESULT ************* //

/// @notice Publish a signed decrypt result to the chain
Expand Down Expand Up @@ -3937,6 +3986,9 @@ library BindingsEbool {
function allowTransient(ebool ctHash, address account) internal {
FHE.allowTransient(ctHash, account);
}
function allowForDecryption(ebool ctHash) internal {
FHE.allowForDecryption(ctHash);
}
/// @notice Returns true if the encrypted boolean is initialized and false otherwise
/// @param value the encrypted boolean value to check
/// @return true if initialized, false otherwise
Expand Down Expand Up @@ -4188,6 +4240,9 @@ library BindingsEuint8 {
function allowTransient(euint8 ctHash, address account) internal {
FHE.allowTransient(ctHash, account);
}
function allowForDecryption(euint8 ctHash) internal {
FHE.allowForDecryption(ctHash);
}
/// @notice Returns true if the encrypted uint8 is initialized and false otherwise
/// @param value the encrypted uint8 value to check
/// @return true if initialized, false otherwise
Expand Down Expand Up @@ -4439,6 +4494,9 @@ library BindingsEuint16 {
function allowTransient(euint16 ctHash, address account) internal {
FHE.allowTransient(ctHash, account);
}
function allowForDecryption(euint16 ctHash) internal {
FHE.allowForDecryption(ctHash);
}
/// @notice Returns true if the encrypted uint16 is initialized and false otherwise
/// @param value the encrypted uint16 value to check
/// @return true if initialized, false otherwise
Expand Down Expand Up @@ -4690,6 +4748,9 @@ library BindingsEuint32 {
function allowTransient(euint32 ctHash, address account) internal {
FHE.allowTransient(ctHash, account);
}
function allowForDecryption(euint32 ctHash) internal {
FHE.allowForDecryption(ctHash);
}
/// @notice Returns true if the encrypted uint32 is initialized and false otherwise
/// @param value the encrypted uint32 value to check
/// @return true if initialized, false otherwise
Expand Down Expand Up @@ -4941,6 +5002,9 @@ library BindingsEuint64 {
function allowTransient(euint64 ctHash, address account) internal {
FHE.allowTransient(ctHash, account);
}
function allowForDecryption(euint64 ctHash) internal {
FHE.allowForDecryption(ctHash);
}
/// @notice Returns true if the encrypted uint64 is initialized and false otherwise
/// @param value the encrypted uint64 value to check
/// @return true if initialized, false otherwise
Expand Down Expand Up @@ -5192,6 +5256,9 @@ library BindingsEuint128 {
function allowTransient(euint128 ctHash, address account) internal {
FHE.allowTransient(ctHash, account);
}
function allowForDecryption(euint128 ctHash) internal {
FHE.allowForDecryption(ctHash);
}
/// @notice Returns true if the encrypted uint128 is initialized and false otherwise
/// @param value the encrypted uint128 value to check
/// @return true if initialized, false otherwise
Expand Down Expand Up @@ -5268,6 +5335,9 @@ library BindingsEaddress {
function allowTransient(eaddress ctHash, address account) internal {
FHE.allowTransient(ctHash, account);
}
function allowForDecryption(eaddress ctHash) internal {
FHE.allowForDecryption(ctHash);
}
/// @notice Returns true if the encrypted address is initialized and false otherwise
/// @param value the encrypted address value to check
/// @return true if initialized, false otherwise
Expand Down
1 change: 1 addition & 0 deletions contracts/ICofhe.sol
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ interface ITaskManager {
function isPubliclyAllowed(uint256 ctHash) external view returns (bool);
function allowGlobal(uint256 ctHash) external;
function allowTransient(uint256 ctHash, address account) external;
function allowForDecryption(uint256 ctHash) external;
function getDecryptResultSafe(uint256 ctHash) external view returns (uint256, bool);
function getDecryptResult(uint256 ctHash) external view returns (uint256);

Expand Down
Loading