arithm::Group Class Reference

Models a mathematical multiplicative group. More...

#include <group.hpp>

+ Inheritance diagram for arithm::Group:
+ Collaboration diagram for arithm::Group:

Public Member Functions

 Group (mpz_class order, mpz_class gen)
 Sets the attributes of a new group instance.
virtual verifierUtils::ByteTreetoByteTree ()
 Returns the bytetree representation of this group.
Element operations
virtual Elmt multiplication (Elmt e1, Elmt e2)
 Returns the product of the two elements as an element of this group.
virtual Elmt multInverse (Elmt e)
 Returns $e^{-1}$ as an element of this group.
virtual Elmt exponentiation (Elmt e, Elmt s)
 Returns the $e^s$ as an element of this group.
bool compare (Elmt e1, Elmt e2)
 Returns true if e1 and e2 have identical values, false otherwise.
Array operations
ArrayOfElmts multiplication (ArrayOfElmts e1, ArrayOfElmts e2)
 Returns $R ~|~ R_i = e_{1,i} \times e_{2,i}$ as an array of elements of this group.
ArrayOfElmts multInverse (ArrayOfElmts e)
 Returns $R ~|~ R_i = e_i^{-1}$ as an array of elements of this group.
ArrayOfElmts exponentiation (ArrayOfElmts e, ArrayOfElmts s)
 Returns $R ~|~ R_i = e_i^{s_i}$ as an array of elements of this group.
Elmt product (ArrayOfElmts e)
 Returns $r = \prod e_i$ as an element of this group.
Elmt expProduct (ArrayOfElmts e, ArrayOfElmts s)
 Returns $r = \prod e_i^{s_i}$ as an element of this group.
bool compare (ArrayOfElmts e1, ArrayOfElmts e2)
 Returns true if e1 and e2 have identical values component-wise, false if at least one of the component is different.
Encoding and decoding elements
virtual Elmt encode (std::vector< uint8_t > message)
 Encodes the message into a element of this group.
virtual std::vector< uint8_t > decode (Elmt e)
 Returns the element encoded in the element given as a paramater.
Obtaining element
Elmt getOne ()
 Returns an element containing the unit of this group.
ArrayOfElmts getOne (unsigned int n)
 Returns an array containing n copies of the unit of this group.
Elmt getElmt (mpz_class repr)
 Returns the element of this group which has repr as a representative.
Elmt getElmt (verifierUtils::ByteTree *bt)
 Returns the element of this group which bt as a bytetree representation.
ArrayOfElmts getArray (verifierUtils::ByteTree *bt)
 Returns the array of elements of this group which has bt as a bytetree representation.
virtual ArrayOfElmts getRandArray (cryptoTools::PRG *prg, unsigned int nr, unsigned int n0)
 Returns an array of elements of size n0 derived using a prg.
Data about the group
mpz_class getMultOrder ()
 Returns the multiplicative generator of this group.
virtual unsigned int getLeafSize ()
 Returns the byte size the leaves representing element of this group must have.
Elmt getGenerator ()
 Returns the multiplicative generator of this group as an element of this group.
ArrayOfElmts getGenerator (unsigned int n)
 Returns an array containing n copies of the multiplicative order of this group.
virtual bool isIn (mpz_class repr)
 Returns true if the element of representative repr is in this group.
virtual std::string getType ()
 Returns a string containing the name of this Group.

Protected Attributes

mpz_class multOrder
 The order of this multiplicative group.
mpz_class generator
 The generator to use for this group.

Detailed Description

Models a mathematical multiplicative group.

Definition at line 35 of file group.hpp.

Constructor & Destructor Documentation

Group::Group ( mpz_class  order,
mpz_class  gen 
)

Sets the attributes of a new group instance.

Parameters
orderThe value to give to multOrder
genThe value to give to generator

Definition at line 18 of file group.cpp.

{
multOrder = order;
generator = gen;
}

Member Function Documentation

bool Group::compare ( Elmt  e1,
Elmt  e2 
)

Returns true if e1 and e2 have identical values, false otherwise.

Definition at line 52 of file group.cpp.

