FRODO Version 2.19.1
An open-source framework for Distributed Constraint Optimization (DCOP)
Loading...
Searching...
No Matches
frodo2.solutionSpaces.crypto.ElGamalScheme Class Reference

The ElGamal crypto scheme. More...

Inheritance diagram for frodo2.solutionSpaces.crypto.ElGamalScheme:

Classes

class  ElGamalPublicKeyShare
 A public key share. More...

Public Member Functions

 ElGamalScheme (Element params)
 Constructor.
AddableInteger decrypt (ElGamalBigInteger initialCypherText, ElGamalBigInteger partialDecryption)
ElGamalBigInteger encrypt (AddableInteger cleartext)
ElGamalBigInteger encrypt (AddableInteger cleartext, AddableInteger bound)
ElGamalBigInteger reencrypt (ElGamalBigInteger cyphertext)
ElGamalBigInteger partialDecrypt (ElGamalBigInteger initialCypherText, ElGamalBigInteger partialDecryption)
void addPublicKeyShare (ElGamalPublicKeyShare share)
ElGamalPublicKeyShare newPublicKeyShare ()
String toString ()
Public Member Functions inherited from frodo2.solutionSpaces.crypto.CryptoScheme< AddableInteger, ElGamalBigInteger, ElGamalScheme.ElGamalPublicKeyShare >
newPublicKeyShare ()
void addPublicKeyShare (K share)
 Records another share of the public key.
encrypt (C cleartext)
 Encrypts a cleartext.
reencrypt (E cyphertext)
 Re-encrypts a cyphertext.
partialDecrypt (E initialCypherText, E partialDecryption)
 Partially decrypts a cyphertext.
decrypt (E initialCypherText, E partialDecryption)
 Decrypts a cyphertext.

Static Public Member Functions

static void main (String[] args)
 Creates a safe prime and a generator for use with the ElGamal scheme.

Private Member Functions

BigInteger randomBigInteger ()
boolean isPowerOf2 (BigInteger nbr)
 Tests whether a number is a power of 2.

Static Private Member Functions

static BigInteger getSafePrime (BigInteger r, BigInteger t)
 Return a safe prime number.
static void getSafePrimeAndGenerator ()
 Generate a safe prime, its generator and print them out.
static ArrayList< BigInteger > getFactors (BigInteger r, BigInteger t)
 Returns the list of prime factors of 2rt.
static BigInteger getGenerator (ArrayList< BigInteger > factors, BigInteger prime, SecureRandom rand)
 Return a generator.

Private Attributes

final BigInteger p
 Prime number.
final BigInteger pMinus3
 p - 3
final int nbrBitsOfPminus3
 The number of bits of p - 3.
final BigInteger g
 Number such that gcd(g,p) = 1.
BigInteger y
 The overall public key, as the product of all the (g^x mod p) shares.
BigInteger x
 private key in [1, p-2]
final int size
 The default size of the ElGamal vector.
final SecureRandom rand
 Random generator.
final boolean debug
 If true, does not actually perform encryption/decryption.

Static Private Attributes

static final long serialVersionUID = -4409105662996332812L
 Used for serialization.
static int certainty
 Parameter used to create P.
static int minBitLength
 Parameter used to create P.

Detailed Description

The ElGamal crypto scheme.

Author
Eric Zbinden, Thomas Leaute

Constructor & Destructor Documentation

◆ ElGamalScheme()

frodo2.solutionSpaces.crypto.ElGamalScheme.ElGamalScheme ( Element params)

Constructor.

Parameters
paramsthe publicly known parameters

References g, p, pMinus3, rand, and size.

Member Function Documentation

◆ addPublicKeyShare()

void frodo2.solutionSpaces.crypto.ElGamalScheme.addPublicKeyShare ( ElGamalPublicKeyShare share)

◆ decrypt()

AddableInteger frodo2.solutionSpaces.crypto.ElGamalScheme.decrypt ( ElGamalBigInteger initialCypherText,
ElGamalBigInteger partialDecryption )

◆ encrypt() [1/2]

ElGamalBigInteger frodo2.solutionSpaces.crypto.ElGamalScheme.encrypt ( AddableInteger cleartext)
See also
CryptoScheme.encrypt(java.io.Serializable)
Warning
THE OUTPUT IS NOT REALLY ENCRYPTED! One has to call reencrypt() to encrypt it.

Referenced by frodo2.solutionSpaces.crypto.ElGamalSchemeTest.min(), and frodo2.solutionSpaces.crypto.ElGamalSchemeTest.randomDecryptOnce().

◆ encrypt() [2/2]

ElGamalBigInteger frodo2.solutionSpaces.crypto.ElGamalScheme.encrypt ( AddableInteger cleartext,
AddableInteger bound )
See also
CryptoScheme.encrypt(java.io.Serializable, java.io.Serializable)
Note
bound + 1 = infinity

References frodo2.solutionSpaces.AddableInteger.intValue(), and frodo2.solutionSpaces.AddableInteger.PlusInfinity.PLUS_INF.

Here is the call graph for this function:

◆ getFactors()

ArrayList< BigInteger > frodo2.solutionSpaces.crypto.ElGamalScheme.getFactors ( BigInteger r,
BigInteger t )
staticprivate

Returns the list of prime factors of 2rt.

Parameters
ra large random number
ta prime number
Returns
the list of factor of 2rt

Referenced by getSafePrimeAndGenerator().

◆ getGenerator()

