· 8 years ago · Feb 05, 2018, 04:02 PM
1#include <tfhe/tfhe.h>
2#include <tfhe/tfhe_io.h>
3#include <stdio.h>
4
5int main() {
6 //generate a keyset
7 const int minimum_lambda = 110;
8 TFheGateBootstrappingParameterSet* params = new_default_gate_bootstrapping_parameters(minimum_lambda);
9
10 //generate a random key
11 uint32_t seed[] = { 314, 1592, 657 };
12 tfhe_random_generator_setSeed(seed,3);
13 TFheGateBootstrappingSecretKeySet* key = new_random_gate_bootstrapping_secret_keyset(params);
14
15 //export the secret key to file for later use
16 FILE* secret_key = fopen("secret.key","wb");
17 export_tfheGateBootstrappingSecretKeySet_toFile(secret_key, key);
18 fclose(secret_key);
19
20 //export the cloud key to a file (for the cloud)
21 FILE* cloud_key = fopen("cloud.key","wb");
22 export_tfheGateBootstrappingCloudKeySet_toFile(cloud_key, &key->cloud);
23 fclose(cloud_key);
24
25 //you can put additional instructions here!!
26 //...
27
28 //clean up all pointers
29 delete_gate_bootstrapping_secret_keyset(key);
30 delete_gate_bootstrapping_parameters(params);
31
32}