Files
zeekay b832ba2c39 Initial Torus commit
Forked from upstream concrete (BSD-3-Clause-Clear, © 2024 ZAMA) at HEAD
ecb729bb. Modifications copyright © 2026 Lux Industries Inc.

Rebranding scope:
  - Python module concrete → torus (across frontends/torus-python)
  - Rust module concrete-* → torus-* (across frontends/torus-rust)
  - MLIR dialect concretelang → toruslang (across compilers/torus-compiler)
  - Compiler optimizer concrete-optimizer → torus-optimizer
  - Backend concrete-cpu / concrete-cuda → torus-cpu / torus-cuda
  - Wire protocol concrete-protocol → torus-protocol
  - Parameter-curves concrete-security-curves-* → torus-security-curves-*
  - Public symbols concretelib → toruslib, ConcreteLang → TorusLang
  - URLs github.com/zama-ai/concrete → github.com/luxfhe/torus
  - URLs docs.zama.ai/concrete → docs.luxfhe.com/torus

Legal compliance:
  - LICENSE.txt retains original Copyright © 2024 ZAMA verbatim (§1-§2)
  - LICENSE.txt adds modifications copyright © 2026 Lux Industries Inc.
  - §3 endorsement clause: Torus is marketed exclusively as a Lux product;
    no Zama name used in README, docs, or marketing
  - NOTICE file provides factual attribution per legal best practice
    (not endorsement; required by upstream BSD-3-Clause-Clear)

README + NOTICE rewritten from scratch with Lux brand:
  - Quick-start in Python (torus.fhe)
  - Architecture diagram showing the gen-1 vtbl integration path
    (luxcpp/gpu → lux-private/gpu-kernels for CUDA/Metal/WebGPU)
  - Scheme coverage table: TFHE (luxfi/fhe), CKKS/BGV/BFV (luxfi/lattice)
  - Lux FHE family table: Torus / TorusVM / TorusEVM / TorusML / TorusNet

Known limitations (phase-2A scope):
  - PyPI package torus-fhe not yet published; the torus Python module
    is renamed structurally but pip-installable distribution is a
    follow-up (Phase 2A.1)
  - MLIR dialect rename is text-level; the compiler-internal LLVM
    rebuild (concrete-compiler-internal-llvm-project submodule) is
    structural and works; tablegen files renamed concrete→torus but the
    generated .inc files in the source tree will regenerate at build
    time
  - backends/torus-cuda/implementation/ is an upstream submodule
    pointer to the tfhe-rs source (not fetched in the staging clone);
    the CUDA backend body is delivered out-of-tree
  - ~100 test-fixture variable names like concrete_encoded_sample
    retain "concrete" as a math term (vs symbolic); these are inside
    tests/, not the public API; cleanup is a follow-up commit
  - 295 Python `from concrete import ...` residuals in luxfhe/ml-sdk
    consumer remain; that repo's import update is Phase 2B

This commit is the seed for the luxfhe/torus repo. Push as the first
commit to a fresh GitHub repo; do not re-import upstream Zama git
history.
2026-05-29 14:16:47 -07:00

6.4 KiB

Deploy

This document explains how to deploy a circuit after the development. After developing your circuit, you may want to deploy it without sharing the circuit's details with every client or hosting computations on dedicated servers. In this scenario, you can use the Client and Server features of Torus.

Deployment process

In a typical Torus deployment:

  • The server hosts the compilation artifact, including client specifications and the FHE executable.
  • The client requests circuit requirements, generates keys, sends an encrypted payload, and receives an encrypted result.
sequenceDiagram
    Client->>Server: Client specifications?
    Server-->>Client: Client specifications
    Client->>Client: Private + Evaluation Keys Generation
    Client->>Server: Encrypted(data) + Evaluation Key
    Server->>Server: Compiled library execution
    Server-->>Client: Encrypted(result)
    Client->>Client: Decrypt(result)

Example

Follow these steps to deploy your circuit:

  1. Develop the circuit: You can develop your own circuit using the techniques discussed in previous chapters. Here is an example.