BigInteger frodo2.solutionSpaces.crypto.ElGamalScheme.getGenerator ( ArrayList< BigInteger > factors,
BigInteger prime,
SecureRandom rand )
staticprivate

Return a generator.

Parameters
factorsthe list of the factor of the safe prime minus one (2rt-1)
primea safe prime
randan instance of SecureRandom
Returns
a generator for this safe prime

References rand, size, and x.

Referenced by getSafePrimeAndGenerator().

◆ getSafePrime()

BigInteger frodo2.solutionSpaces.crypto.ElGamalScheme.getSafePrime ( BigInteger r,
BigInteger t )
staticprivate

Return a safe prime number.

Parameters
ra large random number
ta large prime number
Returns
a prime number in the form 2rt+1
Note
r might be modified in a way to find p

References certainty.

Referenced by getSafePrimeAndGenerator().

◆ getSafePrimeAndGenerator()

void frodo2.solutionSpaces.crypto.ElGamalScheme.getSafePrimeAndGenerator ( )
staticprivate

Generate a safe prime, its generator and print them out.

References certainty, frodo2.generator, getFactors(), getGenerator(), getSafePrime(), minBitLength, and rand.

Referenced by main().

Here is the call graph for this function:

◆ isPowerOf2()

boolean frodo2.solutionSpaces.crypto.ElGamalScheme.isPowerOf2 ( BigInteger nbr)
private

Tests whether a number is a power of 2.

Parameters
nbrthe number to test
Returns
whether the input number is a power of 2

Referenced by decrypt().

◆ main()

void frodo2.solutionSpaces.crypto.ElGamalScheme.main ( String[] args)
static

Creates a safe prime and a generator for use with the ElGamal scheme.

Parameters
argsminimum bit length, and prime certainty
Note
This implementation is an improvement over the one by David Bishop, "Introduction to Cryptography with Java Applets"

References certainty, getSafePrimeAndGenerator(), and minBitLength.

Here is the call graph for this function:

◆ newPublicKeyShare()

ElGamalPublicKeyShare frodo2.solutionSpaces.crypto.ElGamalScheme.newPublicKeyShare ( )
See also
CryptoScheme.newPublicKeyShare()

References g, p, and randomBigInteger().

Referenced by frodo2.solutionSpaces.crypto.ElGamalSchemeTest.init().

Here is the call graph for this function:

◆ partialDecrypt()

ElGamalBigInteger frodo2.solutionSpaces.crypto.ElGamalScheme.partialDecrypt ( ElGamalBigInteger initialCypherText,
ElGamalBigInteger partialDecryption )

◆ randomBigInteger()

BigInteger frodo2.solutionSpaces.crypto.ElGamalScheme.randomBigInteger ( )
private
Returns
a random BigInteger in the range of [1,p-2]

Referenced by newPublicKeyShare(), and reencrypt().

◆ reencrypt()

◆ toString()

String frodo2.solutionSpaces.crypto.ElGamalScheme.toString ( )
See also
java.lang.Object#toString()

Member Data Documentation

◆ certainty

int frodo2.solutionSpaces.crypto.ElGamalScheme.certainty
staticprivate

Parameter used to create P.

Represents the certainty that p is prime

Referenced by getSafePrime(), getSafePrimeAndGenerator(), and main().

◆ debug

final boolean frodo2.solutionSpaces.crypto.ElGamalScheme.debug
private

If true, does not actually perform encryption/decryption.

Referenced by decrypt(), partialDecrypt(), and reencrypt().

◆ g

final BigInteger frodo2.solutionSpaces.crypto.ElGamalScheme.g
private

Number such that gcd(g,p) = 1.

Referenced by ElGamalScheme(), newPublicKeyShare(), and reencrypt().

◆ minBitLength

int frodo2.solutionSpaces.crypto.ElGamalScheme.minBitLength
staticprivate

Parameter used to create P.

Represents the minimum bit length of p

Referenced by getSafePrimeAndGenerator(), and main().

◆ nbrBitsOfPminus3

final int frodo2.solutionSpaces.crypto.ElGamalScheme.nbrBitsOfPminus3
private

The number of bits of p - 3.

◆ p

final BigInteger frodo2.solutionSpaces.crypto.ElGamalScheme.p
private

◆ pMinus3

final BigInteger frodo2.solutionSpaces.crypto.ElGamalScheme.pMinus3
private

p - 3

Referenced by ElGamalScheme().

◆ rand

final SecureRandom frodo2.solutionSpaces.crypto.ElGamalScheme.rand
private

Random generator.

Referenced by ElGamalScheme(), getGenerator(), and getSafePrimeAndGenerator().

◆ serialVersionUID

final long frodo2.solutionSpaces.crypto.ElGamalScheme.serialVersionUID = -4409105662996332812L
staticprivate

Used for serialization.

◆ size

final int frodo2.solutionSpaces.crypto.ElGamalScheme.size
private

The default size of the ElGamal vector.

Referenced by ElGamalScheme(), and getGenerator().

◆ x

BigInteger frodo2.solutionSpaces.crypto.ElGamalScheme.x
private

private key in [1, p-2]

Referenced by decrypt(), getGenerator(), and partialDecrypt().

◆ y

BigInteger frodo2.solutionSpaces.crypto.ElGamalScheme.y
private

The overall public key, as the product of all the (g^x mod p) shares.

Referenced by reencrypt().


The documentation for this class was generated from the following file: