-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Expand file tree
/
Copy pathCiphertextCommits.sol
More file actions
41 lines (34 loc) · 1.27 KB
/
CiphertextCommits.sol
File metadata and controls
41 lines (34 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// SPDX-License-Identifier: BSD-3-Clause-Clear
pragma solidity ^0.8.24;
/// @dev This contract is a mock of the CiphertextCommits contract from the Gateway.
/// source: github.com/zama-ai/fhevm-gateway/blob/main/contracts/CiphertextCommits.sol
contract CiphertextCommits {
error CoprocessorAlreadyAdded(bytes32 ctHandle, address coprocessorTxSenderAddress);
error NotCoprocessorTxSender(address txSenderAddress);
bool alreadyAddedRevert;
ConfigErrorMode configErrorMode;
enum ConfigErrorMode {
None,
NotCoprocessorTxSender
}
constructor(bool _alreadyAddedRevert) {
alreadyAddedRevert = _alreadyAddedRevert;
}
function setConfigErrorMode(uint8 mode) external {
require(mode <= uint8(ConfigErrorMode.NotCoprocessorTxSender), "invalid mode");
configErrorMode = ConfigErrorMode(mode);
}
function addCiphertextMaterial(
bytes32 ctHandle,
uint256 /* keyId */,
bytes32 ciphertextDigest,
bytes32 snsCiphertextDigest
) public {
if (configErrorMode == ConfigErrorMode.NotCoprocessorTxSender) {
revert NotCoprocessorTxSender(msg.sender);
}
if (alreadyAddedRevert) {
revert CoprocessorAlreadyAdded(ctHandle, msg.sender);
}
}
}