Concrete
WebsiteLibrariesProducts & ServicesDevelopersSupport
2.6
2.6
  • Welcome
  • Get Started
    • What is Concrete?
    • Installation
    • Quick start
    • Compatibility
    • Terminology
  • Core features
    • Overview
    • Table lookups
    • Bit extraction
    • Rounding
    • Truncating
    • Floating points
    • Comparisons
    • Min/Max operations
    • Bitwise operations
    • Common tips
    • Extensions
    • Tagging
  • Compilation
    • Composition
    • Compression
    • Reuse arguments
    • Multi precision
    • Multi parameters
    • Modules
    • Decorator
    • Direct circuits
  • Execution / Analysis
    • Simulation
    • Progressbar
    • Statistics
    • Formatting and drawing
    • Debug
  • Guides
    • Configure
    • Manage keys
    • Deploy
  • Tutorials
    • See all tutorials
    • Part I: Concrete - FHE compiler
    • Part II: The Architecture of Concrete
  • References
    • API
  • Explanations
    • Compiler workflow
    • Frontend fusing
    • Compiler backend
      • Adding a new backend
    • Optimizer
    • MLIR FHE dialects
      • FHELinalg dialect
      • FHE dialect
      • TFHE dialect
      • Concrete dialect
      • Tracing dialect
      • Runtime dialect
      • SDFG dialect
    • Security
    • Call FHE circuits from other languages
    • Project layout
  • Developers
    • Contributing
    • Release note
    • Feature request
    • Bug report
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

Was this helpful?

Export as PDF
  1. Compilation

Modules

PreviousMulti parametersNextDecorator

Last updated 1 year ago

Was this helpful?

Modules are still experimental. They are only compatible with , which means the outputs of every functions can be used directly as inputs for other functions. The crypto-parameters used in this mode are large and thus, the execution is likely to slow.

In some cases, deploying a server that can execute different functions is useful. Concrete can compile FHE modules, that can contain many different functions to execute at once. All the functions are compiled in a single step and can be . Here is an example:

from concrete import fhe

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

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

You can compile the FHE module MyModule using the compile method. To do that, you need to provide a dictionnary of input sets for every function:

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

Note that here we can see a current limitation of modules: The configuration must use the parameter_selection_strategy of v0, and activate the composable flag.

After the module has been compiled, we can encrypt and call the different functions in the following way:

x = 5
x_enc = my_module.inc.encrypt(x)
x_inc_enc = my_module.inc.run(x_enc)
x_inc = my_module.inc.decrypt(x_inc_enc)
assert x_inc == 6

x_inc_dec_enc = my_module.dec.run(x_inc_enc)
x_inc_dec = my_module.dec.decrypt(x_inc_dec_enc)
assert x_inc_dec == 5

for _ in range(10):
    x_enc = my_module.inc.run(x_enc)
x_dec = my_module.inc.decrypt(x_enc)
assert x_dec == 15
composition
deployed with the same artifacts