Fabcoin Core  0.16.2
P2P Digital Currency
dh2.h
Go to the documentation of this file.
1 // dh2.h - written and placed in the public domain by Wei Dai
2 
5 
6 #ifndef CRYPTOPP_DH2_H
7 #define CRYPTOPP_DH2_H
8 
9 #include "cryptlib.h"
10 
12 
21 {
22 public:
23  virtual ~DH2() {}
24 
27  : d1(domain), d2(domain) {}
29  DH2(SimpleKeyAgreementDomain &staticDomain, SimpleKeyAgreementDomain &ephemeralDomain)
30  : d1(staticDomain), d2(ephemeralDomain) {}
31 
32  CryptoParameters & AccessCryptoParameters() {return d1.AccessCryptoParameters();}
33 
34  unsigned int AgreedValueLength() const
35  {return d1.AgreedValueLength() + d2.AgreedValueLength();}
36 
37  unsigned int StaticPrivateKeyLength() const
38  {return d1.PrivateKeyLength();}
39  unsigned int StaticPublicKeyLength() const
40  {return d1.PublicKeyLength();}
41  void GenerateStaticPrivateKey(RandomNumberGenerator &rng, byte *privateKey) const
42  {d1.GeneratePrivateKey(rng, privateKey);}
43  void GenerateStaticPublicKey(RandomNumberGenerator &rng, const byte *privateKey, byte *publicKey) const
44  {d1.GeneratePublicKey(rng, privateKey, publicKey);}
45  void GenerateStaticKeyPair(RandomNumberGenerator &rng, byte *privateKey, byte *publicKey) const
46  {d1.GenerateKeyPair(rng, privateKey, publicKey);}
47 
48  unsigned int EphemeralPrivateKeyLength() const
49  {return d2.PrivateKeyLength();}
50  unsigned int EphemeralPublicKeyLength() const
51  {return d2.PublicKeyLength();}
53  {d2.GeneratePrivateKey(rng, privateKey);}
54  void GenerateEphemeralPublicKey(RandomNumberGenerator &rng, const byte *privateKey, byte *publicKey) const
55  {d2.GeneratePublicKey(rng, privateKey, publicKey);}
56  void GenerateEphemeralKeyPair(RandomNumberGenerator &rng, byte *privateKey, byte *publicKey) const
57  {d2.GenerateKeyPair(rng, privateKey, publicKey);}
58 
59  bool Agree(byte *agreedValue,
60  const byte *staticPrivateKey, const byte *ephemeralPrivateKey,
61  const byte *staticOtherPublicKey, const byte *ephemeralOtherPublicKey,
62  bool validateStaticOtherPublicKey=true) const;
63 
64 protected:
66 };
67 
69 
70 #endif
uint8_t byte
Definition: Common.h:57
#define NAMESPACE_BEGIN(x)
Definition: config.h:200
void GenerateStaticPublicKey(RandomNumberGenerator &rng, const byte *privateKey, byte *publicKey) const
Generate a static public key from a private key in this domain.
Definition: dh2.h:43
Abstract base classes that provide a uniform interface to this library.
DH2(SimpleKeyAgreementDomain &domain)
Construct a DH2.
Definition: dh2.h:26
void GenerateStaticPrivateKey(RandomNumberGenerator &rng, byte *privateKey) const
Generate static private key in this domain.
Definition: dh2.h:41
Interface for random number generators.
Definition: cryptlib.h:1188
CryptoParameters & AccessCryptoParameters()
Retrieves a reference to Crypto Parameters.
Definition: dh2.h:32
virtual ~DH2()
Definition: dh2.h:23
DH2(SimpleKeyAgreementDomain &staticDomain, SimpleKeyAgreementDomain &ephemeralDomain)
Construct a DH2.
Definition: dh2.h:29
Interface for domains of simple key agreement protocols.
Definition: cryptlib.h:2664
unsigned int AgreedValueLength() const
Provides the size of the agreed value.
Definition: dh2.h:34
unsigned int EphemeralPrivateKeyLength() const
Provides the size of ephemeral private key.
Definition: dh2.h:48
SimpleKeyAgreementDomain & d2
Definition: dh2.h:65
Unified Diffie-Hellman in GF(p)
Definition: dh2.h:20
void GenerateStaticKeyPair(RandomNumberGenerator &rng, byte *privateKey, byte *publicKey) const
Generate a static private/public key pair.
Definition: dh2.h:45
void GenerateEphemeralPublicKey(RandomNumberGenerator &rng, const byte *privateKey, byte *publicKey) const
Generate ephemeral public key.
Definition: dh2.h:54
void GenerateEphemeralKeyPair(RandomNumberGenerator &rng, byte *privateKey, byte *publicKey) const
Generate private/public key pair.
Definition: dh2.h:56
unsigned int StaticPublicKeyLength() const
Provides the size of the static public key.
Definition: dh2.h:39
#define NAMESPACE_END
Definition: config.h:201
Interface for crypto prameters.
Definition: cryptlib.h:2191
unsigned int EphemeralPublicKeyLength() const
Provides the size of ephemeral public key.
Definition: dh2.h:50
Interface for domains of authenticated key agreement protocols.
Definition: cryptlib.h:2727
void GenerateEphemeralPrivateKey(RandomNumberGenerator &rng, byte *privateKey) const
Generate ephemeral private key.
Definition: dh2.h:52
unsigned int StaticPrivateKeyLength() const
Provides the size of the static private key.
Definition: dh2.h:37