Fabcoin Core  0.16.2
P2P Digital Currency
blumshub.h
Go to the documentation of this file.
1 // blumshub.h - written and placed in the public domain by Wei Dai
2 
6 
7 #ifndef CRYPTOPP_BLUMSHUB_H
8 #define CRYPTOPP_BLUMSHUB_H
9 
10 #include "cryptlib.h"
11 #include "modarith.h"
12 #include "integer.h"
13 
15 
19 {
20 public:
21  virtual ~PublicBlumBlumShub() {}
22 
23  PublicBlumBlumShub(const Integer &n, const Integer &seed);
24 
25  unsigned int GenerateBit();
26  byte GenerateByte();
27  void GenerateBlock(byte *output, size_t size);
28  void ProcessData(byte *outString, const byte *inString, size_t length);
29 
30  bool IsSelfInverting() const {return true;}
31  bool IsForwardTransformation() const {return true;}
32 
33 protected:
36  word maxBits, bitsLeft;
37 };
38 
41 {
42 public:
43  virtual ~BlumBlumShub() {}
44 
45  // Make sure p and q are both primes congruent to 3 mod 4 and at least 512 bits long,
46  // seed is the secret key and should be about as big as p*q
47  BlumBlumShub(const Integer &p, const Integer &q, const Integer &seed);
48 
49  bool IsRandomAccess() const {return true;}
50  void Seek(lword index);
51 
52 protected:
53  const Integer p, q;
54  const Integer x0;
55 };
56 
58 
59 #endif
Integer current
Definition: blumshub.h:35
bool IsSelfInverting() const
Determines whether the cipher is self-inverting.
Definition: blumshub.h:30
uint8_t byte
Definition: Common.h:57
const Integer q
Definition: blumshub.h:53
BlumBlumShub(const Integer &p, const Integer &q, const Integer &seed)
Definition: blumshub.cpp:48
#define NAMESPACE_BEGIN(x)
Definition: config.h:200
Abstract base classes that provide a uniform interface to this library.
void Seek(lword index)
Seek to an absolute position.
Definition: blumshub.cpp:55
Ring of congruence classes modulo n.
Definition: modarith.h:34
Interface for random number generators.
Definition: cryptlib.h:1188
virtual ~PublicBlumBlumShub()
Definition: blumshub.h:21
bool IsForwardTransformation() const
Determines if the cipher is being operated in its forward direction.
Definition: blumshub.h:31
Multiple precision integer with arithmetic operations.
Definition: integer.h:43
Interface for the data processing portion of stream ciphers.
Definition: cryptlib.h:823
ModularArithmetic modn
Definition: blumshub.h:34
bool IsRandomAccess() const
Determines whether the cipher supports random access.
Definition: blumshub.h:49
BlumBlumShub with factorization of the modulus.
Definition: blumshub.h:40
uint8_t const size_t const size
Definition: sha3.h:20
Multiple precision integer with arithmetic operations.
const Integer p
Definition: blumshub.h:53
#define NAMESPACE_END
Definition: config.h:201
Class file for performing modular arithmetic.
word64 lword
Definition: config.h:245
BlumBlumShub without factorization of the modulus.
Definition: blumshub.h:17
const Integer x0
Definition: blumshub.h:54
word32 word
Definition: config.h:308
virtual ~BlumBlumShub()
Definition: blumshub.h:43