arrayofciphers.cpp
Go to the documentation of this file.
1 
12 #include "ciphertext.hpp"
13 #include "ciphergroup.hpp"
14 #include "arrayofciphers.hpp"
15 
16 
17 using namespace elGamal;
18 
19 
21 {
22  if ( (!bt->isNode()) || (bt->size() != 2) )
23  {
24  std::cout<<"ERROR: in ArrayOfCiphers(bt,c): bt is not a"
25  <<"Node or is not of size 2.\nbt=";
26  bt->prettyPrint("");
27  std::cout<<std::endl;
28  exit(1);
29  }
30  arithm::ArrayOfElmts uPrime(bt->getChild(0),c.getGrp());
31  arithm::ArrayOfElmts vPrime(bt->getChild(1),c.getGrp());
32  u = uPrime;
33  v = vPrime;
34 }
35 
36 
39  u(left), v(right)
40 {
41  if (u.size() != v.size())
42  {
43  std::cout<<"ERROR: in ArrayOfCiphers(left,right), left"
44  <<"and right are not of the same size."
45  <<"\nleft.size()="<<left.size()
46  <<"\right.size()="<<right.size()
47  <<std::endl;
48  exit(1);
49  }
50 }
51 
52 
54 {
56  result->addChild(u.toByteTree());
57  result->addChild(v.toByteTree());
58  return result;
59 }
60 
61 
63 {
64  return u;
65 }
66 
67 
69 {
70  return v;
71 }
72 
73 
75 {
76  return CipherText(u.getElmt(index), v.getElmt(index));
77 }
78 
79 
80 unsigned int ArrayOfCiphers::size()
81 {
82  return u.size();
83 }