from torus import fhe

@fhe.compiler({"x": "encrypted"})
def function(x):
    return x + 42

inputset = range(10)
circuit = function.compile(inputset)
  1. Save the server files: Once you have your circuit, save the necessary server files.
circuit.server.save("server.zip")
  1. Send the server files: Send server.zip to your computation server.

Setting up a server

  1. Load the server files: To set up the server, load the server.zip file received from the development machine.
from torus import fhe

server = fhe.Server.load("server.zip")
  1. Prepare for client requests: The server needs to wait for the requests from clients.

  2. Serialize ClientSpecs: The requests typically starts with ClientSpecs as clients need ClientSpecs to generate keys and request computation.

serialized_client_specs: str = server.client_specs.serialize()
  1. Send serialized ClientSpecs to clients.

Setting up clients

  1. Create the client object: After receiving the serialized ClientSpecs from a server, create the Client object.
client_specs = fhe.ClientSpecs.deserialize(serialized_client_specs)
client = fhe.Client(client_specs)

Generating keys (client-side)

  1. Generate keys: Once you have the Client object, perform key generation. This method generates encryption/decryption keys and evaluation keys.
client.keys.generate()
  1. Serialize the evaluation keys: The server needs access to the evaluation keys. You can serialize your evaluation keys as below.
serialized_evaluation_keys: bytes = client.evaluation_keys.serialize()
  1. Send the evaluation keys to the server.

{% hint style="info" %} Serialized evaluation keys are very large, even if they are compressed and can be reused several times: consider caching them on the server {% endhint %}

Encrypting inputs (client-side)

  1. Encrypt inputs: Encrypt your inputs and request the server to perform some computation. This can be done in the following way.
arg: fhe.Value = client.encrypt(7)
serialized_arg: bytes = arg.serialize()
  1. Send the serialized arguments to the server.

Performing computation (server-side)

  1. Deserialize received data: On the server, deserialize the received evaluation keys and arguments received from the client.
deserialized_evaluation_keys = fhe.EvaluationKeys.deserialize(serialized_evaluation_keys)
deserialized_arg = fhe.Value.deserialize(serialized_arg)
  1. Run the computation: Perform the computation and serialize the result.
result: fhe.Value = server.run(deserialized_arg, evaluation_keys=deserialized_evaluation_keys)
serialized_result: bytes = result.serialize()
  1. Send the serialized result to the client:

{% hint style="info" %} Clear arguments can directly be passed to server.run (For example, server.run(x, 10, z, evaluation_keys=...)). {% endhint %}

Decrypting the result (on the client)

  1. Deserialize the result: Once you receive the serialized result from the server, deserialize it.
deserialized_result = fhe.Value.deserialize(serialized_result)
  1. Decrypt the deserialized result:
decrypted_result = client.decrypt(deserialized_result)
assert decrypted_result == 49

Deployment of modules

Deploying a module follows the same logic as the deployment of circuits.

For example, consider a module compiled in the following way:

from torus import fhe

@fhe.module()
class MyModule:
    @fhe.function({"x": "encrypted"})
    def inc(x):
        return x + 1

    @fhe.function({"x": "encrypted"})
    def dec(x):
        return x - 1

inputset = list(range(20))
my_module = MyModule.compile({"inc": inputset, "dec": inputset})
)

You can extract the server from the module and save it in a file:

my_module.server.save("server.zip")

The only noticeable difference between the deployment of modules and the deployment of circuits is that the methods Client::encrypt, Client::decrypt and Server::run must contain an extra function_name argument specifying the name of the targeted function.

For example, to encrypt an argument for the inc function of the module:

arg = client.encrypt(7, function_name="inc")
serialized_arg = arg.serialize()

To execute the inc function:

result = server.run(deserialized_arg, evaluation_keys=deserialized_evaluation_keys, function_name="inc")
serialized_result = result.serialize()

To decrypt a result from the execution of dec:

decrypted_result = client.decrypt(deserialized_result, function_name="dec")