Skip to content
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

Help trying to build an Asymmetric Encryption Gadget #84

Open
fkrause98 opened this issue Dec 5, 2022 · 2 comments
Open

Help trying to build an Asymmetric Encryption Gadget #84

fkrause98 opened this issue Dec 5, 2022 · 2 comments

Comments

@fkrause98
Copy link

Hi!
First of all, if this issue is not meant to be here, please let me know.

That being said, I'm toying with the many repos of arkworks to try and create a gadget for asymmetric encryption using the ElGamal scheme, to then prove said encryption happened.
I was mainly following the example from this test, but it generates 'msg' as a point on JubJub, right? I'd like to know if it is possible to use a string instead, that is, map the string to a point and then encrypt it.

I'm not that versed in cryptography, so correct me If I've said anything wrong, and feel free to point me in another direction if there's an easier way to do this.

@Pratyush
Copy link
Member

Pratyush commented Dec 5, 2022

Hey!

That's a great question. With EC ElGamal, it's a bit tricky to encode arbitrary strings in the plaintext, because the plaintext is, as you noticed, an elliptic curve point (e.g. Jubjub). One way to work around this would be add a str_to_group function that maps (chunks of) strings first to Jubjub base field elements (i.e. Bls12-381 scalar field elements), and then map these to elliptic curve group elements.

This really good post describes some options to encrypt arbitrary string: https://crypto.stackexchange.com/questions/14955/mapping-of-message-onto-elliptic-curve-and-reverse-it. Let me know if it answers your question!

@fkrause98
Copy link
Author

Thanks for the answer and the link, it really helps!
Would it be easier If I had a fixed sized string, or even more so, a u8 array?
What modules from this repo can I use to get started with implementing something like this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants