Fabcoin Core  0.16.2
P2P Digital Currency
gf256.h
Go to the documentation of this file.
1 // gf256.h - written and placed in the public domain by Wei Dai
2 
5 
6 #ifndef CRYPTOPP_GF256_H
7 #define CRYPTOPP_GF256_H
8 
9 #include "cryptlib.h"
10 #include "misc.h"
11 
13 
14 class GF256
16 {
17 public:
18  typedef byte Element;
20 
21  GF256(byte modulus) : m_modulus(modulus) {}
22 
23  Element RandomElement(RandomNumberGenerator &rng, int ignored = 0) const
24  {CRYPTOPP_UNUSED(ignored); return rng.GenerateByte();}
25 
26  bool Equal(Element a, Element b) const
27  {return a==b;}
28 
29  Element Zero() const
30  {return 0;}
31 
32  Element Add(Element a, Element b) const
33  {return a^b;}
34 
35  Element& Accumulate(Element &a, Element b) const
36  {return a^=b;}
37 
38  Element Inverse(Element a) const
39  {return a;}
40 
41  Element Subtract(Element a, Element b) const
42  {return a^b;}
43 
44  Element& Reduce(Element &a, Element b) const
45  {return a^=b;}
46 
47  Element Double(Element a) const
48  {CRYPTOPP_UNUSED(a); return 0;}
49 
50  Element One() const
51  {return 1;}
52 
53  Element Multiply(Element a, Element b) const;
54 
55  Element Square(Element a) const
56  {return Multiply(a, a);}
57 
58  bool IsUnit(Element a) const
59  {return a != 0;}
60 
61  Element MultiplicativeInverse(Element a) const;
62 
63  Element Divide(Element a, Element b) const
64  {return Multiply(a, MultiplicativeInverse(b));}
65 
66 private:
68 };
69 
71 
72 #endif
GF256(byte modulus)
Definition: gf256.h:21
Element & Reduce(Element &a, Element b) const
Definition: gf256.h:44
uint8_t byte
Definition: Common.h:57
Utility functions for the Crypto++ library.
word m_modulus
Definition: gf256.h:67
bool IsUnit(Element a) const
Definition: gf256.h:58
Element Subtract(Element a, Element b) const
Definition: gf256.h:41
#define NAMESPACE_BEGIN(x)
Definition: config.h:200
Element Zero() const
Definition: gf256.h:29
Abstract base classes that provide a uniform interface to this library.
bool Equal(Element a, Element b) const
Definition: gf256.h:26
Interface for random number generators.
Definition: cryptlib.h:1188
Element RandomElement(RandomNumberGenerator &rng, int ignored=0) const
Definition: gf256.h:23
GF(256) with polynomial basis.
Definition: gf256.h:15
Element Add(Element a, Element b) const
Definition: gf256.h:32
Element Square(Element a) const
Definition: gf256.h:55
Element One() const
Definition: gf256.h:50
#define a(i)
Element Divide(Element a, Element b) const
Definition: gf256.h:63
#define b(i, j)
virtual byte GenerateByte()
Generate new random byte and return it.
Definition: cryptlib.cpp:291
Element Inverse(Element a) const
Definition: gf256.h:38
Element Double(Element a) const
Definition: gf256.h:47
#define CRYPTOPP_UNUSED(x)
Definition: config.h:741
Element & Accumulate(Element &a, Element b) const
Definition: gf256.h:35
void Multiply(word *R, word *T, const word *A, const word *B, size_t N)
Definition: integer.cpp:2324
int RandomizationParameter
Definition: gf256.h:19
#define NAMESPACE_END
Definition: config.h:201
byte Element
Definition: gf256.h:18
word32 word
Definition: config.h:308