3 unstable releases

0.2.1 Nov 16, 2022
0.2.0 Oct 19, 2022
0.1.0 Sep 30, 2021

#2478 in Cryptography

Download history 6/week @ 2024-06-26 3/week @ 2024-07-17 19/week @ 2024-07-24 8/week @ 2024-07-31 4/week @ 2024-08-07 3/week @ 2024-08-14 1/week @ 2024-08-21 7/week @ 2024-08-28 7/week @ 2024-09-04 10/week @ 2024-09-11 15/week @ 2024-09-18 18/week @ 2024-09-25 11/week @ 2024-10-02 8/week @ 2024-10-09

54 downloads per month
Used in concrete

BSD-3-Clause-Clear

94KB
2K SLoC

Concrete Boolean

This library makes it possible to execute boolean gates over encrypted bits. It allows to execute a boolean circuit on an untrusted server because both circuit inputs and outputs are kept private. Data are indeed encrypted on the client side, before being sent to the server. On the server side every computation is performed on ciphertexts. The server however has to know the boolean circuit to be evaluated. At the end of the computation, the server returns the encryption of the result to the user.

Quick Example

The following piece of code shows how to generate keys and run a small Boolean circuit homomorphically.

use concrete_boolean::prelude::*;

fn main() {
   // We generate a set of client/server keys, using the default parameters:
   let (mut client_key, mut 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);

   // We use the server public key to execute a boolean circuit:
   // if ((NOT ct_2) NAND (ct_1 AND ct_2)) then (NOT ct_2) else (ct_1 AND ct_2)
   let ct_3 = server_key.not(&ct_2);
   let ct_4 = server_key.and(&ct_1, &ct_2);
   let ct_5 = server_key.nand(&ct_3, &ct_4);
   let ct_6 = server_key.mux(&ct_5, &ct_3, &ct_4);

   // We use the client key to decrypt the output of the circuit:
   let output = client_key.decrypt(&ct_6);
   assert_eq!(output, true)
}

AVX512

On x86_64 CPUs that have the avx512 instruction set, it is possible to compile using the nightly compiler with the nightly-avx152 to get additional speedup.

cargo +nightly bench --features nightly-avx512

GPU backend

concrete-boolean supports GPU backend via the concrete-cuda crate. It can be activated adding the flag --features=cuda to the compile command.

License

This software is distributed under the BSD-3-Clause-Clear license. If you have any questions, please contact us at hello@zama.ai.

Dependencies

~6.5MB
~127K SLoC