-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #68 from zama-ai/updates-encrypted-erc20
refactor: updates EncryptedERC20 and other versions inheriting
- Loading branch information
Showing
11 changed files
with
571 additions
and
128 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
pnpm --no-install prettier:check | ||
pnpm --no-install lint:sol |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
// SPDX-License-Identifier: BSD-3-Clause-Clear | ||
pragma solidity ^0.8.24; | ||
|
||
import "fhevm/lib/TFHE.sol"; | ||
import { EncryptedErrors } from "../../utils/EncryptedErrors.sol"; | ||
import { MockZamaFHEVMConfig } from "fhevm/config/ZamaFHEVMConfig.sol"; | ||
|
||
contract TestEncryptedErrors is MockZamaFHEVMConfig, EncryptedErrors { | ||
constructor(uint8 totalNumberErrorCodes_) EncryptedErrors(totalNumberErrorCodes_) { | ||
for (uint8 i; i <= totalNumberErrorCodes_; i++) { | ||
/// @dev It is not possible to access the _errorCodeDefinitions since it is private. | ||
TFHE.allow(TFHE.asEuint8(i), msg.sender); | ||
} | ||
} | ||
|
||
function errorChangeIf( | ||
einput encryptedCondition, | ||
einput encryptedErrorCode, | ||
bytes calldata inputProof, | ||
uint8 indexCode | ||
) external returns (euint8 newErrorCode) { | ||
ebool condition = TFHE.asEbool(encryptedCondition, inputProof); | ||
euint8 errorCode = TFHE.asEuint8(encryptedErrorCode, inputProof); | ||
newErrorCode = _errorChangeIf(condition, indexCode, errorCode); | ||
_errorSave(newErrorCode); | ||
TFHE.allow(newErrorCode, msg.sender); | ||
} | ||
|
||
function errorChangeIfNot( | ||
einput encryptedCondition, | ||
einput encryptedErrorCode, | ||
bytes calldata inputProof, | ||
uint8 indexCode | ||
) external returns (euint8 newErrorCode) { | ||
ebool condition = TFHE.asEbool(encryptedCondition, inputProof); | ||
euint8 errorCode = TFHE.asEuint8(encryptedErrorCode, inputProof); | ||
newErrorCode = _errorChangeIfNot(condition, indexCode, errorCode); | ||
_errorSave(newErrorCode); | ||
TFHE.allow(newErrorCode, msg.sender); | ||
} | ||
|
||
function errorDefineIf( | ||
einput encryptedCondition, | ||
bytes calldata inputProof, | ||
uint8 indexCode | ||
) external returns (euint8 errorCode) { | ||
ebool condition = TFHE.asEbool(encryptedCondition, inputProof); | ||
errorCode = _errorDefineIf(condition, indexCode); | ||
_errorSave(errorCode); | ||
TFHE.allow(errorCode, msg.sender); | ||
} | ||
|
||
function errorDefineIfNot( | ||
einput encryptedCondition, | ||
bytes calldata inputProof, | ||
uint8 indexCode | ||
) external returns (euint8 errorCode) { | ||
ebool condition = TFHE.asEbool(encryptedCondition, inputProof); | ||
errorCode = _errorDefineIfNot(condition, indexCode); | ||
_errorSave(errorCode); | ||
TFHE.allow(errorCode, msg.sender); | ||
} | ||
|
||
function errorGetCodeDefinition(uint8 indexCodeDefinition) external view returns (euint8 errorCode) { | ||
errorCode = _errorGetCodeDefinition(indexCodeDefinition); | ||
} | ||
|
||
function errorGetCodeEmitted(uint256 errorId) external view returns (euint8 errorCode) { | ||
errorCode = _errorGetCodeEmitted(errorId); | ||
} | ||
|
||
function errorGetCounter() external view returns (uint256 countErrors) { | ||
countErrors = _errorGetCounter(); | ||
} | ||
|
||
function errorGetNumCodesDefined() external view returns (uint8 totalNumberErrorCodes) { | ||
totalNumberErrorCodes = _errorGetNumCodesDefined(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.