The MLIR dialect, its conversion passes (TFHEToConcrete, ConcreteToCAPI, ConcreteToLLVM), the optimizer component, the compiler binary, the Rust crate and the program_info parameter file all still carried the upstream project's name. They now carry this one's. Two things deliberately keep the word, because in them it is not the name. mlir::OpTrait CRTP parameters mean "the derived type", so they are spelled Derived and OpTy — LLVM's other conventional spelling for the same idiom. concreteShape is a capnp field: renaming it would change the serialized protocol, and the prose describing it is ordinary English. This also repairs references the earlier partial rename left dangling: Security.cpp included concrete/curves.gen.h and the directory is torus/, torus-cpu.h included concrete-num_complex.h, the Torus dialect CMakeLists named ConcreteOps.td, and compiler/setup.py asked find_namespace_packages for a "concrete" package that no longer exists — so it built without the package it ships.
3.4 KiB
Upgrading Guide
From Torus v1 To Torus v2
Encrypt/Run/Decrypt type signatures are changed
In Torus v1, there were PublicArguments and PublicResult types. PublicArguments was used to encapsulate encrypted and clear arguments to the function and PublicResult was used to store the encrypted result of the function.
x, y, z = 10, 20, 30
encrypted_args = circuit.encrypt(x, y, z)
encrypted_result = circuit.run(encrypted_args)
result = circuit.decrypt(encrypted_result)
where encrypted_args is of type fhe.PublicArguments, and encrypted_result is of type fhe.PublicResult.
This was simple, but limiting (e.g., since PublicArguments contained all arguments, a change in one of the arguments required re-encryption of all arguments).
In Torus v2, there is fhe.Value type, which is the result of all of encrypt, run, and decrypt.
x, y, z = 10, 20, 30
encrypted_x, encrypted_y, encrypted_z = circuit.encrypt(x, y, z)
encrypted_result = circuit.run(encrypted_x, encrypted_y, encrypted_z)
result = circuit.decrypt(encrypted_result)
where all of encrypted_x, encrypted_y, encrypted_z and encrypted_result are fhe.Value.
In case y value needs to be changed whereas the others need to remain, it's possible to do:
new_y = 42
_, new_encrypted_y, _ = circuit.encrypt(None, new_y, None)
new_encrypted_result = circuit.run(encrypted_x, new_encrypted_y, encrypted_z)
new_result = circuit.decrypt(new_encrypted_result)
New fhe.Circuit.run(...) also support tuples so the old code still works! However, fhe.Server.run(...) had another parameter called evaluation_keys, which have to be a keyword argument now as function arguments are variadic now!
server: fhe.Server = ...
encrypted_x: fhe.Value = ...
encrypted_y: fhe.Value = ...
encrypted_z: fhe.Value = ...
evaluation_keys: fhe.EvaluationKeys = ...
server.run(encrypted_x, encrypted_y, encrypted_z, evaluation_keys=evaluation_keys)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
this needs to be a keyword argument now
Whereas previously it could be:
server: fhe.Server = ...
encrypted_args: fhe.PublicArguments = ...
evaluation_keys: fhe.EvaluationKeys = ...
server.run(encrypted_args, evaluation_keys)
From Torus Numpy v0.x To Torus v1
The PyPI package torus-numpy is now called torus-python.
The module torus.numpy is now called torus.fhe and we advise you to use:
from torus import fhe
instead of the previous:
import torus.numpy as cnp
The module torus.onnx is merged into torus.fhe so we advise you to use:
from torus import fhe
fhe.conv(...)
fhe.maxpool(...)
instead of the previous:
from torus.onnx import connx
connx.conv(...)
connx.maxpool(...)
Virtual configuration option is removed. Simulation is still supported using the new simulate method on circuits:
from torus import fhe
@fhe.compiler({"x": "encrypted"})
def f(x):
return x + 42
inputset = range(10)
circuit = f.compile(inputset)
assert circuit.simulate(1) == 43
instead of the previous:
import torus.numpy as cnp
@cnp.compiler({"x": "encrypted"})
def f(x):
return x + 42
inputset = range(10)
circuit = f.compile(inputset, enable_unsafe_features=True, virtual=True)
assert circuit.encrypt_run_decrypt(1) == 43