Skip to content

Instantly share code, notes, and snippets.

@randhindi
randhindi / concrete_boolean.rs
Created Sep 30, 2021
Concrete Boolean example
View concrete_boolean.rs
extern crate concrete_boolean;
use concrete_boolean::gen_keys;
// We generate a set of client/server keys, using the default parameters:
let (client_key, server_key) = gen_keys();
// We use the client secret key to encrypt two messages:
let ct_1 = client_key.encrypt(true);
let ct_2 = client_key.encrypt(false);
View logreg_simulate.py
x = np.random.uniform(-1, 1, 5)
print(f"Simulation result: {h.simulate(x)}")
print(f"Plain NumPy result: {func(x)}")
View logreg_compilation.py
h = hnp.compile_fhe(
func,
{'x': hnp.encrypted_ndarray(bounds=(-1, 1), shape=(5,))}
)
View logreg_setup.py
import hnumpy as hnp
import numpy as np
weights = np.array([0.1, 0.2, 0.3, 0.4, 0.5])
bias = np.array([0.1])
def sigmoid(x):
return 1 / (1 + np.exp(-x))
def func(x):
View keybase.md

Keybase proof

I hereby claim:

  • I am randhindi on github.
  • I am randhindi (https://keybase.io/randhindi) on keybase.
  • I have a public key whose fingerprint is 98BA 8D5F 66E4 2674 40F1 3672 8477 4711 8743 5CAE

To claim this, I am signing this object: