Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fully Homomorphic Encryption and risc zero #607

Closed
GuangguangLu opened this issue Jun 6, 2023 · 9 comments
Closed

Fully Homomorphic Encryption and risc zero #607

GuangguangLu opened this issue Jun 6, 2023 · 9 comments

Comments

@GuangguangLu
Copy link

I want to combine risc zero and FHE, but I haven't found a suitable fully homomorphic encryption tool yet. Do you know whichcan be combined with risc zero?

@GuangguangLu
Copy link
Author

I tried many rust FHE libraries, but none of them worked, is my approach wrong? Are there any successful projects?
I tried:
image

https://crates.io/crates/sunscreen

@SchmErik
Copy link
Contributor

SchmErik commented Jun 7, 2023

It looks like this one uses the risc zero zkvm. https://github.com/emilianobonassi/zkFHE Aside from this we are not aware of any FHE projects that use risc zero or an FHE library that runs on risc zero

@GuangguangLu
Copy link
Author

I saw this project, but it seems that it only supports addition, not full homomorphic encryption

@emilianobonassi
Copy link

Thanks, @SchmErik for mentioning it. @guangguang888 I'm happy to see someone else trying zk FHE.

I've been using addition only HE but originally wanted to go for https://github.com/zama-ai/tfhe-rs which supports FHE.

The current challenges (not actively working on that) are:

  1. tfhe latest version leverage parallel processing and risc0 is 'single core' atm. I had to use a previous version and tune for not using parallel libraries i.e. https://github.com/emilianobonassi/tfhe-rs/commits/0.1.5b

  2. when I tried libm support was not integrated into risc0 and I had to fork it, currently the latest release includes it but I had issues similar to Guest fails to build crossbeam due to atomics #444

  3. zama fhe keys are pretty big (>100MB) and using common serialization/deserialization lead was pretty slow on the host. I've tried different paths like unsafe mem copy and casting but still had some issues. Indeed, I had to double the memory available in risc0 i.e. emilianobonassi/risc0@b871031

Using my latest version of risc0 you are just facing 3. but would be best to rebase to the latest official version and start from there.

For the logic, just split client key generation in the host and server manipulation in the guest/methods. Useful docs here https://docs.zama.ai/tfhe-rs/boolean/tutorial

Happy to support/build together @guangguang888

Arm yourself with a lot of patience because testing requires a few mins every run :D

PS: it would be nice if risc0 or zama would provide some grant on that to prioritize/incentivize this work

@GuangguangLu
Copy link
Author

Thank you very much for your reply.
I will try patiently, thanks again for your reply.

@GuangguangLu
Copy link
Author

Do you mean it is feasible to combine tfhe-rs and risc zero? By using a suitable version and considering the issue of tfhe key size.

@emilianobonassi
Copy link

Do you mean it is feasible to combine tfhe-rs and risc zero? By using a suitable version and considering the issue of tfhe key size.

Frankly, I don’t know. My objective with the PoC was to test it and see in the case the margins for optimization.

@SchmErik
Copy link
Contributor

SchmErik commented Jun 7, 2023

Thanks, @SchmErik for mentioning it. @guangguang888 I'm happy to see someone else trying zk FHE.

I've been using addition only HE but originally wanted to go for https://github.com/zama-ai/tfhe-rs which supports FHE.

The current challenges (not actively working on that) are:

1. tfhe latest version leverage parallel processing and risc0 is 'single core' atm. I had to use a previous version and tune for not using parallel libraries i.e. https://github.com/emilianobonassi/tfhe-rs/commits/0.1.5b

2. when I tried libm support was not integrated into risc0 and I had to fork it, currently the latest release includes it but I had issues similar to [Guest fails to build crossbeam due to atomics #444](https://github.com/risc0/risc0/issues/444)

3. zama fhe keys are pretty big (>100MB) and using common serialization/deserialization lead was pretty slow on the host. I've tried different paths like unsafe mem copy and casting but still had some issues. Indeed, I had to double the memory available in risc0 i.e. [emilianobonassi/risc0@b871031](https://github.com/emilianobonassi/risc0/commit/b871031da429c409710b44e4cdca1e2df1f0150d)

That's pretty big. I don't know much about FHE but is the key a single key or are there different components to the key? In other words, do you need all of the key at once or are you ok taking parts of the key?

@emilianobonassi
Copy link

Thanks, @SchmErik for mentioning it. @guangguang888 I'm happy to see someone else trying zk FHE.
I've been using addition only HE but originally wanted to go for https://github.com/zama-ai/tfhe-rs which supports FHE.
The current challenges (not actively working on that) are:

1. tfhe latest version leverage parallel processing and risc0 is 'single core' atm. I had to use a previous version and tune for not using parallel libraries i.e. https://github.com/emilianobonassi/tfhe-rs/commits/0.1.5b

2. when I tried libm support was not integrated into risc0 and I had to fork it, currently the latest release includes it but I had issues similar to [Guest fails to build crossbeam due to atomics #444](https://github.com/risc0/risc0/issues/444)

3. zama fhe keys are pretty big (>100MB) and using common serialization/deserialization lead was pretty slow on the host. I've tried different paths like unsafe mem copy and casting but still had some issues. Indeed, I had to double the memory available in risc0 i.e. [emilianobonassi/risc0@b871031](https://github.com/emilianobonassi/risc0/commit/b871031da429c409710b44e4cdca1e2df1f0150d)

That's pretty big. I don't know much about FHE but is the key a single key or are there different components to the key? In other words, do you need all of the key at once or are you ok taking parts of the key?

Idk, i’ve been using as a blackbox.

btw, relevant update just 1hr ago which reduces considerably the size for the key.

zama-ai/tfhe-rs#322

@pdg744 pdg744 mentioned this issue Jun 20, 2023
@risc0 risc0 locked and limited conversation to collaborators Jul 18, 2023
@flaub flaub converted this issue into discussion #714 Jul 18, 2023

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants