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.
17 KiB
'TFHE' Dialect
High Level Fully Homomorphic Encryption dialect A dialect for representation of high level operation on fully homomorphic ciphertext.
Operation definition
TFHE.batched_add_glwe_cst_int (::mlir::toruslang::TFHE::ABatchedAddGLWECstIntOp)
Batched version of AddGLWEIntOp
Traits: AlwaysSpeculatableImplTrait
Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{}
Operands:
| Operand | Description |
|---|---|
ciphertext |
A GLWE ciphertext |
plaintexts |
1D tensor of integer values |
Results:
| Result | Description |
|---|---|
result |
1D tensor of A GLWE ciphertext values |
TFHE.batched_add_glwe_int_cst (::mlir::toruslang::TFHE::ABatchedAddGLWEIntCstOp)
Batched version of AddGLWEIntOp
Traits: AlwaysSpeculatableImplTrait
Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{}
Operands:
| Operand | Description |
|---|---|
ciphertexts |
1D tensor of A GLWE ciphertext values |
plaintext |
integer |
Results:
| Result | Description |
|---|---|
result |
1D tensor of A GLWE ciphertext values |
TFHE.batched_add_glwe_int (::mlir::toruslang::TFHE::ABatchedAddGLWEIntOp)
Batched version of AddGLWEIntOp
Traits: AlwaysSpeculatableImplTrait
Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{}
Operands:
| Operand | Description |
|---|---|
ciphertexts |
1D tensor of A GLWE ciphertext values |
plaintexts |
1D tensor of integer values |
Results:
| Result | Description |
|---|---|
result |
1D tensor of A GLWE ciphertext values |
TFHE.batched_add_glwe (::mlir::toruslang::TFHE::ABatchedAddGLWEOp)
Batched version of AddGLWEOp
Traits: AlwaysSpeculatableImplTrait
Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{}
Operands:
| Operand | Description |
|---|---|
ciphertexts_a |
1D tensor of A GLWE ciphertext values |
ciphertexts_b |
1D tensor of A GLWE ciphertext values |
Results:
| Result | Description |
|---|---|
result |
1D tensor of A GLWE ciphertext values |
TFHE.add_glwe_int (::mlir::toruslang::TFHE::AddGLWEIntOp)
Returns the sum of a clear integer and an lwe ciphertext
Traits: AlwaysSpeculatableImplTrait
Interfaces: BatchableOpInterface, ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{}
Operands:
| Operand | Description |
|---|---|
a |
A GLWE ciphertext |
b |
integer |
Results:
| Result | Description |
|---|---|
| «unnamed» | A GLWE ciphertext |
TFHE.add_glwe (::mlir::toruslang::TFHE::AddGLWEOp)
Returns the sum of two lwe ciphertexts
Traits: AlwaysSpeculatableImplTrait
Interfaces: BatchableOpInterface, ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{}
Operands:
| Operand | Description |
|---|---|
a |
A GLWE ciphertext |
b |
A GLWE ciphertext |
Results:
| Result | Description |
|---|---|
| «unnamed» | A GLWE ciphertext |
TFHE.batched_bootstrap_glwe (::mlir::toruslang::TFHE::BatchedBootstrapGLWEOp)
Batched version of KeySwitchGLWEOp
Traits: AlwaysSpeculatableImplTrait
Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{}
Attributes:
| Attribute | MLIR Type | Description |
|---|---|---|
key |
::mlir::toruslang::TFHE::GLWEBootstrapKeyAttr | An attribute representing bootstrap key. |
Operands:
| Operand | Description |
|---|---|
ciphertexts |
1D tensor of A GLWE ciphertext values |
lookup_table |
1D tensor of 64-bit signless integer values |
Results:
| Result | Description |
|---|---|
result |
1D tensor of A GLWE ciphertext values |
TFHE.batched_keyswitch_glwe (::mlir::toruslang::TFHE::BatchedKeySwitchGLWEOp)
Batched version of KeySwitchGLWEOp
Traits: AlwaysSpeculatableImplTrait
Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{}
Attributes:
| Attribute | MLIR Type | Description |
|---|---|---|
key |
::mlir::toruslang::TFHE::GLWEKeyswitchKeyAttr | An attribute representing keyswitch key. |
Operands:
| Operand | Description |
|---|---|
ciphertexts |
1D tensor of A GLWE ciphertext values |
Results:
| Result | Description |
|---|---|
result |
1D tensor of A GLWE ciphertext values |
TFHE.batched_mapped_bootstrap_glwe (::mlir::toruslang::TFHE::BatchedMappedBootstrapGLWEOp)
Batched version of KeySwitchGLWEOp which also batches the lookup table
Traits: AlwaysSpeculatableImplTrait
Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{}
Attributes:
| Attribute | MLIR Type | Description |
|---|---|---|
key |
::mlir::toruslang::TFHE::GLWEBootstrapKeyAttr | An attribute representing bootstrap key. |
Operands:
| Operand | Description |
|---|---|
ciphertexts |
1D tensor of A GLWE ciphertext values |
lookup_table |
2D tensor of 64-bit signless integer values |
Results:
| Result | Description |
|---|---|
result |
1D tensor of A GLWE ciphertext values |
TFHE.batched_mul_glwe_cst_int (::mlir::toruslang::TFHE::BatchedMulGLWECstIntOp)
Batched version of MulGLWECstIntOp
Traits: AlwaysSpeculatableImplTrait
Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{}
Operands:
| Operand | Description |
|---|---|
ciphertext |
A GLWE ciphertext |
cleartexts |
1D tensor of integer values |
Results:
| Result | Description |
|---|---|
result |
1D tensor of A GLWE ciphertext values |
TFHE.batched_mul_glwe_int_cst (::mlir::toruslang::TFHE::BatchedMulGLWEIntCstOp)
Batched version of MulGLWEIntCstOp
Traits: AlwaysSpeculatableImplTrait
Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{}
Operands:
| Operand | Description |
|---|---|
ciphertexts |
1D tensor of A GLWE ciphertext values |
cleartext |
integer |
Results:
| Result | Description |
|---|---|
result |
1D tensor of A GLWE ciphertext values |
TFHE.batched_mul_glwe_int (::mlir::toruslang::TFHE::BatchedMulGLWEIntOp)
Batched version of MulGLWEIntOp
Traits: AlwaysSpeculatableImplTrait
Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{}
Operands:
| Operand | Description |
|---|---|
ciphertexts |
1D tensor of A GLWE ciphertext values |
cleartexts |
1D tensor of integer values |
Results:
| Result | Description |
|---|---|
result |
1D tensor of A GLWE ciphertext values |
TFHE.batched_neg_glwe (::mlir::toruslang::TFHE::BatchedNegGLWEOp)
Batched version of NegGLWEOp
Traits: AlwaysSpeculatableImplTrait
Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{}
Operands:
| Operand | Description |
|---|---|
ciphertexts |
1D tensor of A GLWE ciphertext values |
Results:
| Result | Description |
|---|---|
result |
1D tensor of A GLWE ciphertext values |
TFHE.bootstrap_glwe (::mlir::toruslang::TFHE::BootstrapGLWEOp)
Programmable bootstraping of a GLWE ciphertext with a lookup table
Traits: AlwaysSpeculatableImplTrait
Interfaces: BatchableOpInterface, ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{}
Attributes:
| Attribute | MLIR Type | Description |
|---|---|---|
key |
::mlir::toruslang::TFHE::GLWEBootstrapKeyAttr | An attribute representing bootstrap key. |
Operands:
| Operand | Description |
|---|---|
ciphertext |
A GLWE ciphertext |
lookup_table |
1D tensor of 64-bit signless integer values |
Results:
| Result | Description |
|---|---|
result |
A GLWE ciphertext |
TFHE.encode_expand_lut_for_bootstrap (::mlir::toruslang::TFHE::EncodeExpandLutForBootstrapOp)
Encode and expand a lookup table so that it can be used for a bootstrap.
Traits: AlwaysSpeculatableImplTrait
Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{}
Attributes:
| Attribute | MLIR Type | Description |
|---|---|---|
polySize |
::mlir::IntegerAttr | 32-bit signless integer attribute |
outputBits |
::mlir::IntegerAttr | 32-bit signless integer attribute |
isSigned |
::mlir::BoolAttr | bool attribute |
Operands:
| Operand | Description |
|---|---|
input_lookup_table |
1D tensor of 64-bit signless integer values |
Results:
| Result | Description |
|---|---|
result |
1D tensor of 64-bit signless integer values |
TFHE.encode_lut_for_crt_woppbs (::mlir::toruslang::TFHE::EncodeLutForCrtWopPBSOp)
Encode and expand a lookup table so that it can be used for a wop pbs.
Traits: AlwaysSpeculatableImplTrait
Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{}
Attributes:
| Attribute | MLIR Type | Description |
|---|---|---|
crtDecomposition |
::mlir::ArrayAttr | 64-bit integer array attribute |
crtBits |
::mlir::ArrayAttr | 64-bit integer array attribute |
modulusProduct |
::mlir::IntegerAttr | 32-bit signless integer attribute |
isSigned |
::mlir::BoolAttr | bool attribute |
Operands:
| Operand | Description |
|---|---|
input_lookup_table |
1D tensor of 64-bit signless integer values |
Results:
| Result | Description |
|---|---|
result |
2D tensor of 64-bit signless integer values |
TFHE.encode_plaintext_with_crt (::mlir::toruslang::TFHE::EncodePlaintextWithCrtOp)
Encodes a plaintext by decomposing it on a crt basis.
Traits: AlwaysSpeculatableImplTrait
Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{}
Attributes:
| Attribute | MLIR Type | Description |
|---|---|---|
mods |
::mlir::ArrayAttr | 64-bit integer array attribute |
modsProd |
::mlir::IntegerAttr | 64-bit signless integer attribute |
Operands:
| Operand | Description |
|---|---|
input |
64-bit signless integer |
Results:
| Result | Description |
|---|---|
result |
1D tensor of 64-bit signless integer values |
TFHE.keyswitch_glwe (::mlir::toruslang::TFHE::KeySwitchGLWEOp)
Change the encryption parameters of a glwe ciphertext by applying a keyswitch
Traits: AlwaysSpeculatableImplTrait
Interfaces: BatchableOpInterface, ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{}
Attributes:
| Attribute | MLIR Type | Description |
|---|---|---|
key |
::mlir::toruslang::TFHE::GLWEKeyswitchKeyAttr | An attribute representing keyswitch key. |
Operands:
| Operand | Description |
|---|---|
ciphertext |
A GLWE ciphertext |
Results:
| Result | Description |
|---|---|
result |
A GLWE ciphertext |
TFHE.mul_glwe_int (::mlir::toruslang::TFHE::MulGLWEIntOp)
Returns the product of a clear integer and an lwe ciphertext
Traits: AlwaysSpeculatableImplTrait
Interfaces: BatchableOpInterface, ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{}
Operands:
| Operand | Description |
|---|---|
a |
A GLWE ciphertext |
b |
integer |
Results:
| Result | Description |
|---|---|
| «unnamed» | A GLWE ciphertext |
TFHE.neg_glwe (::mlir::toruslang::TFHE::NegGLWEOp)
Negates a glwe ciphertext
Traits: AlwaysSpeculatableImplTrait
Interfaces: BatchableOpInterface, ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{}
Operands:
| Operand | Description |
|---|---|
a |
A GLWE ciphertext |
Results:
| Result | Description |
|---|---|
| «unnamed» | A GLWE ciphertext |
TFHE.sub_int_glwe (::mlir::toruslang::TFHE::SubGLWEIntOp)
Substracts an integer and a GLWE ciphertext
Traits: AlwaysSpeculatableImplTrait
Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{}
Operands:
| Operand | Description |
|---|---|
a |
integer |
b |
A GLWE ciphertext |
Results:
| Result | Description |
|---|---|
| «unnamed» | A GLWE ciphertext |
TFHE.wop_pbs_glwe (::mlir::toruslang::TFHE::WopPBSGLWEOp)
Traits: AlwaysSpeculatableImplTrait
Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{}
Attributes:
| Attribute | MLIR Type | Description |
|---|---|---|
ksk |
::mlir::toruslang::TFHE::GLWEKeyswitchKeyAttr | An attribute representing keyswitch key. |
bsk |
::mlir::toruslang::TFHE::GLWEBootstrapKeyAttr | An attribute representing bootstrap key. |
pksk |
::mlir::toruslang::TFHE::GLWEPackingKeyswitchKeyAttr | An attribute representing Wop Pbs key. |
crtDecomposition |
::mlir::ArrayAttr | 64-bit integer array attribute |
cbsLevels |
::mlir::IntegerAttr | 32-bit signless integer attribute |
cbsBaseLog |
::mlir::IntegerAttr | 32-bit signless integer attribute |
Operands:
| Operand | Description |
|---|---|
ciphertexts |
|
lookupTable |
2D tensor of 64-bit signless integer values |
Results:
| Result | Description |
|---|---|
result |
TFHE.zero (::mlir::toruslang::TFHE::ZeroGLWEOp)
Returns a trivial encryption of 0
Traits: AlwaysSpeculatableImplTrait
Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{}
Results:
| Result | Description |
|---|---|
out |
A GLWE ciphertext |
TFHE.zero_tensor (::mlir::toruslang::TFHE::ZeroTensorGLWEOp)
Returns a tensor containing trivial encryptions of 0
Traits: AlwaysSpeculatableImplTrait
Interfaces: ConditionallySpeculatable, NoMemoryEffect (MemoryEffectOpInterface)
Effects: MemoryEffects::Effect{}
Results:
| Result | Description |
|---|---|
tensor |
Attribute definition
GLWEBootstrapKeyAttr
An attribute representing bootstrap key.
Syntax:
#TFHE.bsk<
mlir::toruslang::TFHE::GLWESecretKey, # inputKey
mlir::toruslang::TFHE::GLWESecretKey, # outputKey
int, # polySize
int, # glweDim
int, # levels
int, # baseLog
int # index
>
Parameters:
| Parameter | C++ type | Description |
|---|---|---|
| inputKey | mlir::toruslang::TFHE::GLWESecretKey |
|
| outputKey | mlir::toruslang::TFHE::GLWESecretKey |
|
| polySize | int |
|
| glweDim | int |
|
| levels | int |
|
| baseLog | int |
|
| index | int |
GLWEKeyswitchKeyAttr
An attribute representing keyswitch key.
Syntax:
#TFHE.ksk<
mlir::toruslang::TFHE::GLWESecretKey, # inputKey
mlir::toruslang::TFHE::GLWESecretKey, # outputKey
int, # levels
int, # baseLog
int # index
>
Parameters:
| Parameter | C++ type | Description |
|---|---|---|
| inputKey | mlir::toruslang::TFHE::GLWESecretKey |
|
| outputKey | mlir::toruslang::TFHE::GLWESecretKey |
|
| levels | int |
|
| baseLog | int |
|
| index | int |
GLWEPackingKeyswitchKeyAttr
An attribute representing Wop Pbs key.
Syntax:
#TFHE.pksk<
mlir::toruslang::TFHE::GLWESecretKey, # inputKey
mlir::toruslang::TFHE::GLWESecretKey, # outputKey
int, # outputPolySize
int, # innerLweDim
int, # glweDim
int, # levels
int, # baseLog
int # index
>
Parameters:
| Parameter | C++ type | Description |
|---|---|---|
| inputKey | mlir::toruslang::TFHE::GLWESecretKey |
|
| outputKey | mlir::toruslang::TFHE::GLWESecretKey |
|
| outputPolySize | int |
|
| innerLweDim | int |
|
| glweDim | int |
|
| levels | int |
|
| baseLog | int |
|
| index | int |
Type definition
GLWECipherTextType
A GLWE ciphertext
An GLWE cipher text
Parameters:
| Parameter | C++ type | Description |
|---|---|---|
| key | mlir::toruslang::TFHE::GLWESecretKey |