mirror of
https://github.com/luxfhe/solidity.git
synced 2026-10-30 17:09:02 +00:00
main
Built on github.com/luxfi/tfhe (our Go implementation). NO Zama code. NO third-party FHE dependencies. © 2020-2025 Lux Industries Inc.
LuxFHE Solidity
FHE-enabled Smart Contract Library for Lux Network
⚠️ Important IP Notice
This library uses Lux's independent FHE implementation:
- ✅ Interfaces with
github.com/luxfi/tfhe(our Go TFHE) - ✅ Precompiles implemented in
lux/evm/precompile/contracts/fhe/ - ✅ NO dependency on Zama or any third-party FHE code
- ✅ Protected by Lux Industries patent portfolio
Overview
Solidity library for writing confidential smart contracts on Lux Network. Enables operations on encrypted data directly in smart contracts.
Installation
npm install @luxfhe/solidity
# or
forge install luxfhe/solidity
Quick Start
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;
import "@luxfhe/solidity/FHE.sol";
contract ConfidentialCounter {
euint32 private counter;
constructor() {
counter = FHE.asEuint32(0);
}
function increment(inEuint32 calldata encryptedAmount) public {
euint32 amount = FHE.asEuint32(encryptedAmount);
counter = FHE.add(counter, amount);
}
function getEncrypted() public view returns (euint32) {
return counter;
}
}
Encrypted Types
| Type | Description |
|---|---|
ebool |
Encrypted boolean |
euint8 |
Encrypted 8-bit unsigned integer |
euint16 |
Encrypted 16-bit unsigned integer |
euint32 |
Encrypted 32-bit unsigned integer |
euint64 |
Encrypted 64-bit unsigned integer |
euint128 |
Encrypted 128-bit unsigned integer |
euint160 |
Encrypted Ethereum address |
euint256 |
Encrypted EVM word |
eaddress |
Encrypted address type |
Operations
Arithmetic
FHE.add(a, b)- AdditionFHE.sub(a, b)- SubtractionFHE.mul(a, b)- Multiplication
Comparison
FHE.eq(a, b)- EqualFHE.ne(a, b)- Not equalFHE.lt(a, b)- Less thanFHE.le(a, b)- Less than or equalFHE.gt(a, b)- Greater thanFHE.ge(a, b)- Greater than or equal
Bitwise
FHE.and(a, b)- Bitwise ANDFHE.or(a, b)- Bitwise ORFHE.xor(a, b)- Bitwise XORFHE.not(a)- Bitwise NOTFHE.shl(a, n)- Left shiftFHE.shr(a, n)- Right shift
Control Flow
FHE.select(condition, a, b)- Encrypted ternary
Precompile Addresses
| Address | Operation | Gas Cost |
|---|---|---|
| 0x0080 | FheAdd | 50,000 |
| 0x0081 | FheSub | 50,000 |
| 0x0082 | FheMul | 150,000 |
| 0x0083 | FheDiv | 200,000 |
| 0x0090 | FheEq | 30,000 |
| 0x0091 | FheLt | 30,000 |
| 0x00A0 | FheDecrypt | 500,000 |
Contract Templates
ConfidentialERC20
import "@luxfhe/solidity/token/ConfidentialERC20.sol";
contract MyToken is ConfidentialERC20 {
constructor() ConfidentialERC20("My Token", "MTK") {
_mint(msg.sender, FHE.asEuint256(1000000 * 10**18));
}
}
ConfidentialGovernance
import "@luxfhe/solidity/governance/ConfidentialGovernorAlpha.sol";
Architecture
Solidity Contracts (this library)
↓
FHE Precompiles (lux/evm/precompile/contracts/fhe/)
↓
Go TFHE Library (github.com/luxfi/tfhe)
↓
Lattice Primitives (github.com/luxfi/lattice)
License
Lux Research License with Patent Reservation
- ✅ Free for research and academic use
- ✅ Free on Lux Network (mainnet/testnet)
- 📧 Commercial license required for other networks
Contact: [email protected]
Related
- github.com/luxfi/tfhe - Go TFHE implementation
- github.com/luxfi/standard - Full contract library
- docs.lux.network/fhe - Documentation
© 2020-2025 Lux Industries Inc. All rights reserved.