zama-ai / bounty-program

Zama Bounty Program: Contribute to the FHE space and Zama's open source libraries and get rewarded 💰
https://zama.ai
244 stars 13 forks source link

Add bitwise operations #34

Closed zaccherinij closed 1 year ago

zaccherinij commented 1 year ago

Winner

This bounty has been solved, see the entire solution here.

Overview

Support bitwise operations between encrypted integers in Concrete Numpy.

Description

Add support in Concrete Numpy for the following operations:

Here is an example of the bitwise AND operation on 8-bits encrypted values:

import concrete.numpy as cnp
import numpy as np

configuration = cnp.Configuration(
    enable_unsafe_features=True,
    use_insecure_key_cache=True,
    insecure_key_cache_location=".keys",
)

@cnp.compiler({"x": "encrypted", "y": "encrypted"})
def f(x, y):
    return x & y

inputset = [(np.random.randint(0, 2 ** 8), np.random.randint(0, 2 ** 8)) for _ in range(100)]
circuit = f.compile(inputset, configuration, verbose=True)

assert circuit.encrypt_run_decrypt(0b_0010_1100, 0b_0110_0100) == 0b_0010_0100

Here are some guidance to get you started:

We expect your PR to comply with the following:

Library targeted

Concrete-Numpy

Bounty type

Easy bounty

Reward

Up to €2,500

Related links and references

Submission

Apply directly to this bounty by opening an application here.

Questions?

Do you have a specific question about this bounty? Join the live conversation on the FHE.org discord server here. You can also send us an email at: bounty@zama.ai

zaccherinij commented 1 year ago

Closed by https://github.com/zama-ai/concrete-numpy/pull/84