mirror of
https://github.com/luxfi/fhe.git
synced 2026-07-26 23:16:08 +00:00
refactor: clean @luxfhe/contracts wrapper paths
- Restructured to fhe/ at root (no double contracts/) - Import: @luxfhe/contracts/fhe/FHE.sol - Depends on @luxfi/contracts@^1.3.4 - Published @luxfhe/contracts@1.1.0
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
# @luxfhe/contracts
|
||||
|
||||
**Thin wrapper package** - Re-exports FHE (Fully Homomorphic Encryption) contracts from `@luxfi/contracts`.
|
||||
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
npm install @luxfhe/contracts
|
||||
# or
|
||||
pnpm add @luxfhe/contracts
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```solidity
|
||||
// Option 1: Import from @luxfhe/contracts (this package)
|
||||
import "@luxfhe/contracts/fhe/FHE.sol";
|
||||
|
||||
// Option 2: Import directly from @luxfi/contracts (canonical source)
|
||||
import "@luxfi/contracts/fhe/FHE.sol";
|
||||
```
|
||||
|
||||
Both paths resolve to the same contracts.
|
||||
|
||||
## What's Included
|
||||
|
||||
This package re-exports:
|
||||
|
||||
- `FHE.sol` - Core FHE library with encrypted types and operations
|
||||
- `IFHE.sol` - Interfaces and struct definitions
|
||||
|
||||
For the full FHE library including access control, tokens, and governance:
|
||||
|
||||
```solidity
|
||||
// Access control
|
||||
import "@luxfi/contracts/fhe/access/Permissioned.sol";
|
||||
|
||||
// Confidential tokens
|
||||
import "@luxfi/contracts/fhe/token/ConfidentialERC20.sol";
|
||||
|
||||
// Governance
|
||||
import "@luxfi/contracts/fhe/governance/ConfidentialGovernorAlpha.sol";
|
||||
```
|
||||
|
||||
## Canonical Source
|
||||
|
||||
All FHE contracts are maintained in `@luxfi/contracts`:
|
||||
- GitHub: https://github.com/luxfi/standard
|
||||
- npm: https://www.npmjs.com/package/@luxfi/contracts
|
||||
|
||||
This package (`@luxfhe/contracts`) exists for convenience and backwards compatibility.
|
||||
|
||||
## Version History
|
||||
|
||||
- **v1.1.0** - Clean import paths (`@luxfhe/contracts/fhe/FHE.sol`)
|
||||
- **v1.0.0** - Initial release
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
||||
@@ -0,0 +1,6 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
pragma solidity >=0.8.19 <0.9.0;
|
||||
|
||||
// Re-export all FHE types and library from @luxfi/contracts
|
||||
// Clean path: @luxfi/contracts/fhe/FHE.sol (no double "contracts")
|
||||
import "@luxfi/contracts/fhe/FHE.sol";
|
||||
@@ -0,0 +1,96 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
pragma solidity >=0.8.19 <0.9.0;
|
||||
|
||||
// Extension library for FHE operations with InEuint* typed inputs
|
||||
// These provide convenience overloads for the typed input structs
|
||||
|
||||
import "@luxfi/contracts/fhe/FHE.sol";
|
||||
import {InEbool, InEuint8, InEuint16, InEuint32, InEuint64, InEuint128, InEuint256, InEaddress} from "./InTypes.sol";
|
||||
import {Ebool, Euint8, Euint16, Euint32, Euint64, Euint128, Euint256, Eaddress, EncryptedInput, Utils} from "@luxfi/contracts/fhe/IFHE.sol";
|
||||
import {FHENetwork} from "@luxfi/contracts/fhe/FHENetwork.sol";
|
||||
|
||||
/// @title FHEIn
|
||||
/// @notice Extension library providing asEuint* functions for typed input structs
|
||||
library FHEIn {
|
||||
// ===== Convert InEuint* structs to euint* types =====
|
||||
|
||||
function asEbool(InEbool memory value) internal returns (ebool) {
|
||||
EncryptedInput memory input = EncryptedInput({
|
||||
ctHash: value.ctHash,
|
||||
securityZone: value.securityZone,
|
||||
utype: value.utype,
|
||||
signature: value.signature
|
||||
});
|
||||
return ebool.wrap(FHENetwork.verifyInput(input));
|
||||
}
|
||||
|
||||
function asEuint8(InEuint8 memory value) internal returns (euint8) {
|
||||
EncryptedInput memory input = EncryptedInput({
|
||||
ctHash: value.ctHash,
|
||||
securityZone: value.securityZone,
|
||||
utype: value.utype,
|
||||
signature: value.signature
|
||||
});
|
||||
return euint8.wrap(FHENetwork.verifyInput(input));
|
||||
}
|
||||
|
||||
function asEuint16(InEuint16 memory value) internal returns (euint16) {
|
||||
EncryptedInput memory input = EncryptedInput({
|
||||
ctHash: value.ctHash,
|
||||
securityZone: value.securityZone,
|
||||
utype: value.utype,
|
||||
signature: value.signature
|
||||
});
|
||||
return euint16.wrap(FHENetwork.verifyInput(input));
|
||||
}
|
||||
|
||||
function asEuint32(InEuint32 memory value) internal returns (euint32) {
|
||||
EncryptedInput memory input = EncryptedInput({
|
||||
ctHash: value.ctHash,
|
||||
securityZone: value.securityZone,
|
||||
utype: value.utype,
|
||||
signature: value.signature
|
||||
});
|
||||
return euint32.wrap(FHENetwork.verifyInput(input));
|
||||
}
|
||||
|
||||
function asEuint64(InEuint64 memory value) internal returns (euint64) {
|
||||
EncryptedInput memory input = EncryptedInput({
|
||||
ctHash: value.ctHash,
|
||||
securityZone: value.securityZone,
|
||||
utype: value.utype,
|
||||
signature: value.signature
|
||||
});
|
||||
return euint64.wrap(FHENetwork.verifyInput(input));
|
||||
}
|
||||
|
||||
function asEuint128(InEuint128 memory value) internal returns (euint128) {
|
||||
EncryptedInput memory input = EncryptedInput({
|
||||
ctHash: value.ctHash,
|
||||
securityZone: value.securityZone,
|
||||
utype: value.utype,
|
||||
signature: value.signature
|
||||
});
|
||||
return euint128.wrap(FHENetwork.verifyInput(input));
|
||||
}
|
||||
|
||||
function asEuint256(InEuint256 memory value) internal returns (euint256) {
|
||||
EncryptedInput memory input = EncryptedInput({
|
||||
ctHash: value.ctHash,
|
||||
securityZone: value.securityZone,
|
||||
utype: value.utype,
|
||||
signature: value.signature
|
||||
});
|
||||
return euint256.wrap(FHENetwork.verifyInput(input));
|
||||
}
|
||||
|
||||
function asEaddress(InEaddress memory value) internal returns (eaddress) {
|
||||
EncryptedInput memory input = EncryptedInput({
|
||||
ctHash: value.ctHash,
|
||||
securityZone: value.securityZone,
|
||||
utype: value.utype,
|
||||
signature: value.signature
|
||||
});
|
||||
return eaddress.wrap(FHENetwork.verifyInput(input));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
pragma solidity >=0.8.19 <0.9.0;
|
||||
|
||||
// Re-export all FHE interfaces and structs from @luxfi/contracts
|
||||
// Clean path: @luxfi/contracts/fhe/IFHE.sol (no double "contracts")
|
||||
import "@luxfi/contracts/fhe/IFHE.sol";
|
||||
@@ -0,0 +1,51 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
pragma solidity >=0.8.19 <0.9.0;
|
||||
|
||||
import {FunctionId, EncryptedInput} from "./IFHE.sol";
|
||||
|
||||
/// @title IFHENetwork
|
||||
/// @notice Interface for the FHE Network contract on the Lux T-Chain
|
||||
/// @dev Extends ITaskManager with additional access control and utility methods
|
||||
interface IFHENetwork {
|
||||
// Task Management
|
||||
function createTask(
|
||||
uint8 returnType,
|
||||
FunctionId funcId,
|
||||
uint256[] memory encryptedInputs,
|
||||
uint256[] memory extraInputs
|
||||
) external returns (uint256);
|
||||
|
||||
function createDecryptTask(uint256 ctHash, address requestor) external;
|
||||
|
||||
function verifyInput(
|
||||
EncryptedInput memory input,
|
||||
address sender
|
||||
) external returns (uint256);
|
||||
|
||||
// Decryption Results
|
||||
function getDecryptResult(uint256 ctHash) external view returns (uint256);
|
||||
|
||||
function getDecryptResultSafe(
|
||||
uint256 ctHash
|
||||
) external view returns (uint256 result, bool decrypted);
|
||||
|
||||
// Access Control
|
||||
function allow(uint256 ctHash, address account) external;
|
||||
|
||||
function allowGlobal(uint256 ctHash) external;
|
||||
|
||||
function allowTransient(uint256 ctHash, address account) external;
|
||||
|
||||
function allowForDecryption(uint256 ctHash) external;
|
||||
|
||||
function isAllowed(
|
||||
uint256 ctHash,
|
||||
address account
|
||||
) external view returns (bool);
|
||||
|
||||
// Note: isAllowedWithPermission is implementation-specific due to Permission struct variations
|
||||
// Implementations should define this function with their own Permission type
|
||||
|
||||
// Utility
|
||||
function exists() external view returns (bool);
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
pragma solidity >=0.8.19 <0.9.0;
|
||||
|
||||
// Typed encrypted input structs for the FHE API
|
||||
// These have the same memory layout as EncryptedInput for ABI compatibility
|
||||
// Format: { ctHash, securityZone, utype, signature }
|
||||
|
||||
struct InEbool {
|
||||
uint256 ctHash;
|
||||
uint8 securityZone;
|
||||
uint8 utype;
|
||||
bytes signature;
|
||||
}
|
||||
|
||||
struct InEuint8 {
|
||||
uint256 ctHash;
|
||||
uint8 securityZone;
|
||||
uint8 utype;
|
||||
bytes signature;
|
||||
}
|
||||
|
||||
struct InEuint16 {
|
||||
uint256 ctHash;
|
||||
uint8 securityZone;
|
||||
uint8 utype;
|
||||
bytes signature;
|
||||
}
|
||||
|
||||
struct InEuint32 {
|
||||
uint256 ctHash;
|
||||
uint8 securityZone;
|
||||
uint8 utype;
|
||||
bytes signature;
|
||||
}
|
||||
|
||||
struct InEuint64 {
|
||||
uint256 ctHash;
|
||||
uint8 securityZone;
|
||||
uint8 utype;
|
||||
bytes signature;
|
||||
}
|
||||
|
||||
struct InEuint128 {
|
||||
uint256 ctHash;
|
||||
uint8 securityZone;
|
||||
uint8 utype;
|
||||
bytes signature;
|
||||
}
|
||||
|
||||
struct InEuint256 {
|
||||
uint256 ctHash;
|
||||
uint8 securityZone;
|
||||
uint8 utype;
|
||||
bytes signature;
|
||||
}
|
||||
|
||||
struct InEaddress {
|
||||
uint256 ctHash;
|
||||
uint8 securityZone;
|
||||
uint8 utype;
|
||||
bytes signature;
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
{
|
||||
"name": "@luxfhe/contracts",
|
||||
"version": "1.1.0",
|
||||
"description": "LuxFHE Contracts - Re-exports FHE contracts from @luxfi/contracts",
|
||||
"license": "MIT",
|
||||
"author": "Lux Partners Limited <security@lux.partners>",
|
||||
"homepage": "https://github.com/luxfi/fhe",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/luxfi/fhe.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/luxfi/fhe/issues"
|
||||
},
|
||||
"keywords": [
|
||||
"solidity",
|
||||
"ethereum",
|
||||
"fhe",
|
||||
"fully-homomorphic-encryption",
|
||||
"smart-contracts",
|
||||
"lux",
|
||||
"blockchain"
|
||||
],
|
||||
"files": [
|
||||
"fhe/**/*.sol",
|
||||
"README.md"
|
||||
],
|
||||
"dependencies": {
|
||||
"@luxfi/contracts": "^1.3.4"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user