Fabcoin Core  0.16.2
P2P Digital Currency
gf256.cpp
Go to the documentation of this file.
1 // gf256.cpp - written and placed in the public domain by Wei Dai
2 
3 #include "pch.h"
4 #include "gf256.h"
5 
7 
9 {
10  word result = 0, t = b;
11 
12  for (unsigned int i=0; i<8; i++)
13  {
14  result <<= 1;
15  if (result & 0x100)
16  result ^= m_modulus;
17 
18  t <<= 1;
19  if (t & 0x100)
20  result ^= a;
21  }
22 
23  return (GF256::Element) result;
24 }
25 
27 {
28  Element result = a;
29  for (int i=1; i<7; i++)
30  result = Multiply(Square(result), a);
31  return Square(result);
32 }
33 
Element Multiply(Element a, Element b) const
Definition: gf256.cpp:8
#define NAMESPACE_BEGIN(x)
Definition: config.h:200
GF(256) with polynomial basis.
Definition: gf256.h:15
Element Square(Element a) const
Definition: gf256.h:55
#define a(i)
Classes and functions for schemes over GF(256)
#define b(i, j)
void Multiply(word *R, word *T, const word *A, const word *B, size_t N)
Definition: integer.cpp:2324
#define NAMESPACE_END
Definition: config.h:201
byte Element
Definition: gf256.h:18
word32 word
Definition: config.h:308
Element MultiplicativeInverse(Element a) const
Definition: gf256.cpp:26