Division FHE
AI-powered FHE (Fully Homomorphic Encryption) smart contract generator for Fhenix CoFHE.
Generate privacy-preserving Solidity contracts from natural language descriptions. The AI understands FHE patterns, encrypted types, access control, and compiles contracts automatically using Hardhat.
Built by Sunima
Installation
pip install division-fhe
Requirements: Node.js 18+ and the cofhe-hardhat-starter project for compilation.
Quick Start
CLI
# Generate a contract from description
division-fhe "Create a private voting contract with encrypted vote counts"
# Use a predefined task
division-fhe --task-key voting
# Run benchmark (all 9 contract types)
division-fhe --benchmark
# List available tasks
division-fhe --list-tasks
# Use Groq instead of DeepSeek
division-fhe --provider groq "Create a sealed-bid auction"
Python API
import asyncio
from solagent_fhe import generate, benchmark, FHE_TASKS
async def main():
# Generate a single contract
result = await generate(
task="Create a private token with encrypted balances",
contract_name="MyToken",
provider="deepseek", # or "groq"
)
if result['compiled']:
print(f"Contract generated: {result['name']}.sol")
print(f"Refine rounds: {result['rounds']}")
print(result['code'])
# Run full benchmark
results = await benchmark(provider="deepseek")
asyncio.run(main())
Environment Variables
| Variable | Required | Description |
|---|---|---|
DEEPSEEK_API_KEY |
Yes* | DeepSeek API key for code generation |
GROQ_API_KEY |
Yes* | Groq API key (alternative provider) |
SOLAGENT_HARDHAT_DIR |
No | Path to cofhe-hardhat-starter (auto-detected) |
*At least one LLM provider key required.
Supported Contract Types
| Key | Contract | Description |
|---|---|---|
voting |
ConfidentialVoting | Encrypted vote counts, admin-controlled |
auction |
SealedBidAuction | Hidden bids, FHE comparison for winner |
token |
PrivateToken | ERC20-like with encrypted balances |
lottery |
BlindLottery | FHE random number for winner selection |
threshold |
SecretThreshold | Encrypted threshold comparison |
payroll |
ConfidentialPayroll | Hidden salaries, batch payments |
dex |
PrivateDEX | Encrypted swap amounts and balances |
dao |
PrivateDAO | Encrypted voting power and tallies |
vault |
FHESavingsVault | Encrypted deposits with interest |
How It Works
Description ──→ [Code Agent] ──→ Solidity ──→ [Hardhat Compile]
(DeepSeek) │ │
│ ✓ Success → Done
│ │
│ ✗ Errors
│ │
└──→ [Refine Agent] ──→ Fix ──→ Recompile
(Groq/DeepSeek) (up to 10 rounds)
410 passing tests, 14 deployed contracts, 100% compilation rate
FHE Patterns
The generator understands all Fhenix CoFHE patterns:
- Encrypted types:
euint8–euint256,ebool,eaddress - Operations:
FHE.add,FHE.sub,FHE.select,FHE.gte, etc. - Access control:
FHE.allowThis(),FHE.allow(ct, addr) - Decryption: Async
FHE.decrypt()+getDecryptResultSafe() - Random:
FHE.randomEuint32()for on-chain randomness - Input:
InEuint64for client-encrypted values
License
MIT
Metadata
Release files for division-fhe 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| division_fhe-0.1.0.tar.gz | 10.3 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| division_fhe-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 23.6 kB
Release files / division_fhe-0.1.0.tar.gz
| Download URL | division_fhe-0.1.0.tar.gz |
|---|---|
| Size | 10.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b7f1428080c02b70885d8745fe69d09a58f50266dbeba248bac35f6ea1391465
|
|
BLAKE2b-256 checksum How to use checksums |
c1658659a8cb48833fdad6a62c7b1191837cdb2b1c2ab6701d48d23f71b4fcc2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.12
|
Release files / division_fhe-0.1.0-py3-none-any.whl
| Download URL | division_fhe-0.1.0-py3-none-any.whl |
|---|---|
| Size | 13.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8d523eb79818b0c14ac69759829e021783d7c2b3f5fb5f84de56b95de75b3b61
|
|
BLAKE2b-256 checksum How to use checksums |
ce0bd95e39637ab8965b5dc0839e997f005dcc73323784f90bff1cc6c2f954eb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.12
|
Security for division-fhe 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.