---
# System prepended metadata

title: ReLU Challenge

---


## Introduction
The Rectified Linear Unit (ReLU) function is a fundamental activation function used extensively in neural networks, particularly in deep learning models. It is a simple yet powerful non-linear function that introduces non-linearity into the network, allowing it to learn complex patterns and representations in the data.

The ReLU function is defined mathematically as:

ReLU(x) = \max(0, x)

The objective of the challenge is to create an algorithm capable of computing the ReLU function on data encrypted with CKKS.

## Timeline
* **March 5, 2024** - Start Date
* **June 5, 2024** - Submission Deadline
* **June 15, 2024** - Prize Awarded

## Challenge Info:
1. **Challenge type:** This challenge is a Black Box. Participants are only required to submit the resultant ciphertext. Code or implementation details are not required during the challenge.
2. **Encryption Scheme**: CKKS.
3. **FHE Libraries**: [OpenFHE](https://github.com/openfheorg/openfhe-development), [Lattigo](https://github.com/tuneinsight/lattigo).
4. **Input Data**: 
    * Encrypted vector **X**
    * Cryptocontext
    * Public key
    * Multiplication (Relinearization) key
5. **Output Data**: The outcome should be an encrypted vector `ReLU(x)`.

*If additional rotation keys are needed, please open an issue on [GitHub]() and we will provide them.*

## Testcases
For this challenge, we will publish multiple test cases. Participants should handle the input ciphertext and produce a ciphertext representing the evaluation of the `relu()` function on each element of the input vector. 

***Solutions implemented with OpenFHE and LattiGo libraries will be scorred separately.***

### OpenFHE
**Testcase 1:**
1. **Batch size (Vector length):** 16384
2. **Maximum multiplicative depth**: 12
4. **Ring dimension**: 32768
5. **Scale Mod Size:** 48
6. **Element range**: [-1...1].

### LattiGo
**Testcase 1:**
1. **LogN:** 15
2. **Maximum multiplicative depth**: 13
4. **LogQ**: [60,50,50,50,50,50,50,50,50,50,50,50,50]
5. **LogP:** [56,55,55,55]
6. **LogDefultScale:** 50
7. **Element range**: [-1...1].


## Encoding Technique
By default, we pack the input vector **X** in ciphertext as follows:
| x<sub>0</sub> | x<sub>1</sub> | x<sub>2</sub> | x<sub>3</sub> |...
|---|---|---|---|---

The resulting **ReLU(X)** vector should be packed in the same manner:

| ReLU(x<sub>0</sub>) | ReLU(x<sub>1</sub>) | ReLU(x<sub>2</sub>) | ReLU(x<sub>3</sub>) | ...
|---|---|---|---|---

*If you need the data to be packaged in a different format, please open an issue on [GitHub](https://github.com/Fherma-challenges/relu).*

## Scorring

Solutions implemented with OpenFHE and LattiGo libraries will be scorred separately.
The main parameter of this challenge is Accuracy.
Accuracy is measured as the percentage of slots calculated correctly.
Correctly calculated slot = a slot in which the absolute error is less than **threshold = 0.001** (for the Tescase 1).


## Awards

In this challenge, one solution will be chosen for each group separately: OpenFHE and LattiGo.
The winner in each group will be awarded $ 2,500.

## Test Environment 
The following libraries/packages were used for generating test cases: 
 - **OpenFHE**: v1.1.2
 - **Lattigo**: v5.0.2

Participants can use any third-party software and libraries to solve the challenge.
The only requirement is that the ciphertext uploaded to the platform should be compatible with the  OpenFHE library v1.1 or Lattigo v5.0.2 .

## Challenge Committee

* [Gurgen Arakelov](https://www.linkedin.com/in/gurgen-arakelov-943172b9/), Fair Math
* [Jean-Philippe Bossuat](https://www.linkedin.com/in/jean-philippe-bossuat-9136024b/), Lattigo
* [Nikita Kaskov](https://www.linkedin.com/in/nikita-kaskov-07029812a/), Fair Math
* [Yuriy Polyakov](https://www.linkedin.com/in/yuriy-polyakov-796b84a/), Duality


## How to Participate
This is a **Black Box** challenge. We've prepared a guide on how to participate in these types of challenges. For more detailed information, please see our [User Guide](https://fherma.io/blogs/6542cb68100761da3b545c3f).


## Example
Suppose we have a vector `[-0.45, 0, 0.23]`. After applying the **ReLU** function to each element, we get the vector `[0, 0, 0.23]`.

## Challenge Test Case Files
### OpenFHE
- **cc.txt**: CKKS cryptocontext, serialized in JSON format.
- **key_pub.txt**: Public key, serialized in ~~BINARY~~ JSON format.
- **key_rot.txt**: Rotation key, serialized in ~~BINARY~~ JSON format.
- **key_mult.txt**: Multiplication key, serialized in ~~BINARY~~ JSON format.
- **input.txt**: Input ciphertext, serialized in ~~BINARY~~ JSON format.

### Lattigo
- **cc.txt**: CKKS cryptocontext, serialized in JSON format.
- **key_pub.txt**: Public key, serialized in BINARY format.
- **key_eval.txt**: `RelinearizationKey` object contains evaluation key and Galois keys.
- **input.txt**: Input ciphertext, serialized in BINARY format.




## Useful Links

* [OpenFHE](https://github.com/openfheorg/openfhe-development)
* [OpenFHE Python](https://github.com/openfheorg/openfhe-python)
* [Lattigo](https://github.com/tuneinsight/lattigo)


## Help
If you have any questions, you can:
- Contact us by email: support@fherma.io
- Ask a question in our [Discord](https://discord.gg/NfhXwyr9M5).
- Open an issue on the [GitHub Repository](https://github.com/Fherma-challenges/relu).
- Use [OpenFHE Discourse](https://openfhe.discourse.group).