{
return (e1.getValue() == e2.getValue());
}
bool Group::compare ( ArrayOfElmts  e1,
ArrayOfElmts  e2 
)

Returns true if e1 and e2 have identical values component-wise, false if at least one of the component is different.

Definition at line 137 of file group.cpp.

{
for (unsigned int i=0; i<e1.size(); i++)
if (! compare(e1.getElmt(i),e2.getElmt(i)) )
return false;
return true;
}
std::vector< uint8_t > Group::decode ( Elmt  e)
virtual

Returns the element encoded in the element given as a paramater.

Definition at line 155 of file group.cpp.

{
std::vector<uint8_t> dummyResult;
return dummyResult;
}
Elmt Group::encode ( std::vector< uint8_t >  message)
virtual

Encodes the message into a element of this group.

Definition at line 149 of file group.cpp.

{
return Elmt(0,this);
}
Elmt Group::exponentiation ( Elmt  e,
Elmt  s 
)
virtual

Returns the $e^s$ as an element of this group.

Reimplemented in arithm::PSubGroup, and arithm::ModField.

Definition at line 46 of file group.cpp.

{
return Elmt(0,this);
}
ArrayOfElmts Group::exponentiation ( ArrayOfElmts  e,
ArrayOfElmts  s 
)

Returns $R ~|~ R_i = e_i^{s_i}$ as an array of elements of this group.

Definition at line 88 of file group.cpp.

{
if (e.size() != s.size())
{
std::cout<<"ERROR: in Group.exponentiation(e,s), "
<<"arrays are not of the same size."
<<"\ne.size()="<<e.size()
<<"\ns.size()="<<s.size()<<std::endl;
exit(1);
}
ArrayOfElmts result;
for (unsigned int i=0; i<e.size(); i++)
result.addElmt(
return result;
}
Elmt Group::expProduct ( ArrayOfElmts  e,
ArrayOfElmts  s 
)

Returns $r = \prod e_i^{s_i}$ as an element of this group.

Definition at line 116 of file group.cpp.

{
if (e.size() != s.size())
{
std::cout<<"ERROR: in Group.expProduct(e,s), "
<<"arrays are not of the same size."
<<"\ne.size()="<<e.size()
<<"\ns.size()="<<s.size()<<std::endl;
exit(1);
}
Elmt result = getOne();
for (unsigned int i=0; i<e.size(); i++)
result = multiplication(
result,
return result;
}
ArrayOfElmts Group::getArray ( verifierUtils::ByteTree bt)

Returns the array of elements of this group which has bt as a bytetree representation.

Definition at line 200 of file group.cpp.

{
ArrayOfElmts result;
if (!bt->isNode())
{
std::cout<<"ERROR: in Group.getArray(bt), bt is not a "
<<"Node.\nbt=";
bt->prettyPrint("");
std::cout<<std::endl;
exit(1);
}
for (unsigned int i=0; i<bt->size(); i++)
result.addElmt(getElmt(bt->getChild(i)));
return result;
}
Elmt Group::getElmt ( mpz_class  repr)

Returns the element of this group which has repr as a representative.

Definition at line 180 of file group.cpp.

{
return Elmt(repr,this);
}
Elmt Group::getElmt ( verifierUtils::ByteTree bt)

Returns the element of this group which bt as a bytetree representation.

Definition at line 186 of file group.cpp.

{
if (!bt->isLeaf())
{
std::cout<<"ERROR: in Group.getElmt(bt), bt is not a "
<<"Leaf.\nbt=";
bt->prettyPrint("");
std::cout<<std::endl;
exit(1);
}
return Elmt(bt->toInteger(),this);
}
Elmt Group::getGenerator ( )

Returns the multiplicative generator of this group as an element of this group.

Definition at line 241 of file group.cpp.

{
return getElmt(generator);
}
ArrayOfElmts Group::getGenerator ( unsigned int  n)

Returns an array containing n copies of the multiplicative order of this group.

Definition at line 247 of file group.cpp.

{
ArrayOfElmts result;
for (unsigned int i=0; i<n; i++)
result.addElmt(getGenerator());
return result;
}
unsigned int Group::getLeafSize ( )
virtual

Returns the byte size the leaves representing element of this group must have.

Reimplemented in arithm::Field, and arithm::PSubGroup.

Definition at line 235 of file group.cpp.

{
return mpz_sizeinbase(multOrder.get_mpz_t(),2);
}
mpz_class Group::getMultOrder ( )

Returns the multiplicative generator of this group.

Definition at line 229 of file group.cpp.

{
return multOrder;
}
Elmt Group::getOne ( )

Returns an element containing the unit of this group.

Definition at line 165 of file group.cpp.

{
return getElmt(1);
}
ArrayOfElmts Group::getOne ( unsigned int  n)

Returns an array containing n copies of the unit of this group.

Definition at line 171 of file group.cpp.

{
ArrayOfElmts result;
for (unsigned int i=0; i<n; i++)
result.addElmt(getOne());
return result;
}
ArrayOfElmts Group::getRandArray ( cryptoTools::PRG prg,
unsigned int  nr,
unsigned int  n0 
)
virtual

Returns an array of elements of size n0 derived using a prg.

Parameters
prgThe pseudo-random generator to use.
nrThe statistical distance to use.
n0The size of the array.

Reimplemented in arithm::ModPGrp.

Definition at line 217 of file group.cpp.

{
return ArrayOfElmts();
}
std::string Group::getType ( )
virtual

Returns a string containing the name of this Group.

Reimplemented in arithm::Field, arithm::PSubGroup, and arithm::ModField.

Definition at line 262 of file group.cpp.

{
return "Group";
}
bool Group::isIn ( mpz_class  repr)
virtual

Returns true if the element of representative repr is in this group.

Reimplemented in arithm::PSubGroup.

Definition at line 256 of file group.cpp.

{
return true;
}
Elmt Group::multInverse ( Elmt  e)
virtual

Returns $e^{-1}$ as an element of this group.

Reimplemented in arithm::PSubGroup, and arithm::ModField.

Definition at line 40 of file group.cpp.

{
return Elmt(0,this);
}
ArrayOfElmts Group::multInverse ( ArrayOfElmts  e)

Returns $R ~|~ R_i = e_i^{-1}$ as an array of elements of this group.

Definition at line 79 of file group.cpp.

{
ArrayOfElmts result;
for (unsigned int i=0; i<e.size(); i++)
result.addElmt(multInverse(e.getElmt(i)));
return result;
}
Elmt Group::multiplication ( Elmt  e1,
Elmt  e2 
)
virtual

Returns the product of the two elements as an element of this group.

Reimplemented in arithm::PSubGroup, and arithm::ModField.

Definition at line 34 of file group.cpp.

{
return Elmt(0,this);
}
ArrayOfElmts Group::multiplication ( ArrayOfElmts  e1,
ArrayOfElmts  e2 
)

Returns $R ~|~ R_i = e_{1,i} \times e_{2,i}$ as an array of elements of this group.

Definition at line 61 of file group.cpp.

{
if (e1.size() != e2.size())
{
std::cout<<"ERROR: in Group.multiplication(e1,e2), "
<<"arrays are not of the same size."
<<"\ne1.size()="<<e1.size()
<<"\ne2.size()="<<e2.size()<<std::endl;
exit(1);
}
ArrayOfElmts result;
for (unsigned int i=0; i<e1.size(); i++)
result.addElmt(
multiplication(e1.getElmt(i), e2.getElmt(i)));
return result;
}
Elmt Group::product ( ArrayOfElmts  e)

Returns $r = \prod e_i$ as an element of this group.

Definition at line 107 of file group.cpp.

{
Elmt result = getOne();
for (unsigned int i=0; i<e.size(); i++)
result = multiplication(result,e.getElmt(i));
return result;
}
verifierUtils::ByteTree * Group::toByteTree ( )
virtual

Returns the bytetree representation of this group.

Reimplemented in arithm::ModPGrp.

Definition at line 25 of file group.cpp.

{
return NULL;
}

Member Data Documentation

mpz_class arithm::Group::generator
protected

The generator to use for this group.

Definition at line 46 of file group.hpp.

mpz_class arithm::Group::multOrder
protected

The order of this multiplicative group.

Definition at line 41 of file group.hpp.


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