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

Encryption scheme #30

Closed
wants to merge 4 commits into from
Closed

Encryption scheme #30

wants to merge 4 commits into from

Conversation

LukePearson1
Copy link

@LukePearson1 LukePearson1 commented Aug 11, 2020

This PR is the implementation of the out of circuit (standard), ElGamal Encryption scheme using the JubJub Elliptic curve
group.

This closes #28.

Luke Pearson added 3 commits August 11, 2020 11:09
This commit adds elgamal to the
lib.rs
The elgamal encryption scheme is
needed as an encryption method
across several libraries, which
import jubjub. This commit adds
them in.
The standard code was preventing
the tests from producing the correct
errors. This is removed in this commit.
@LukePearson1 LukePearson1 added bug area:cryptography anything related to cryptographic primitives, hashing and ZKP labels Aug 11, 2020
@LukePearson1 LukePearson1 self-assigned this Aug 11, 2020
@LukePearson1
Copy link
Author

LukePearson1 commented Aug 11, 2020

The tests on this PR fail. With a result as follows:

thread 'elgamal::test_encryption' panicked at 'assertion failed: (left == right)
left: Message([17, 173, 29, 111, 166, 181, 34, 52, 147, 76, 48, 146, 54, 198, 170, 2, 24, 178, 120, 22, 117, 105, 110, 105, 65, 234, 66, 232, 8, 189, 252, 8]),
right: Message([98, 11, 123, 123, 1, 71, 136, 171, 251, 67, 119, 122, 186, 185, 142, 75, 68, 254, 120, 246, 246, 168, 103, 164, 6, 56, 29, 84, 212, 174, 249, 21])
`

The left is the message going in and the right is the messaging coming out. After encryption and decryption, this is not the same message.

My assumption is the decrypt is failing as the decrypt function uses the curve order and SecretKey to compute the inverse mod via lagrange theorem.
This is done as an 'alternative' as there is no inverse mod or power mod functions.

A suggested fix is to implement these functions, either by extended Euclidean Algorithm, or the Savas and Koc in Zerocaf.
@vlopes11 @CPerezz

Inline with the comments on the PR
linked to this issue. The encrypt
and decrypt functions should rely
upon the exponentiations and inverse
modular operations. These have been
added in this commit.
@LukePearson1
Copy link
Author

#32 covers this issue so the PR can be closed.

@CPerezz CPerezz deleted the encryption_scheme branch April 12, 2021 09:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:cryptography anything related to cryptographic primitives, hashing and ZKP
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement ElGamal encryption schema
1 participant