Fabcoin Core  0.16.2
P2P Digital Currency
Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
XTR_DH Class Reference

XTR-DH with key validation. More...

#include <xtrcrypt.h>

Inheritance diagram for XTR_DH:
[legend]
Collaboration diagram for XTR_DH:
[legend]

Public Member Functions

 XTR_DH (const Integer &p, const Integer &q, const GFP2Element &g)
 
 XTR_DH (RandomNumberGenerator &rng, unsigned int pbits, unsigned int qbits)
 
 XTR_DH (BufferedTransformation &domainParams)
 
void DEREncode (BufferedTransformation &domainParams) const
 
bool Validate (RandomNumberGenerator &rng, unsigned int level) const
 Check this object for errors. More...
 
bool GetVoidValue (const char *name, const std::type_info &valueType, void *pValue) const
 Get a named value. More...
 
void AssignFrom (const NameValuePairs &source)
 Assign values to this object. More...
 
CryptoParametersAccessCryptoParameters ()
 Retrieves a reference to Crypto Parameters. More...
 
unsigned int AgreedValueLength () const
 Provides the size of the agreed value. More...
 
unsigned int PrivateKeyLength () const
 Provides the size of the private key. More...
 
unsigned int PublicKeyLength () const
 Provides the size of the public key. More...
 
void GeneratePrivateKey (RandomNumberGenerator &rng, byte *privateKey) const
 Generate private key in this domain. More...
 
void GeneratePublicKey (RandomNumberGenerator &rng, const byte *privateKey, byte *publicKey) const
 Generate a public key from a private key in this domain. More...
 
bool Agree (byte *agreedValue, const byte *privateKey, const byte *otherPublicKey, bool validateOtherPublicKey=true) const
 Derive agreed value. More...
 
const IntegerGetModulus () const
 
const IntegerGetSubgroupOrder () const
 
const GFP2ElementGetSubgroupGenerator () const
 
void SetModulus (const Integer &p)
 
void SetSubgroupOrder (const Integer &q)
 
void SetSubgroupGenerator (const GFP2Element &g)
 
- Public Member Functions inherited from SimpleKeyAgreementDomain
virtual ~SimpleKeyAgreementDomain ()
 
virtual void GenerateKeyPair (RandomNumberGenerator &rng, byte *privateKey, byte *publicKey) const
 Generate a private/public key pair. More...
 
- Public Member Functions inherited from KeyAgreementAlgorithm
virtual ~KeyAgreementAlgorithm ()
 
CryptoMaterialAccessMaterial ()
 Retrieves a reference to Crypto Parameters. More...
 
const CryptoMaterialGetMaterial () const
 Retrieves a reference to Crypto Parameters. More...
 
virtual const CryptoParametersGetCryptoParameters () const
 Retrieves a reference to Crypto Parameters. More...
 
- Public Member Functions inherited from AsymmetricAlgorithm
virtual ~AsymmetricAlgorithm ()
 
void BERDecode (BufferedTransformation &bt)
 Loads this object from a BufferedTransformation. More...
 
void DEREncode (BufferedTransformation &bt) const
 Saves this object to a BufferedTransformation. More...
 
- Public Member Functions inherited from Algorithm
virtual ~Algorithm ()
 
 Algorithm (bool checkSelfTestStatus=true)
 Interface for all crypto algorithms. More...
 
virtual std::string AlgorithmName () const
 Provides the name of this algorithm. More...
 
- Public Member Functions inherited from Clonable
virtual ~Clonable ()
 
virtual ClonableClone () const
 Copies this object. More...
 
- Public Member Functions inherited from GeneratableCryptoMaterial
virtual ~GeneratableCryptoMaterial ()
 
virtual void GenerateRandom (RandomNumberGenerator &rng, const NameValuePairs &params=g_nullNameValuePairs)
 Generate a random key or crypto parameters. More...
 
void GenerateRandomWithKeySize (RandomNumberGenerator &rng, unsigned int keySize)
 Generate a random key or crypto parameters. More...
 
- Public Member Functions inherited from CryptoMaterial
virtual ~CryptoMaterial ()
 
virtual void ThrowIfInvalid (RandomNumberGenerator &rng, unsigned int level) const
 Check this object for errors. More...
 
virtual void Save (BufferedTransformation &bt) const
 Saves a key to a BufferedTransformation. More...
 
virtual void Load (BufferedTransformation &bt)
 Loads a key from a BufferedTransformation. More...
 
virtual bool SupportsPrecomputation () const
 Determines whether the object supports precomputation. More...
 
virtual void Precompute (unsigned int precomputationStorage)
 Perform precomputation. More...
 
