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