public class ElgamalEncryption extends java.lang.Object implements AsymmetricEncryptionScheme
Let G be a cyclic group of order $q$.
Key generation: - Choose a \in Z_q = {0,1, ..., q-1} uniformly at random. - Choose generator g of G uniformly at random. - The private key is (G, g, a, h = g^a) and the public key is (G, g, h)
Encryption of message m \in G under public key pk = (G, g, h): - Choose r \in Z_q uniformly at random. - The ciphertext is c = (c_1, c_2) = (g^r, m * h^r)
Decryption of c = (c_1, c_2) under private key sk = (G, g, a, h): - The message is m = c_2 * c_1^{-a}
[1] T. Elgamal, "A public key cryptosystem and a signature scheme based on discrete logarithms," in IEEE Transactions on Information Theory, vol. 31, no. 4, pp. 469-472, July 1985.
| Constructor and Description |
|---|
ElgamalEncryption(org.cryptimeleon.math.structures.groups.Group groupG) |
ElgamalEncryption(org.cryptimeleon.math.serialization.Representation repr) |
| Modifier and Type | Method and Description |
|---|---|
PlainText |
decrypt(CipherText cipherText,
DecryptionKey privateKey)
Decrypts the given cipher text using the given decryption key.
|
CipherText |
encrypt(PlainText plainText,
EncryptionKey publicKey)
Encrypts the given plain text using the given encryption key.
|
CipherText |
encrypt(PlainText plainText,
EncryptionKey publicKey,
java.math.BigInteger random)
Encrypt message under public key and use given randomness.
|
boolean |
equals(java.lang.Object o) |
EncryptionKeyPair |
generateKeyPair()
Generates a public/private-key pair for the specified group.
|
org.cryptimeleon.math.structures.groups.Group |
getGroup() |
org.cryptimeleon.math.serialization.Representation |
getRepresentation() |
int |
hashCode() |
ElgamalCipherText |
restoreCipherText(org.cryptimeleon.math.serialization.Representation repr)
Restores the ciphertext corresponding to the given representation.
|
ElgamalPrivateKey |
restoreDecryptionKey(org.cryptimeleon.math.serialization.Representation repr)
Restores the decryption key corresponding to the given representation.
|
ElgamalPublicKey |
restoreEncryptionKey(org.cryptimeleon.math.serialization.Representation repr)
Restores the encryption key corresponding to the given representation.
|
PlainText |
restorePlainText(org.cryptimeleon.math.serialization.Representation repr)
Restores the plaintext corresponding to the given representation.
|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitdecrypt, encrypt, restoreFromRepresentationpublic ElgamalEncryption(org.cryptimeleon.math.structures.groups.Group groupG)
public ElgamalEncryption(org.cryptimeleon.math.serialization.Representation repr)
public org.cryptimeleon.math.structures.groups.Group getGroup()
public CipherText encrypt(PlainText plainText, EncryptionKey publicKey)
EncryptionSchemeencrypt in interface EncryptionSchemeplainText - the plaintext to encryptpublicKey - the key to use for encryptionpublic CipherText encrypt(PlainText plainText, EncryptionKey publicKey, java.math.BigInteger random)
This function is used internally. Randomness is either uniform at random to obtain the standard Elgamal Encryption. But, e.g. for Fujisaki-Okamoto transform, the randomness is the result of mangling the message with additional randomness.
plainText - the message to encryptpublicKey - the key to use for encryptionrandom - the randomness to use for encryptionpublic PlainText decrypt(CipherText cipherText, DecryptionKey privateKey)
EncryptionSchemedecrypt in interface EncryptionSchemecipherText - the ciphertext to decryptprivateKey - the key to use for decryptionpublic EncryptionKeyPair generateKeyPair()
generateKeyPair in interface AsymmetricEncryptionSchemepublic PlainText restorePlainText(org.cryptimeleon.math.serialization.Representation repr)
EncryptionSchemerestorePlainText in interface EncryptionSchemerepr - the representation to restore the plaintext frompublic ElgamalCipherText restoreCipherText(org.cryptimeleon.math.serialization.Representation repr)
EncryptionSchemerestoreCipherText in interface EncryptionSchemerepr - the representation to restore the ciphertext frompublic ElgamalPublicKey restoreEncryptionKey(org.cryptimeleon.math.serialization.Representation repr)
EncryptionSchemerestoreEncryptionKey in interface EncryptionSchemerepr - the representation to restore the encryption key frompublic ElgamalPrivateKey restoreDecryptionKey(org.cryptimeleon.math.serialization.Representation repr)
EncryptionSchemerestoreDecryptionKey in interface EncryptionSchemerepr - the representation to restore the decryption key frompublic org.cryptimeleon.math.serialization.Representation getRepresentation()
getRepresentation in interface org.cryptimeleon.math.serialization.Representablepublic boolean equals(java.lang.Object o)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Object