virtual void LoadPrecomputation (BufferedTransformation &storedPrecomputation)
 Retrieve previously saved precomputation. More...
 
virtual void SavePrecomputation (BufferedTransformation &storedPrecomputation) const
 Save precomputation for later use. More...
 
void DoQuickSanityCheck () const
 Perform a quick sanity check. More...
 
- Public Member Functions inherited from NameValuePairs
virtual ~NameValuePairs ()
 
template<class T >
bool GetThisObject (T &object) const
 Get a copy of this object or subobject. More...
 
template<class T >
bool GetThisPointer (T *&ptr) const
 Get a pointer to this object. More...
 
template<class T >
bool GetValue (const char *name, T &value) const
 Get a named value. More...
 
template<class T >
T GetValueWithDefault (const char *name, T defaultValue) const
 Get a named value. More...
 
CRYPTOPP_DLL std::string GetValueNames () const
 Get a list of value names that can be retrieved. More...
 
CRYPTOPP_DLL bool GetIntValue (const char *name, int &value) const
 Get a named value with type int. More...
 
CRYPTOPP_DLL int GetIntValueWithDefault (const char *name, int defaultValue) const
 Get a named value with type int, with default. More...
 
template<class T >
void GetRequiredParameter (const char *className, const char *name, T &value) const
 Retrieves a required name/value pair. More...
 
CRYPTOPP_DLL void GetRequiredIntParameter (const char *className, const char *name, int &value) const
 Retrieves a required name/value pair. More...
 

Private Types

typedef XTR_DH ThisClass
 

Private Member Functions

unsigned int ExponentBitLength () const
 

Private Attributes

Integer m_p
 
Integer m_q
 
GFP2Element m_g
 

Additional Inherited Members

- Static Public Member Functions inherited from NameValuePairs
static CRYPTOPP_DLL void CRYPTOPP_API ThrowIfTypeMismatch (const char *name, const std::type_info &stored, const std::type_info &retrieving)
 Ensures an expected name and type is present. More...
 

Detailed Description

XTR-DH with key validation.

Definition at line 16 of file xtrcrypt.h.

Member Typedef Documentation

typedef XTR_DH XTR_DH::ThisClass
private

Definition at line 18 of file xtrcrypt.h.

Constructor & Destructor Documentation

XTR_DH::XTR_DH ( const Integer p,
const Integer q,
const GFP2Element g 
)

Definition at line 14 of file xtrcrypt.cpp.

XTR_DH::XTR_DH ( RandomNumberGenerator rng,
unsigned int  pbits,
unsigned int  qbits 
)

Definition at line 19 of file xtrcrypt.cpp.

Here is the call graph for this function:

XTR_DH::XTR_DH ( BufferedTransformation domainParams)

Definition at line 24 of file xtrcrypt.cpp.

Here is the call graph for this function:

Member Function Documentation

CryptoParameters& XTR_DH::AccessCryptoParameters ( )
inlinevirtual

Retrieves a reference to Crypto Parameters.

Returns
a reference the crypto parameters

Implements KeyAgreementAlgorithm.

Definition at line 30 of file xtrcrypt.h.

bool XTR_DH::Agree ( byte agreedValue,
const byte privateKey,
const byte otherPublicKey,
bool  validateOtherPublicKey = true 
) const
virtual

Derive agreed value.

Parameters
agreedValuea byte buffer for the shared secret
privateKeya byte buffer with your private key in this domain
otherPublicKeya byte buffer with the other party's public key in this domain
validateOtherPublicKeya flag indicating if the other party's public key should be validated
Returns
true upon success, false in case of failure

Agree() derives an agreed value from your private keys and couterparty's public keys.

The other party's public key is validated by default. If you have previously validated the static public key, use validateStaticOtherPublicKey=false to save time.

Precondition
COUNTOF(agreedValue) == AgreedValueLength()
COUNTOF(privateKey) == PrivateKeyLength()
COUNTOF(otherPublicKey) == PublicKeyLength()

Implements SimpleKeyAgreementDomain.

Definition at line 94 of file xtrcrypt.cpp.

Here is the call graph for this function:

unsigned int XTR_DH::AgreedValueLength ( ) const
inlinevirtual

Provides the size of the agreed value.

Returns
size of agreed value produced in this domain

Implements SimpleKeyAgreementDomain.

Definition at line 31 of file xtrcrypt.h.

Here is the caller graph for this function:

void XTR_DH::AssignFrom ( const NameValuePairs source)
virtual

Assign values to this object.

This function can be used to create a public key from a private key.

Implements CryptoMaterial.

Definition at line 71 of file xtrcrypt.cpp.

