Skip to content
Merged
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
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

## [Unreleased]

### Changed
- Rename `FHE.asEbool(bytes32)`, `FHE.asEuint*(bytes32)`, `FHE.asEaddress(bytes32)` to `FHE.wrapEbool(bytes32)`, `FHE.wrapEuint*(bytes32)`, `FHE.wrapEaddress(bytes32)` to avoid overload ambiguity with `asEuintX(0)` calls and clarify intent

### Fixed
- CI now compiles against local `cofhe-contracts` source instead of stale npm version, closing a gap where FHE.sol compilation errors were not caught
- Update internal test contracts to match current FHE.sol API (remove `euint256`, `FHE.decrypt`, fix `bytes32` return types)

## v0.1.2 - 2025-03-16

### Added
Expand Down
14 changes: 7 additions & 7 deletions contracts/FHE.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3786,49 +3786,49 @@ library FHE {
/// @notice Wraps a bytes32 handle into an encrypted boolean type
/// @param handle the bytes32 ciphertext handle to wrap
/// @return an ebool representing the encrypted value
function asEbool(bytes32 handle) internal pure returns (ebool) {
function wrapEbool(bytes32 handle) internal pure returns (ebool) {
return ebool.wrap(handle);
}

/// @notice Wraps a bytes32 handle into an encrypted uint8 type
/// @param handle the bytes32 ciphertext handle to wrap
/// @return an euint8 representing the encrypted value
function asEuint8(bytes32 handle) internal pure returns (euint8) {
function wrapEuint8(bytes32 handle) internal pure returns (euint8) {
return euint8.wrap(handle);
}

/// @notice Wraps a bytes32 handle into an encrypted uint16 type
/// @param handle the bytes32 ciphertext handle to wrap
/// @return an euint16 representing the encrypted value
function asEuint16(bytes32 handle) internal pure returns (euint16) {
function wrapEuint16(bytes32 handle) internal pure returns (euint16) {
return euint16.wrap(handle);
}

/// @notice Wraps a bytes32 handle into an encrypted uint32 type
/// @param handle the bytes32 ciphertext handle to wrap
/// @return an euint32 representing the encrypted value
function asEuint32(bytes32 handle) internal pure returns (euint32) {
function wrapEuint32(bytes32 handle) internal pure returns (euint32) {
return euint32.wrap(handle);
}

/// @notice Wraps a bytes32 handle into an encrypted uint64 type
/// @param handle the bytes32 ciphertext handle to wrap
/// @return an euint64 representing the encrypted value
function asEuint64(bytes32 handle) internal pure returns (euint64) {
function wrapEuint64(bytes32 handle) internal pure returns (euint64) {
return euint64.wrap(handle);
}

/// @notice Wraps a bytes32 handle into an encrypted uint128 type
/// @param handle the bytes32 ciphertext handle to wrap
/// @return an euint128 representing the encrypted value
function asEuint128(bytes32 handle) internal pure returns (euint128) {
function wrapEuint128(bytes32 handle) internal pure returns (euint128) {
return euint128.wrap(handle);
}

/// @notice Wraps a bytes32 handle into an encrypted address type
/// @param handle the bytes32 ciphertext handle to wrap
/// @return an eaddress representing the encrypted value
function asEaddress(bytes32 handle) internal pure returns (eaddress) {
function wrapEaddress(bytes32 handle) internal pure returns (eaddress) {
return eaddress.wrap(handle);
}
}
Expand Down
12 changes: 6 additions & 6 deletions contracts/internal/host-chain/contracts/tests/OnChain.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ contract OnChain {
FHE.eq(ea, eb);
FHE.ne(ea, eb);
FHE.select(ebool.wrap(0), eb, ea);
FHE.decrypt(ea);


ctHashBool = ea;
return ctHashBool;
Expand Down Expand Up @@ -53,7 +53,7 @@ contract OnChain {
FHE.max(ea, eb);
FHE.not(ea);
FHE.select(ebool.wrap(0), eb, ea);
FHE.decrypt(ea);


ctHash8 = ea;
return ctHash8;
Expand Down Expand Up @@ -86,7 +86,7 @@ contract OnChain {
FHE.max(ea, eb);
FHE.not(ea);
FHE.select(ebool.wrap(0), eb, ea);
FHE.decrypt(ea);


ctHash16 = ea;
return ctHash16;
Expand Down Expand Up @@ -119,7 +119,7 @@ contract OnChain {
FHE.max(ea, eb);
FHE.not(ea);
FHE.select(ebool.wrap(0), eb, ea);
FHE.decrypt(ea);

ctHash32 = ea;
return ctHash32;
}
Expand Down Expand Up @@ -148,15 +148,15 @@ contract OnChain {
return FHE.asEuint32(1000000000000); // Value taken from a real world example
}

function cantEncryptWithFakeUintType() public returns (uint256) {
function cantEncryptWithFakeUintType() public returns (bytes32) {
return Impl.trivialEncrypt(15, 100, 0);
}

function cantEncryptWithFakeSecurityZone() public returns (euint32) {
return FHE.asEuint32(16, 200); // 200 is outside valid range (-128 to 127)
}

function cantCastWithFakeType() public returns (uint256) {
function cantCastWithFakeType() public returns (bytes32) {
euint32 v = FHE.asEuint32(16);
return Impl.cast(euint32.unwrap(v), 150);
}
Expand Down
43 changes: 2 additions & 41 deletions contracts/internal/host-chain/contracts/tests/OnChain2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import "@fhenixprotocol/cofhe-contracts/FHE.sol";
contract OnChain2 {
euint64 public ctHash64;
euint128 public ctHash128;
euint256 public ctHash256;
eaddress public ctHashAddress;

function trivial64(uint64 a, uint64 b) public returns (euint64) {
Expand Down Expand Up @@ -37,7 +36,7 @@ contract OnChain2 {
FHE.max(ea, eb);
FHE.not(ea);
FHE.select(ebool.wrap(0), eb, ea);
FHE.decrypt(ea);


ctHash64 = ea;
return ctHash64;
Expand Down Expand Up @@ -70,45 +69,12 @@ contract OnChain2 {
FHE.max(ea, eb);
FHE.not(ea);
FHE.select(ebool.wrap(0), eb, ea);
FHE.decrypt(ea);


ctHash128 = ea;
return ctHash128;
}

function trivial256(uint256 a, uint256 b) public returns (euint256) {
euint256 ea = FHE.asEuint256(a);
euint256 eb = FHE.asEuint256(b);

FHE.add(ea, eb);
FHE.sub(ea, eb);
FHE.mul(ea, eb);
FHE.and(ea, eb);
FHE.or(ea, eb);
FHE.xor(ea, eb);
FHE.div(ea, eb);
FHE.rem(ea, eb);
FHE.square(ea);
FHE.shl(ea, eb);
FHE.shr(ea, eb);
FHE.ror(ea, eb);
FHE.rol(ea, eb);
FHE.eq(ea, eb);
FHE.ne(ea, eb);
FHE.gte(ea, eb);
FHE.gt(ea, eb);
FHE.lte(ea, eb);
FHE.lt(ea, eb);
FHE.min(ea, eb);
FHE.max(ea, eb);
FHE.not(ea);
FHE.select(ebool.wrap(0), eb, ea);
FHE.decrypt(ea);

ctHash256 = ea;
return ctHash256;
}

function trivialAddress(address a, address b) public returns (eaddress) {
eaddress ea = FHE.asEaddress(a);
eaddress eb = FHE.asEaddress(b);
Expand All @@ -129,11 +95,6 @@ contract OnChain2 {
return ctHash128;
}

function notAllowedPersistently256() public returns (euint256) {
ctHash256 = FHE.xor(ctHash256, ctHash256);
return ctHash256;
}

function notAllowedPersistentlyAddress() public returns (ebool) {
ebool ctHashBool = FHE.eq(ctHashAddress, ctHashAddress);
return ctHashBool;
Expand Down
2 changes: 1 addition & 1 deletion contracts/internal/host-chain/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"author": "Fhenix",
"license": "MIT",
"devDependencies": {
"@fhenixprotocol/cofhe-contracts": "0.0.13",
"@fhenixprotocol/cofhe-contracts": "file:../../",
"@fhenixprotocol/contracts": "0.2.1",
"@nomicfoundation/hardhat-chai-matchers": "^2.1.0",
"@nomicfoundation/hardhat-ethers": "^3.1.3",
Expand Down
10 changes: 5 additions & 5 deletions contracts/internal/host-chain/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading