Skip to content

Create a SHA256 tutorial #39

@zaccherinij

Description

@zaccherinij

Winners

See the two winning solutions here and here

Overview

Create a tutorial demonstrating how to develop a homomorphic SHA256 function

Description

Create an FHE program that computes the SHA-256 value over an encrypted input.
Turn it into a tutorial for the documentation, highlighting the process of turning a regular
program into its FHE equivalent. Input text could be fixed-length for Concrete Numpy solution,
while it should be any length for TFHE-rs solution.

Here is a python example of code you could start from:

import hashlib

import concrete.numpy as cnp
import numpy as np

text = (
    b"Lorem ipsum dolor sit amet, consectetur adipiscing elit. "
    b"Curabitur bibendum, urna eu bibendum egestas, neque augue eleifend odio, et sagittis viverra."
)
assert len(text) == 150

hasher = hashlib.sha256()
hasher.update(text)

sample_input = list(text)
expected_output = list(hasher.digest())

def sha256(data):
    # TODO: implement this function
    pass

compiler = cnp.Compiler(sha256, {"data": "encrypted"})
circuit = compiler.compile(
    inputset=[
        np.random.randint(0, 2 ** 8, size=(150,))
        for _ in range(100)
    ],
    configuration=cnp.Configuration(
        enable_unsafe_features=True,
        use_insecure_key_cache=True,
        insecure_key_cache_location=".keys",
    ),
    verbose=True,
)

We expect your PR to comply with the following:

  • For Concrete Numpy:
    • Input size is fixed to 150 bytes
    • Create the app examples/sha256.py
    • Create the tutorial docs/tutorial/sha256.{md,ipynb}
  • For TFHE-rs:
    • Input size is not fixed
    • Create the app tfhe/examples/sha256.rs
    • Create the tutorial tfhe/docs/tutorial/sha256.md

Library targeted

Bounty type

Expert bounty

Reward

Up to €7,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

Metadata

Metadata

Labels

🎯 BountyThis bounty is currently open💰 AwardedThis project is now completed and awarded📁 Concretelibrary targeted: Concrete📁 TFHE-rslibrary targeted: TFHE-rs

Type

No type

Projects

Status

Awarded Contributions

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions