psubgroup.cpp
Go to the documentation of this file.
1 
12 #include "psubgroup.hpp"
13 
14 
15 using namespace arithm;
16 
17 
18 PSubGroup::PSubGroup(Group * bgrp, mpz_class order, mpz_class gen) :
19  Group(order, gen)
20 {
21  baseGroup = bgrp;
22  coOrder = baseGroup->getMultOrder() / order;
23  if (!isIn(generator))
24  {
25  std::cout<<"ERROR: in PSubGroup(bgrp, order, gen), the "
26  <<"generator is not of the correct order."
27  <<"\ngen="<<gen.get_str(16)
28  <<"\norder="<<order.get_str(16)<<std::endl;
29  }
30 }
31 
32 
34 {
35  return Elmt(baseGroup->multiplication(e1,e2).getValue(), this);
36 }
37 
38 
40 {
41  return Elmt(baseGroup->multInverse(e).getValue(), this);
42 }
43 
44 
46 {
47  return Elmt(baseGroup->exponentiation(e,s).getValue(), this);
48 }
49 
50 
51 unsigned int PSubGroup::getLeafSize()
52 {
53  return baseGroup->getLeafSize();
54 }
55 
56 
57 bool PSubGroup::isIn(mpz_class r)
58 {
59  Elmt trial = baseGroup->exponentiation(
61  return (trial.getValue() == 1);
62 }
63 
64 
65 std::string PSubGroup::getType()
66 {
67  return "PSubGroup of a " + baseGroup->getType();
68 }