Skip to content

Commit

Permalink
feat: pass a contract address to verifyCiphertext
Browse files Browse the repository at this point in the history
Will be needed in the future to verify the input ZKPoK.
  • Loading branch information
dartdart26 committed Jun 21, 2024
1 parent bfc1dab commit 16fbbec
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 11 deletions.
14 changes: 5 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,18 +116,14 @@ import "fhevm/lib/TFHE.sol";
contract Counter {
euint32 counter;
function add(bytes calldata encryptedValue) public {
euint32 value = TFHE.asEuint32(encryptedValue);
counter = counter + value;
}
function getCounter(bytes32 publicKey) returns (bytes memory) {
return TFHE.reencrypt(counter, publicKey);
function add(einput valueInput, bytes calldata inputProof) public {
euint32 value = TFHE.asEuint32(valueInput, inputProof);
counter = TFHE.add(counter, value);
}
}
```

_This example is explained in more detail in [here](https://github.com/zama-ai/fhevm/tree/main/examples)._
_More examples are available [here](https://github.com/zama-ai/fhevm/tree/main/examples)._

<p align="right">
<a href="#about" > ↑ Back to top </a>
Expand All @@ -149,7 +145,7 @@ _This example is explained in more detail in [here](https://github.com/zama-ai/f

#### Games:

- [Ciperbomb](https://github.com/immortal-tofu/cipherbomb): A Hardhat-based template for developing Solidity smart contracts, with sensible defaults. - by Clément Danjou
- [Cipherbomb](https://github.com/immortal-tofu/cipherbomb): A Hardhat-based template for developing Solidity smart contracts, with sensible defaults. - by Clément Danjou
- [Battleship](https://github.com/battleship-fhevm/battleship-hardhat): A smart contract that replicates the classic Battleship game on a blockchain in a transparent manner. - by [Owen Murovec](https://github.com/omurovec)

#### Others
Expand Down
4 changes: 2 additions & 2 deletions codegen/templates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ function generateImplCoprocessorInterface(operators: Operator[]): string {
function fheLibCustomInterfaceFunctions(): string {
return `
function fhePubKey(bytes1 fromLib) external view returns (bytes memory result);
function verifyCiphertext(bytes32 inputHandle, address callerAddress, bytes memory inputProof, bytes1 inputType) external pure returns (uint256 result);
function verifyCiphertext(bytes32 inputHandle, address callerAddress, address contractAddress, bytes memory inputProof, bytes1 inputType) external pure returns (uint256 result);
function cast(uint256 ct, bytes1 toType) external pure returns (uint256 result);
function trivialEncrypt(uint256 ct, bytes1 toType) external pure returns (uint256 result);
function fheIfThenElse(uint256 control, uint256 ifTrue, uint256 ifFalse) external pure returns (uint256 result);
Expand Down Expand Up @@ -289,7 +289,7 @@ function generateACLInterface(): string {
function tfheExecutorCustomFunctions(): string {
return `
function verifyCiphertext(bytes32 inputHandle, address callerAddress, bytes memory inputProof, bytes1 inputType) external returns (uint256 result) {
result = FhevmLib(address(EXT_TFHE_LIBRARY)).verifyCiphertext(inputHandle, callerAddress, inputProof, inputType);
result = FhevmLib(address(EXT_TFHE_LIBRARY)).verifyCiphertext(inputHandle, callerAddress, msg.sender, inputProof, inputType);
acl.allowTransient(result, msg.sender);
}
function cast(uint256 ct, bytes1 toType) external returns (uint256 result) {
Expand Down
1 change: 1 addition & 0 deletions lib/FhevmLib.sol
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ interface FhevmLib {
function verifyCiphertext(
bytes32 inputHandle,
address callerAddress,
address contractAddress,
bytes memory inputProof,
bytes1 inputType
) external pure returns (uint256 result);
Expand Down
1 change: 1 addition & 0 deletions lib/TFHEExecutor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ contract TFHEExecutor {
result = FhevmLib(address(EXT_TFHE_LIBRARY)).verifyCiphertext(
inputHandle,
callerAddress,
msg.sender,
inputProof,
inputType
);
Expand Down

0 comments on commit 16fbbec

Please sign in to comment.