elGamal::ArrayOfCiphers Class Reference

Implements an array containing several ciphers. More...

#include <arrayofciphers.hpp>

+ Collaboration diagram for elGamal::ArrayOfCiphers:

Public Member Functions

 ArrayOfCiphers (verifierUtils::ByteTree *bt, CipherGroup c)
 Builds an array from the content of a bytetree and the group in which the ciphers are.
 ArrayOfCiphers (arithm::ArrayOfElmts left, arithm::ArrayOfElmts right)
 Builds an array by setting directly its two attributes.
verifierUtils::ByteTreetoByteTree ()
 Returns a node containing the bytetree representations of the ciphertexts stored in this instance.
arithm::ArrayOfElmts getUarray ()
 Returns the u attribute.
arithm::ArrayOfElmts getVarray ()
 Returns the v attribute.
CipherText getCipherText (unsigned int index)
 Returns the ciphertext at index.
unsigned int size ()
 Returns the size of the array.

Private Attributes

arithm::ArrayOfElmts u
 The "u" part of every ciphertext, i.e. their left hand side.
arithm::ArrayOfElmts v
 The "v" part of every ciphertext, i.e. their right hand side.

Detailed Description

Implements an array containing several ciphers.

Actually, we cheat to in order to make use of the ArrayOfElmts class: the ciphertexts are not stored as CipherText instances. Instead, we have a first ArrayOfElmts containing the values of their u attribute and another for their v. CipherTexts are then built just before the output.

Definition at line 34 of file arrayofciphers.hpp.

Constructor & Destructor Documentation

ArrayOfCiphers::ArrayOfCiphers ( verifierUtils::ByteTree bt,
CipherGroup  c 
)

Builds an array from the content of a bytetree and the group in which the ciphers are.

The bytetree has to be a node containing the bytetree representations of the ciphertexts, NOT a Node containing the bytetree representation of two ArrayOfElmts's.

Definition at line 20 of file arrayofciphers.cpp.

{
if ( (!bt->isNode()) || (bt->size() != 2) )
{
std::cout<<"ERROR: in ArrayOfCiphers(bt,c): bt is not a"
<<"Node or is not of size 2.\nbt=";
bt->prettyPrint("");
std::cout<<std::endl;
exit(1);
}
arithm::ArrayOfElmts uPrime(bt->getChild(0),c.getGrp());
arithm::ArrayOfElmts vPrime(bt->getChild(1),c.getGrp());
u = uPrime;
v = vPrime;
}
ArrayOfCiphers::ArrayOfCiphers ( arithm::ArrayOfElmts  left,
arithm::ArrayOfElmts  right 
)

Builds an array by setting directly its two attributes.

Definition at line 37 of file arrayofciphers.cpp.

:
u(left), v(right)
{
if (u.size() != v.size())
{
std::cout<<"ERROR: in ArrayOfCiphers(left,right), left"
<<"and right are not of the same size."
<<"\nleft.size()="<<left.size()
<<"\right.size()="<<right.size()
<<std::endl;
exit(1);
}
}

Member Function Documentation

CipherText ArrayOfCiphers::getCipherText ( unsigned int  index)

Returns the ciphertext at index.

In practice, builds a new ciphertext from u[index] and v[index].

Definition at line 74 of file arrayofciphers.cpp.

{
return CipherText(u.getElmt(index), v.getElmt(index));
}
arithm::ArrayOfElmts ArrayOfCiphers::getUarray ( )

Returns the u attribute.

Definition at line 62 of file arrayofciphers.cpp.

{
return u;
}
arithm::ArrayOfElmts ArrayOfCiphers::getVarray ( )

Returns the v attribute.

Definition at line 68 of file arrayofciphers.cpp.

{
return v;
}
unsigned int ArrayOfCiphers::size ( )

Returns the size of the array.

Definition at line 80 of file arrayofciphers.cpp.

{
return u.size();
}
verifierUtils::ByteTree * ArrayOfCiphers::toByteTree ( )

Returns a node containing the bytetree representations of the ciphertexts stored in this instance.

Definition at line 53 of file arrayofciphers.cpp.

{
result->addChild(u.toByteTree());
result->addChild(v.toByteTree());
return result;
}

Member Data Documentation

arithm::ArrayOfElmts elGamal::ArrayOfCiphers::u
private

The "u" part of every ciphertext, i.e. their left hand side.

Definition at line 41 of file arrayofciphers.hpp.

arithm::ArrayOfElmts elGamal::ArrayOfCiphers::v
private

The "v" part of every ciphertext, i.e. their right hand side.

Definition at line 47 of file arrayofciphers.hpp.


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