Skip to main content

Compiling FHE programs

Say we had the following FHE program:

#include <parasol.h>

[[clang::fhe_program]]
uint8_t add([[clang::encrypted]] uint8_t a,
[[clang::encrypted]] uint8_t b) {
return a + b;
}

To compile this program, use clang from the Parasol compiler as following:

# Compile the program with clang, targeting the parasol CPU with
# optimizations enabled (-O2). Specify the input C file and the
# output binary path.
clang \
-target parasol \
-O2 \
path/to/voting.c \
-o path/to/voting

This will produce a small binary file at path/to/voting. This file is an Executable and Linkable Format (ELF) file that contains some metadata about the Parasol programs, the specific FHE programs specified with [[clang::fhe_program]], and the assembly code to run the FHE programs on the Parasol processor.

The file generated here can be used with SPF to execute the program, as you probably have seen in the quick start demo.