21    GFP2Element(
const byte *encodedElement, 
unsigned int size)
 
   22        : c1(encodedElement, size/2), c2(encodedElement+size/2, size/2) {}
 
   24    void Encode(
byte *encodedElement, 
unsigned int size)
 
   26        c1.
Encode(encodedElement, size/2);
 
   27        c2.
Encode(encodedElement+size/2, size/2);
 
 
   54            throw InvalidArgument(
"GFP2_ONB: modulus must be equivalent to 2 mod 3");
 
   57    const Integer& GetModulus()
 const {
return modp.GetModulus();}
 
   61        t = modp.Inverse(modp.ConvertIn(a));
 
   66        {
return GFP2Element(modp.ConvertIn(a.c1), modp.ConvertIn(a.c2));}
 
   69        {
return GFP2Element(modp.ConvertOut(a.c1), modp.ConvertOut(a.c2));}
 
   73        return modp.Equal(a.c1, b.c1) && modp.Equal(a.c2, b.c2);
 
   78        return GFP2Element::Zero();
 
 
   81    const Element& Add(
const Element &a, 
const Element &b)
 const 
   83        result.c1 = modp.Add(a.c1, b.c1);
 
   84        result.c2 = modp.Add(a.c2, b.c2);
 
   88    const Element& Inverse(
const Element &a)
 const 
   90        result.c1 = modp.Inverse(a.c1);
 
   91        result.c2 = modp.Inverse(a.c2);
 
   95    const Element& Double(
const Element &a)
 const 
   97        result.c1 = modp.Double(a.c1);
 
   98        result.c2 = modp.Double(a.c2);
 
  102    const Element& Subtract(
const Element &a, 
const Element &b)
 const 
  104        result.c1 = modp.Subtract(a.c1, b.c1);
 
  105        result.c2 = modp.Subtract(a.c2, b.c2);
 
  109    Element& Accumulate(Element &a, 
const Element &b)
 const 
  111        modp.Accumulate(a.c1, b.c1);
 
  112        modp.Accumulate(a.c2, b.c2);
 
  116    Element& Reduce(Element &a, 
const Element &b)
 const 
  118        modp.Reduce(a.c1, b.c1);
 
  119        modp.Reduce(a.c2, b.c2);
 
  125        return a.c1.NotZero() || a.c2.NotZero();
 
 
  130        result.c1 = result.c2 = modp.Inverse(modp.MultiplicativeIdentity());
 
 
  136        t = modp.Add(a.c1, a.c2);
 
  137        t = modp.Multiply(t, modp.Add(b.c1, b.c2));
 
  138        result.c1 = modp.Multiply(a.c1, b.c1);
 
  139        result.c2 = modp.Multiply(a.c2, b.c2);
 
  140        result.c1.
swap(result.c2);
 
  141        modp.Reduce(t, result.c1);
 
  142        modp.Reduce(t, result.c2);
 
  143        modp.Reduce(result.c1, t);
 
  144        modp.Reduce(result.c2, t);
 
 
  155        const Integer &ac1 = (&a == &result) ? (t = a.c1) : a.c1;
 
  156        result.c1 = modp.Multiply(modp.Subtract(modp.Subtract(a.c2, a.c1), a.c1), a.c2);
 
  157        result.c2 = modp.Multiply(modp.Subtract(modp.Subtract(ac1, a.c2), a.c2), ac1);
 
 
  169    const Element & PthPower(
const Element &a)
 const 
  172        result.c1.
swap(result.c2);
 
  176    void RaiseToPthPower(Element &a)
 const 
  182    const Element & SpecialOperation1(
const Element &a)
 const 
  186        modp.Reduce(result.c1, a.c2);
 
  187        modp.Reduce(result.c1, a.c2);
 
  188        modp.Reduce(result.c2, a.c1);
 
  189        modp.Reduce(result.c2, a.c1);
 
  194    const Element & SpecialOperation2(
const Element &x, 
const Element &y, 
const Element &z)
 const 
  197        t = modp.Add(x.c2, y.c2);
 
  198        result.c1 = modp.Multiply(z.c1, modp.Subtract(y.c1, t));
 
  199        modp.Accumulate(result.c1, modp.Multiply(z.c2, modp.Subtract(t, x.c1)));
 
  200        t = modp.Add(x.c1, y.c1);
 
  201        result.c2 = modp.Multiply(z.c2, modp.Subtract(y.c2, t));
 
  202        modp.Accumulate(result.c2, modp.Multiply(z.c1, modp.Subtract(t, x.c2)));
 
 
Classes for performing mathematics over different fields.
 
bool operator==(const OID &lhs, const OID &rhs)
Compare two OIDs for equality.
 
bool operator!=(const OID &lhs, const OID &rhs)
Compare two OIDs for inequality.
 
virtual Element CascadeExponentiate(const Element &x, const Integer &e1, const Element &y, const Integer &e2) const
TODO.
 
GF(p^2), optimal normal basis.
 
const Element & MultiplicativeIdentity() const
Retrieves the multiplicative identity.
 
const Element & MultiplicativeInverse(const Element &a) const
Calculate the multiplicative inverse of an element in the group.
 
const Element & Multiply(const Element &a, const Element &b) const
Multiplies elements in the group.
 
bool IsUnit(const Element &a) const
Determines whether an element is a unit in the group.
 
Element Exponentiate(const Element &a, const Integer &e) const
Raises a base to an exponent in the group.
 
const Element & Square(const Element &a) const
Square an element in the group.
 
const Element & Identity() const
Provides the Identity element.
 
Multiple precision integer with arithmetic operations.
 
static void Divide(Integer &r, Integer &q, const Integer &a, const Integer &d)
Extended Division.
 
void swap(Integer &a)
Swaps this Integer with another Integer.
 
void Encode(byte *output, size_t outputLen, Signedness sign=UNSIGNED) const
Encode in big-endian format.
 
An invalid argument was detected.
 
Interface for random number generators.
 
Abstract base classes that provide a uniform interface to this library.
 
Multiple precision integer with arithmetic operations.
 
Class file for performing modular arithmetic.
 
Crypto++ library namespace.
 
#define CRYPTOPP_ASSERT(exp)
Debugging and diagnostic assertion.
 
void XTR_FindPrimesAndGenerator(RandomNumberGenerator &rng, Integer &p, Integer &q, GFP2Element &g, unsigned int pbits, unsigned int qbits)
Creates primes p,q and generator g for XTR.