Concrete ML
WebsiteLibrariesProducts & ServicesDevelopersSupport
0.6
0.6
  • What is Concrete ML?
  • Getting Started
    • Installation
    • Key Concepts
    • Inference in the Cloud
    • Demos and Tutorials
  • Built-in Models
    • Linear Models
    • Tree-based Models
    • Neural Networks
    • Pandas
    • Built-in Model Examples
  • Deep Learning
    • Using Torch
    • Using ONNX
    • Step-by-step Guide
    • Deep Learning Examples
    • Debugging Models
  • Advanced topics
    • Quantization
    • Pruning
    • Compilation
    • Production Deployment
    • Advanced Features
  • Developer Guide
    • Workflow
      • Set Up the Project
      • Set Up Docker
      • Documentation
      • Support and Issues
      • Contributing
    • Inner Workings
      • Importing ONNX
      • Quantization Tools
      • FHE Op-graph Design
      • External Libraries
    • API
      • concrete.ml.common.check_inputs.md
      • concrete.ml.common.debugging.custom_assert.md
      • concrete.ml.common.debugging.md
      • concrete.ml.common.md
      • concrete.ml.common.utils.md
      • concrete.ml.deployment.fhe_client_server.md
      • concrete.ml.deployment.md
      • concrete.ml.onnx.convert.md
      • concrete.ml.onnx.md
      • concrete.ml.onnx.onnx_impl_utils.md
      • concrete.ml.onnx.onnx_model_manipulations.md
      • concrete.ml.onnx.onnx_utils.md
      • concrete.ml.onnx.ops_impl.md
      • concrete.ml.pytest.md
      • concrete.ml.pytest.torch_models.md
      • concrete.ml.pytest.utils.md
      • concrete.ml.quantization.base_quantized_op.md
      • concrete.ml.quantization.md
      • concrete.ml.quantization.post_training.md
      • concrete.ml.quantization.quantized_module.md
      • concrete.ml.quantization.quantized_ops.md
      • concrete.ml.quantization.quantizers.md
      • concrete.ml.sklearn.base.md
      • concrete.ml.sklearn.glm.md
      • concrete.ml.sklearn.linear_model.md
      • concrete.ml.sklearn.md
      • concrete.ml.sklearn.protocols.md
      • concrete.ml.sklearn.qnn.md
      • concrete.ml.sklearn.rf.md
      • concrete.ml.sklearn.svm.md
      • concrete.ml.sklearn.torch_modules.md
      • concrete.ml.sklearn.tree.md
      • concrete.ml.sklearn.tree_to_numpy.md
      • concrete.ml.sklearn.xgb.md
      • concrete.ml.torch.compile.md
      • concrete.ml.torch.md
      • concrete.ml.torch.numpy_module.md
      • concrete.ml.version.md
Powered by GitBook

Libraries

  • TFHE-rs
  • Concrete
  • Concrete ML
  • fhEVM

Developers

  • Blog
  • Documentation
  • Github
  • FHE resources

Company

  • About
  • Introduction to FHE
  • Media
  • Careers
On this page
  • module concrete.ml.deployment.fhe_client_server
  • Global Variables
  • class FHEModelServer
  • class FHEModelDev
  • class FHEModelClient

Was this helpful?

Export as PDF
  1. Developer Guide
  2. API

concrete.ml.deployment.fhe_client_server.md

Previousconcrete.ml.common.utils.mdNextconcrete.ml.deployment.md

Last updated 2 years ago

Was this helpful?

module concrete.ml.deployment.fhe_client_server

APIs for FHE deployment.

Global Variables

  • CML_VERSION

  • AVAILABLE_MODEL


class FHEModelServer

Server API to load and run the FHE circuit.

method __init__

__init__(path_dir: str)

Initialize the FHE API.

Args:

  • path_dir (str): the path to the directory where the circuit is saved


method load

load()

Load the circuit.


method run

run(
    serialized_encrypted_quantized_data: PublicArguments,
    serialized_evaluation_keys: EvaluationKeys
) → PublicResult

Run the model on the server over encrypted data.

Args:

  • serialized_encrypted_quantized_data (cnp.PublicArguments): the encrypted, quantized and serialized data

  • serialized_evaluation_keys (cnp.EvaluationKeys): the serialized evaluation keys

Returns:

  • cnp.PublicResult: the result of the model


class FHEModelDev

Dev API to save the model and then load and run the FHE circuit.

method __init__

__init__(path_dir: str, model: Any = None)

Initialize the FHE API.

Args:

  • path_dir (str): the path to the directory where the circuit is saved

  • model (Any): the model to use for the FHE API


method save

save()

Export all needed artifacts for the client and server.

Raises:

  • Exception: path_dir is not empty


class FHEModelClient

Client API to encrypt and decrypt FHE data.

method __init__

__init__(path_dir: str, key_dir: str = None)

Initialize the FHE API.

Args:

  • path_dir (str): the path to the directory where the circuit is saved

  • key_dir (str): the path to the directory where the keys are stored


method deserialize_decrypt

deserialize_decrypt(
    serialized_encrypted_quantized_result: PublicArguments
) → ndarray

Deserialize and decrypt the values.

Args:

  • serialized_encrypted_quantized_result (cnp.PublicArguments): the serialized, encrypted and quantized result

Returns:

  • numpy.ndarray: the decrypted and deserialized values


method deserialize_decrypt_dequantize

deserialize_decrypt_dequantize(
    serialized_encrypted_quantized_result: PublicArguments
) → ndarray

Deserialize, decrypt and dequantize the values.

Args:

  • serialized_encrypted_quantized_result (cnp.PublicArguments): the serialized, encrypted and quantized result

Returns:

  • numpy.ndarray: the decrypted (dequantized) values


method generate_private_and_evaluation_keys

generate_private_and_evaluation_keys(force=False)

Generate the private and evaluation keys.

Args:

  • force (bool): if True, regenerate the keys even if they already exist


method get_serialized_evaluation_keys

get_serialized_evaluation_keys() → EvaluationKeys

Get the serialized evaluation keys.

Returns:

  • cnp.EvaluationKeys: the evaluation keys


method load

load()

Load the quantizers along with the FHE specs.


method quantize_encrypt_serialize

quantize_encrypt_serialize(x: ndarray) → PublicArguments

Quantize, encrypt and serialize the values.

Args:

  • x (numpy.ndarray): the values to quantize, encrypt and serialize

Returns:

  • cnp.PublicArguments: the quantized, encrypted and serialized values