Fabcoin Core  0.16.2
P2P Digital Currency
xtrcrypt.h
Go to the documentation of this file.
1 #ifndef CRYPTOPP_XTRCRYPT_H
2 #define CRYPTOPP_XTRCRYPT_H
3 
8 #include "cryptlib.h"
9 #include "xtr.h"
10 #include "integer.h"
11 
13 
14 
17 {
18  typedef XTR_DH ThisClass;
19 
20 public:
21  XTR_DH(const Integer &p, const Integer &q, const GFP2Element &g);
22  XTR_DH(RandomNumberGenerator &rng, unsigned int pbits, unsigned int qbits);
23  XTR_DH(BufferedTransformation &domainParams);
24 
25  void DEREncode(BufferedTransformation &domainParams) const;
26 
27  bool Validate(RandomNumberGenerator &rng, unsigned int level) const;
28  bool GetVoidValue(const char *name, const std::type_info &valueType, void *pValue) const;
29  void AssignFrom(const NameValuePairs &source);
30  CryptoParameters & AccessCryptoParameters() {return *this;}
31  unsigned int AgreedValueLength() const {return 2*m_p.ByteCount();}
32  unsigned int PrivateKeyLength() const {return m_q.ByteCount();}
33  unsigned int PublicKeyLength() const {return 2*m_p.ByteCount();}
34 
35  void GeneratePrivateKey(RandomNumberGenerator &rng, byte *privateKey) const;
36  void GeneratePublicKey(RandomNumberGenerator &rng, const byte *privateKey, byte *publicKey) const;
37  bool Agree(byte *agreedValue, const byte *privateKey, const byte *otherPublicKey, bool validateOtherPublicKey=true) const;
38 
39  const Integer &GetModulus() const {return m_p;}
40  const Integer &GetSubgroupOrder() const {return m_q;}
41  const GFP2Element &GetSubgroupGenerator() const {return m_g;}
42 
43  void SetModulus(const Integer &p) {m_p = p;}
44  void SetSubgroupOrder(const Integer &q) {m_q = q;}
45  void SetSubgroupGenerator(const GFP2Element &g) {m_g = g;}
46 
47 private:
48  unsigned int ExponentBitLength() const;
49 
50  Integer m_p, m_q;
52 };
53 
55 
56 #endif
unsigned int PublicKeyLength() const
Provides the size of the public key.
Definition: xtrcrypt.h:33
uint8_t byte
Definition: Common.h:57
Integer m_q
Definition: xtrcrypt.h:50
GFP2Element m_g
Definition: xtrcrypt.h:51
#define NAMESPACE_BEGIN(x)
Definition: config.h:200
Abstract base classes that provide a uniform interface to this library.
XTR_DH ThisClass
Definition: xtrcrypt.h:18
#define g(i)
Definition: sha.cpp:735
Interface for random number generators.
Definition: cryptlib.h:1188
const Integer & GetSubgroupOrder() const
Definition: xtrcrypt.h:40
void SetSubgroupGenerator(const GFP2Element &g)
Definition: xtrcrypt.h:45
Interface for buffered transformations.
Definition: cryptlib.h:1352
Interface for domains of simple key agreement protocols.
Definition: cryptlib.h:2664
an element of GF(p^2)
Definition: xtr.h:17
const char * source
Definition: rpcconsole.cpp:60
XTR-DH with key validation.
Definition: xtrcrypt.h:16
const char * name
Definition: rest.cpp:36
CryptoParameters & AccessCryptoParameters()
Retrieves a reference to Crypto Parameters.
Definition: xtrcrypt.h:30
void SetModulus(const Integer &p)
Definition: xtrcrypt.h:43
The XTR public key system.
unsigned int AgreedValueLength() const
Provides the size of the agreed value.
Definition: xtrcrypt.h:31
bool Validate(int, bool, const char *)
Definition: test.cpp:884
Multiple precision integer with arithmetic operations.
Definition: integer.h:43
const Integer & GetModulus() const
Definition: xtrcrypt.h:39
Multiple precision integer with arithmetic operations.
#define NAMESPACE_END
Definition: config.h:201
Interface for crypto prameters.
Definition: cryptlib.h:2191
unsigned int PrivateKeyLength() const
Provides the size of the private key.
Definition: xtrcrypt.h:32
void SetSubgroupOrder(const Integer &q)
Definition: xtrcrypt.h:44
const GFP2Element & GetSubgroupGenerator() const
Definition: xtrcrypt.h:41
Interface for retrieving values given their names.
Definition: cryptlib.h:279