Skip to content
/ torus Public

Torus: Lux FHE framework (Python compiler and runtime)

License

Notifications You must be signed in to change notification settings

luxfi/torus

Repository files navigation

Torus

Fully Homomorphic Encryption framework for the Lux ecosystem.

Overview

Torus is a comprehensive FHE framework providing Python APIs, LLVM compilation, and multi-language support for encrypted computation.

Language Support

Language Package Status
Python torus-py ✅ Full
Go luxfi/fhe ✅ Full
Rust torus-rs ✅ Full
C/C++ libtorus ✅ Full
Node.js @luxfi/torus ✅ Full
Ruby torus-rb 🔄 Beta
Elixir torus_ex 🔄 Beta
Haskell torus-hs 🔄 Beta

Installation

Python

pip install torus

Node.js

npm install @luxfi/torus

Go

import "github.com/luxfi/fhe"

Rust

[dependencies]
torus = { git = "https://github.com/luxfi/torus" }

Quick Start

Python

from torus import Compiler, encrypt, decrypt

@Compiler.circuit
def private_add(a, b):
    return a + b

# Compile to FHE circuit
circuit = private_add.compile({"a": "encrypted", "b": "encrypted"})

# Encrypt inputs
enc_a = encrypt(5)
enc_b = encrypt(3)

# Compute on encrypted data
result = circuit(enc_a, enc_b)

# Decrypt result
print(decrypt(result))  # 8

Private ML

from torus.ml import FHEClassifier
from sklearn.datasets import make_classification

X, y = make_classification(n_samples=1000)
model = FHEClassifier()
model.fit(X, y)
model.compile(X)

# Encrypted inference
enc_X = model.encrypt(X[:1])
enc_pred = model.predict(enc_X)
pred = model.decrypt(enc_pred)

Private Agents

from torus.agents import PrivateAgent, EncryptedContext

agent = PrivateAgent(model="luxfi/zen-7b")

# Create encrypted context
ctx = EncryptedContext()
ctx.add_document("Secret plans...", encrypted=True)

# Agent operates on encrypted data
response = agent.run("Summarize the plans", context=ctx)

Components

Integration with Lux

License

BSD 3-Clause Clear License

Links

About

Torus: Lux FHE framework (Python compiler and runtime)

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published