21 #ifndef TAO_CRYPT_ALGEBRA_HPP
22 #define TAO_CRYPT_ALGEBRA_HPP
24 #include "integer.hpp"
46 virtual const Element& Identity()
const =0;
49 virtual bool InversionIsFast()
const {
return false;}
60 virtual void SimultaneousMultiply(
Element *results,
const Element &base,
61 const Integer *exponents,
unsigned int exponentsCount)
const;
72 {m_mg.m_pRing =
this;}
75 virtual bool IsUnit(
const Element &a)
const =0;
76 virtual const Element& MultiplicativeIdentity()
const =0;
78 virtual const Element& MultiplicativeInverse(
const Element &a)
const =0;
87 virtual void SimultaneousExponentiate(
Element *results,
const Element&,
88 const Integer *exponents,
unsigned int exponentsCount)
const;
101 {
return GetRing().Equal(a, b);}
103 const Element& Identity()
const
104 {
return GetRing().MultiplicativeIdentity();}
107 {
return GetRing().Multiply(a, b);}
110 {
return a = GetRing().Multiply(a, b);}
113 {
return GetRing().MultiplicativeInverse(a);}
116 {
return GetRing().Divide(a, b);}
119 {
return a = GetRing().Divide(a, b);}
122 {
return GetRing().Square(a);}
125 {
return GetRing().Exponentiate(a, e);}
129 {
return GetRing().CascadeExponentiate(x, e1, y, e2);}
132 const Integer *exponents,
unsigned int exponentsCount)
const
133 {GetRing().SimultaneousExponentiate(results, base, exponents,
139 MultiplicativeGroupT m_mg;
172 const Element& Identity()
const
173 {
return Element::Zero();}
176 {
return result = a+b;}
182 {
return result = -a;}
185 {
return result = a-b;}
191 {
return result = a.Doubled();}
193 const Element& MultiplicativeIdentity()
const
194 {
return Element::One();}
197 {
return result = a*b;}
200 {
return result = a.Squared();}
202 bool IsUnit(
const Element &a)
const
206 {
return result = a.MultiplicativeInverse();}
209 {
return result = a/b;}
212 {
return result = a%b;}
216 {Element::Divide(r, q, a, d);}
226 #endif // TAO_CRYPT_ALGEBRA_HPP