Here is the call graph for this function:

void XTR_DH::DEREncode ( BufferedTransformation domainParams) const

Definition at line 34 of file xtrcrypt.cpp.

Here is the call graph for this function:

unsigned int XTR_DH::ExponentBitLength ( ) const
private
void XTR_DH::GeneratePrivateKey ( RandomNumberGenerator rng,
byte privateKey 
) const
virtual

Generate private key in this domain.

Parameters
rnga RandomNumberGenerator derived class
privateKeya byte buffer for the generated private key in this domain
Precondition
COUNTOF(privateKey) == PrivateKeyLength()

Implements SimpleKeyAgreementDomain.

Definition at line 80 of file xtrcrypt.cpp.

Here is the call graph for this function:

void XTR_DH::GeneratePublicKey ( RandomNumberGenerator rng,
const byte privateKey,
byte publicKey 
) const
virtual

Generate a public key from a private key in this domain.

Parameters
rnga RandomNumberGenerator derived class
privateKeya byte buffer with the previously generated private key
publicKeya byte buffer for the generated public key in this domain
Precondition
COUNTOF(publicKey) == PublicKeyLength()

Implements SimpleKeyAgreementDomain.

Definition at line 86 of file xtrcrypt.cpp.

Here is the call graph for this function:

const Integer& XTR_DH::GetModulus ( ) const
inline

Definition at line 39 of file xtrcrypt.h.

const GFP2Element& XTR_DH::GetSubgroupGenerator ( ) const
inline

Definition at line 41 of file xtrcrypt.h.

const Integer& XTR_DH::GetSubgroupOrder ( ) const
inline

Definition at line 40 of file xtrcrypt.h.

bool XTR_DH::GetVoidValue ( const char *  name,
const std::type_info &  valueType,
void *  pValue 
) const
virtual

Get a named value.

Parameters
namethe name of the object or value to retrieve
valueTypereference to a variable that receives the value
pValuevoid pointer to a variable that receives the value
Returns
true if the value was retrieved, false otherwise

GetVoidValue() retrieves the value of name if it exists.

Note
GetVoidValue() is an internal function and should be implemented by derived classes. Users should use one of the other functions instead.
See also
GetValue(), GetValueWithDefault(), GetIntValue(), GetIntValueWithDefault(), GetRequiredParameter() and GetRequiredIntParameter()

Implements NameValuePairs.

Definition at line 62 of file xtrcrypt.cpp.

Here is the call graph for this function:

unsigned int XTR_DH::PrivateKeyLength ( ) const
inlinevirtual

Provides the size of the private key.

Returns
size of private keys in this domain

Implements SimpleKeyAgreementDomain.

Definition at line 32 of file xtrcrypt.h.

Here is the caller graph for this function:

unsigned int XTR_DH::PublicKeyLength ( ) const
inlinevirtual

Provides the size of the public key.

Returns
size of public keys in this domain

Implements SimpleKeyAgreementDomain.

Definition at line 33 of file xtrcrypt.h.

Here is the caller graph for this function:

void XTR_DH::SetModulus ( const Integer p)
inline

Definition at line 43 of file xtrcrypt.h.

void XTR_DH::SetSubgroupGenerator ( const GFP2Element g)
inline

Definition at line 45 of file xtrcrypt.h.

void XTR_DH::SetSubgroupOrder ( const Integer q)
inline

Definition at line 44 of file xtrcrypt.h.

bool XTR_DH::Validate ( RandomNumberGenerator rng,
unsigned int  level 
) const
virtual

Check this object for errors.

Parameters
rnga RandomNumberGenerator for objects which use randomized testing
levelthe level of thoroughness
Returns
true if the tests succeed, false otherwise

There are four levels of thoroughness:

  • 0 - using this object won't cause a crash or exception
  • 1 - this object will probably function, and encrypt, sign, other operations correctly
  • 2 - ensure this object will function correctly, and perform reasonable security checks
  • 3 - perform reasonable security checks, and do checks that may take a long time

Level 0 does not require a RandomNumberGenerator. A NullRNG() can be used for level 0. Level 1 may not check for weak keys and such. Levels 2 and 3 are recommended.

See also
ThrowIfInvalid()

Implements CryptoMaterial.

Definition at line 44 of file xtrcrypt.cpp.

Here is the call graph for this function:

Member Data Documentation

GFP2Element XTR_DH::m_g
private

Definition at line 51 of file xtrcrypt.h.

Integer XTR_DH::m_p
private

Definition at line 50 of file xtrcrypt.h.

Integer XTR_DH::m_q
private

Definition at line 50 of file xtrcrypt.h.


The documentation for this class was generated from the following files: