Skip to content

Commit

Permalink
chore: applied reviews
Browse files Browse the repository at this point in the history
  • Loading branch information
jatZama committed Dec 23, 2024
1 parent 6d59ffa commit 9cda628
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
13 changes: 12 additions & 1 deletion contracts/codegen/templates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export function implSol(operators: Operator[]): string {

const coprocessorInterface = generateImplCoprocessorInterface(operators);
const aclInterface = generateACLInterface();
const inputVerifierInterface = generateInputVerifierInterface();

res.push(`
// SPDX-License-Identifier: BSD-3-Clause-Clear
Expand All @@ -79,6 +80,8 @@ ${coprocessorInterface}
${aclInterface}
${inputVerifierInterface}
library Impl {
// keccak256(abi.encode(uint256(keccak256("fhevm.storage.FHEVMConfig")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant FHEVMConfigLocation = 0xed8d60e34876f751cc8b014c560745351147d9de11b9347c854e881b128ea600;
Expand Down Expand Up @@ -215,6 +218,14 @@ function generateACLInterface(): string {
`;
}

function generateInputVerifierInterface(): string {
return `
interface IInputVerifier {
function cleanTransientStorage() external;
}
`;
}

export function tfheSol(
operators: Operator[],
supportedBits: number[],
Expand Down Expand Up @@ -1464,7 +1475,7 @@ function implCustomMethods(): string {
function cleanTransientStorageInputVerifier() internal {
FHEVMConfig.FHEVMConfigStruct storage $ = getFHEVMConfig();
IACL($.InputVerifierAddress).cleanTransientStorage();
IInputVerifier($.InputVerifierAddress).cleanTransientStorage();
}
function isAllowed(uint256 handle, address account) internal view returns (bool) {
Expand Down
1 change: 0 additions & 1 deletion contracts/examples/PaymentLimit.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
pragma solidity ^0.8.24;

import "../lib/TFHE.sol";
import "@openzeppelin/contracts/access/Ownable2Step.sol";

/// @title PaymentLimit
/// @notice A contract to demonstrate FHE gas limits in different scenarios
Expand Down
6 changes: 5 additions & 1 deletion contracts/lib/Impl.sol
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ interface IACL {
function allowForDecryption(uint256[] memory handlesList) external;
}

interface IInputVerifier {
function cleanTransientStorage() external;
}

library Impl {
// keccak256(abi.encode(uint256(keccak256("fhevm.storage.FHEVMConfig")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant FHEVMConfigLocation = 0xed8d60e34876f751cc8b014c560745351147d9de11b9347c854e881b128ea600;
Expand Down Expand Up @@ -372,7 +376,7 @@ library Impl {

function cleanTransientStorageInputVerifier() internal {
FHEVMConfig.FHEVMConfigStruct storage $ = getFHEVMConfig();
IACL($.InputVerifierAddress).cleanTransientStorage();
IInputVerifier($.InputVerifierAddress).cleanTransientStorage();
}

function isAllowed(uint256 handle, address account) internal view returns (bool) {
Expand Down

0 comments on commit 9cda628

Please sign in to comment.