Crypto++ 7.0 Free C++ class library of cryptographic schemes

Public Types | Public Member Functions | List of all members
DL_GroupParameters< T > Class Template Referenceabstract

Interface for Discrete Log (DL) group parameters. More...

Inheritance diagram for DL_GroupParameters< T >:

## Public Types
typedef T | Element

## Public Member Functions
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...
bool | SupportsPrecomputation () const
| Determines whether the object supports precomputation. More...
void | Precompute (unsigned int precomputationStorage=16)
| Perform precomputation. More...
void | LoadPrecomputation (BufferedTransformation &storedPrecomputation)
| Retrieve previously saved precomputation. More...
void | SavePrecomputation (BufferedTransformation &storedPrecomputation) const
| Save precomputation for later use. More...
virtual const Element & | GetSubgroupGenerator () const
| Retrieves the subgroup generator. More...
virtual void | SetSubgroupGenerator (const Element &base)
| Sets the subgroup generator. More...
virtual Element | ExponentiateBase (const Integer &exponent) const
| Exponentiates the base. More...
virtual Element | ExponentiateElement (const Element &base, const Integer &exponent) const
| Exponentiates an element. More...
virtual const DL_GroupPrecomputation< Element > & | GetGroupPrecomputation () const =0
| Retrieves the group precomputation. More...
virtual const DL_FixedBasePrecomputation< Element > & | GetBasePrecomputation () const =0
| Retrieves the group precomputation. More...
virtual DL_FixedBasePrecomputation< Element > & | AccessBasePrecomputation ()=0
| Retrieves the group precomputation. More...
virtual const Integer & | GetSubgroupOrder () const =0
| Retrieves the subgroup order. More...
virtual Integer | GetMaxExponent () const =0
| Retrieves the maximum exponent for the group. More...
virtual Integer | GetGroupOrder () const
| Retrieves the order of the group. More...
virtual Integer | GetCofactor () const
| Retrieves the cofactor. More...
virtual unsigned int | GetEncodedElementSize (bool reversible) const =0
| Retrieves the encoded element's size. More...
virtual void | EncodeElement (bool reversible, const Element &element, byte *encoded) const =0
| Encodes the element. More...
virtual Element | DecodeElement (const byte *encoded, bool checkForGroupMembership) const =0
| Decodes the element. More...
virtual Integer | ConvertElementToInteger (const Element &element) const =0
| Converts an element to an Integer. More...
virtual bool | ValidateGroup (RandomNumberGenerator &rng, unsigned int level) const =0
| Check the group for errors. More...
virtual bool | ValidateElement (unsigned int level, const Element &element, const DL_FixedBasePrecomputation< Element > *precomp) const =0
| Check the element for errors. More...
virtual bool | FastSubgroupCheckAvailable () const =0
virtual bool | IsIdentity (const Element &element) const =0
| Determines if an element is an identity. More...
virtual void | SimultaneousExponentiate (Element *results, const Element &base, const Integer *exponents, unsigned int exponentsCount) const =0
| Exponentiates a base to multiple exponents. More...
Public Member Functions inherited from 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 void | AssignFrom (const NameValuePairs &source)=0
| Assign values to this object. More...
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...
void | DoQuickSanityCheck () const
| Perform a quick sanity check. More...
Public Member Functions inherited from 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...
std::string | GetValueNames () const
| Get a list of value names that can be retrieved. More...
bool | GetIntValue (const char *name, int &value) const
| Get a named value with type int. More...
int | GetIntValueWithDefault (const char *name, int defaultValue) const
| Get a named value with type int, with default. More...
bool | GetWord64Value (const char *name, word64 &value) const
| Get a named value with type word64. More...
word64 | GetWord64ValueWithDefault (const char *name, word64 defaultValue) const
| Get a named value with type word64, with default. More...
template<class T >
void | GetRequiredParameter (const char *className, const char *name, T &value) const
| Retrieves a required name/value pair. More...
void | GetRequiredIntParameter (const char *className, const char *name, int &value) const
| Retrieves a required name/value pair. More...

## Additional Inherited Members
Static Public Member Functions inherited from NameValuePairs
static void | 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

### template<class T>
class DL_GroupParameters< T >

Interface for Discrete Log (DL) group parameters.

Template Parameters

  T | element in the group

The element is usually an Integer, ECP::Point or EC2N::Point

Definition at line 753 of file pubkey.h.

## Member Function Documentation

## ◆ Validate()

template<class T>

bool DL_GroupParameters< T >::Validate | ( | RandomNumberGenerator & | rng,
|  | unsigned int | level
| ) |  | const
| inline virtual

Check this object for errors.

Parameters

  rng | a RandomNumberGenerator for objects which use randomized testing
  level | the 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 765 of file pubkey.h.

## ◆ GetVoidValue()

template<class T>

bool DL_GroupParameters< T >::GetVoidValue | ( | const char * | name,
|  | const std::type_info & | valueType,
|  | void * | pValue
| ) |  | const
| inline virtual

Get a named value.

Parameters

  name | the name of the object or value to retrieve
  valueType | reference to a variable that receives the value
  pValue | void 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 781 of file pubkey.h.

## ◆ SupportsPrecomputation()

template<class T>

bool DL_GroupParameters< T >::SupportsPrecomputation | ( |  | ) | const
| inline virtual

Determines whether the object supports precomputation.

Returns
  true if the object supports precomputation, false otherwise

See also
  Precompute()

Reimplemented from CryptoMaterial.

Definition at line 792 of file pubkey.h.

## ◆ Precompute()

template<class T>

void DL_GroupParameters< T >::Precompute | ( | unsigned int | precomputationStorage = `16` | ) |
| inline virtual

Perform precomputation.

Parameters

  precomputationStorage | the suggested number of objects for the precompute table

Exceptions

  NotImplemented |

The exact semantics of Precompute() varies, but it typically means calculate a table of n objects that can be used later to speed up computation.

If a derived class does not override Precompute(), then the base class throws NotImplemented.

See also
  SupportsPrecomputation(), LoadPrecomputation(), SavePrecomputation()

Reimplemented from CryptoMaterial.

Definition at line 802 of file pubkey.h.

## ◆ LoadPrecomputation()

template<class T>

void DL_GroupParameters< T >::LoadPrecomputation | ( | BufferedTransformation & | storedPrecomputation | ) |
| inline virtual

Retrieve previously saved precomputation.

Parameters

  storedPrecomputation | BufferedTransformation with the saved precomputation

Exceptions

  NotImplemented |

See also
  SupportsPrecomputation(), Precompute()

Reimplemented from CryptoMaterial.

Definition at line 811 of file pubkey.h.

## ◆ SavePrecomputation()

template<class T>

void DL_GroupParameters< T >::SavePrecomputation | ( | BufferedTransformation & | storedPrecomputation | ) | const
| inline virtual

Save precomputation for later use.

Parameters

  storedPrecomputation | BufferedTransformation to write the precomputation

Exceptions

  NotImplemented |

See also
  SupportsPrecomputation(), Precompute()

Reimplemented from CryptoMaterial.

Definition at line 821 of file pubkey.h.

## ◆ GetSubgroupGenerator()

template<class T>

virtual const Element& DL_GroupParameters< T >::GetSubgroupGenerator | ( |  | ) | const
| inline virtual

Retrieves the subgroup generator.

Returns
  the subgroup generator

The subgroup generator is retrieved from the base precomputation

Definition at line 829 of file pubkey.h.

## ◆ SetSubgroupGenerator()

template<class T>

virtual void DL_GroupParameters< T >::SetSubgroupGenerator | ( | const Element & | base | ) |
| inline virtual

Sets the subgroup generator.

Parameters

  base | the new subgroup generator

The subgroup generator is set in the base precomputation

Definition at line 834 of file pubkey.h.

## ◆ ExponentiateBase()

template<class T>

virtual Element DL_GroupParameters< T >::ExponentiateBase | ( | const Integer & | exponent | ) | const
| inline virtual

Exponentiates the base.

Returns
  the element after exponentiation

ExponentiateBase() calls GetBasePrecomputation() and then exponentiates.

Definition at line 839 of file pubkey.h.

## ◆ ExponentiateElement()

template<class T>

virtual Element DL_GroupParameters< T >::ExponentiateElement | ( | const Element & | base,
|  | const Integer & | exponent
| ) |  | const
| inline virtual

Exponentiates an element.

Parameters

  base | the base elemenet
  exponent | the exponent to raise the base

Returns
  the result of the exponentiation

Internally, ExponentiateElement() calls SimultaneousExponentiate().

Definition at line 849 of file pubkey.h.

## ◆ GetGroupPrecomputation()

template<class T>

virtual const DL_GroupPrecomputation<Element>& DL_GroupParameters< T >::GetGroupPrecomputation | ( |  | ) | const
| pure virtual

Retrieves the group precomputation.

Returns
  a const reference to the group precomputation

Implemented in DL_GroupParametersImpl< EcPrecomputation< EC > >, DL_GroupParametersImpl< ModExpPrecomputation, DL_FixedBasePrecomputationImpl< typename ModExpPrecomputation ::Element >, DL_GroupParameters_IntegerBased >, DL_GroupParametersImpl< GROUP_PRECOMP, BASE_PRECOMP, DL_GroupParameters_IntegerBased >, and DL_GroupParametersImpl< DL_GroupPrecomputation_LUC, DL_BasePrecomputation_LUC, DL_GroupParameters_IntegerBased >.

## ◆ GetBasePrecomputation()

template<class T>

virtual const DL_FixedBasePrecomputation<Element>& DL_GroupParameters< T >::GetBasePrecomputation | ( |  | ) | const
| pure virtual

Retrieves the group precomputation.

Returns
  a const reference to the group precomputation using a fixed base

Implemented in DL_GroupParametersImpl< EcPrecomputation< EC > >, DL_GroupParametersImpl< ModExpPrecomputation, DL_FixedBasePrecomputationImpl< typename ModExpPrecomputation ::Element >, DL_GroupParameters_IntegerBased >, DL_GroupParametersImpl< GROUP_PRECOMP, BASE_PRECOMP, DL_GroupParameters_IntegerBased >, DL_GroupParametersImpl< DL_GroupPrecomputation_LUC, DL_BasePrecomputation_LUC, DL_GroupParameters_IntegerBased >, DL_GroupParameters_IntegerBasedImpl< GROUP_PRECOMP, BASE_PRECOMP >, DL_GroupParameters_IntegerBasedImpl< DL_GroupPrecomputation_LUC, DL_BasePrecomputation_LUC >, DL_GroupParameters_IntegerBasedImpl< ModExpPrecomputation >, and DL_GroupParameters_EC< EC >.

## ◆ AccessBasePrecomputation()

template<class T>

virtual DL_FixedBasePrecomputation<Element>& DL_GroupParameters< T >::AccessBasePrecomputation | ( |  | ) |
| pure virtual

Retrieves the group precomputation.

Returns
  a non-const reference to the group precomputation using a fixed base

Implemented in DL_GroupParametersImpl< EcPrecomputation< EC > >, DL_GroupParametersImpl< ModExpPrecomputation, DL_FixedBasePrecomputationImpl< typename ModExpPrecomputation ::Element >, DL_GroupParameters_IntegerBased >, DL_GroupParametersImpl< GROUP_PRECOMP, BASE_PRECOMP, DL_GroupParameters_IntegerBased >, DL_GroupParametersImpl< DL_GroupPrecomputation_LUC, DL_BasePrecomputation_LUC, DL_GroupParameters_IntegerBased >, DL_GroupParameters_IntegerBasedImpl< GROUP_PRECOMP, BASE_PRECOMP >, DL_GroupParameters_IntegerBasedImpl< DL_GroupPrecomputation_LUC, DL_BasePrecomputation_LUC >, DL_GroupParameters_IntegerBasedImpl< ModExpPrecomputation >, and DL_GroupParameters_EC< EC >.

## ◆ GetSubgroupOrder()

template<class T>

virtual const Integer& DL_GroupParameters< T >::GetSubgroupOrder | ( |  | ) | const
| pure virtual

Retrieves the subgroup order.

Returns
  the order of subgroup generated by the base element

Implemented in DL_GroupParameters_EC< EC >, and DL_GroupParameters_IntegerBased.

## ◆ GetMaxExponent()

template<class T>

virtual Integer DL_GroupParameters< T >::GetMaxExponent | ( |  | ) | const
| pure virtual

Retrieves the maximum exponent for the group.

Returns
  the maximum exponent for the group

Implemented in DL_GroupParameters_EC< EC >, and DL_GroupParameters_IntegerBased.

## ◆ GetGroupOrder()

template<class T>

virtual Integer DL_GroupParameters< T >::GetGroupOrder | ( |  | ) | const
| inline virtual

Retrieves the order of the group.

Returns
  the order of the group

Either GetGroupOrder() or GetCofactor() must be overridden in a derived class.

Reimplemented in DL_GroupParameters_IntegerBased.

Definition at line 879 of file pubkey.h.

## ◆ GetCofactor()

template<class T>

virtual Integer DL_GroupParameters< T >::GetCofactor | ( |  | ) | const
| inline virtual

Retrieves the cofactor.

Returns
  the cofactor

Either GetGroupOrder() or GetCofactor() must be overridden in a derived class.

Reimplemented in DL_GroupParameters_EC< EC >.

Definition at line 884 of file pubkey.h.

## ◆ GetEncodedElementSize()

template<class T>

virtual unsigned int DL_GroupParameters< T >::GetEncodedElementSize | ( | bool | reversible | ) | const
| pure virtual

Retrieves the encoded element's size.

Parameters

  reversible | flag indicating the encoding format

Returns
  encoded element's size, in bytes

The format of the encoded element varies by the underlyinhg type of the element and the reversible flag. GetEncodedElementSize() must be implemented in a derived class.

See also
  GetEncodedElementSize(), EncodeElement(), DecodeElement()

Implemented in DL_GroupParameters_EC< EC >, and DL_GroupParameters_IntegerBased.

## ◆ EncodeElement()

template<class T>

virtual void DL_GroupParameters< T >::EncodeElement | ( | bool | reversible,
|  | const Element & | element,
|  | byte * | encoded
| ) |  | const
| pure virtual

Encodes the element.

Parameters

  reversible | flag indicating the encoding format
  element | reference to the element to encode
  encoded | destination byte array for the encoded element

EncodeElement() must be implemented in a derived class.

Precondition
  `COUNTOF(encoded) == GetEncodedElementSize()`

## ◆ DecodeElement()

template<class T>

virtual Element DL_GroupParameters< T >::DecodeElement | ( | const byte * | encoded,
|  | bool | checkForGroupMembership
| ) |  | const
| pure virtual

Decodes the element.

Parameters

  encoded | byte array with the encoded element
  checkForGroupMembership | flag indicating if the element should be validated

Returns
  Element after decoding

DecodeElement() must be implemented in a derived class.

Precondition
  `COUNTOF(encoded) == GetEncodedElementSize()`

Implemented in DL_GroupParameters_EC< EC >, and DL_GroupParameters_IntegerBased.

## ◆ ConvertElementToInteger()

template<class T>

virtual Integer DL_GroupParameters< T >::ConvertElementToInteger | ( | const Element & | element | ) | const
| pure virtual

Converts an element to an Integer.

Parameters

  element | the element to convert to an Integer

Returns
  Element after converting to an Integer

ConvertElementToInteger() must be implemented in a derived class.

Implemented in DL_GroupParameters_IntegerBased.

## ◆ ValidateGroup()

template<class T>

virtual bool DL_GroupParameters< T >::ValidateGroup | ( | RandomNumberGenerator & | rng,
|  | unsigned int | level
| ) |  | const
| pure virtual

Check the group for errors.

Parameters

  rng | RandomNumberGenerator for objects which use randomized testing
  level | 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.

ValidateGroup() must be implemented in a derived class.

Implemented in DL_GroupParameters_DSA, DL_GroupParameters_EC< EC >, and DL_GroupParameters_IntegerBased.

## ◆ ValidateElement()

template<class T>

virtual bool DL_GroupParameters< T >::ValidateElement | ( | unsigned int | level,
|  | const Element & | element,
|  | const DL_FixedBasePrecomputation< Element > * | precomp
| ) |  | const
| pure virtual

Check the element for errors.

Parameters

  level | level of thoroughness
  element | element to check
  precomp | optional pointer to DL_FixedBasePrecomputation

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 performs group membership checks. Level 1 may not check for weak keys and such. Levels 2 and 3 are recommended.

ValidateElement() must be implemented in a derived class.

Implemented in DL_GroupParameters_IntegerBased.

## ◆ IsIdentity()

template<class T>

virtual bool DL_GroupParameters< T >::IsIdentity | ( | const Element & | element | ) | const
| pure virtual

Determines if an element is an identity.

Parameters

  element | element to check

Returns
  true if the element is an identity, false otherwise

The identity element or or neutral element is a special element in a group that leaves other elements unchanged when combined with it.

IsIdentity() must be implemented in a derived class.

Implemented in DL_GroupParameters_LUC, and DL_GroupParameters_GFP.

## ◆ SimultaneousExponentiate()

template<class T>

virtual void DL_GroupParameters< T >::SimultaneousExponentiate | ( | Element * | results,
|  | const Element & | base,
|  | const Integer * | exponents,
|  | unsigned int | exponentsCount
| ) |  | const
| pure virtual

Exponentiates a base to multiple exponents.

Parameters

  results | an array of Elements
  base | the base to raise to the exponents
  exponents | an array of exponents
  exponentsCount | the number of exponents in the array

SimultaneousExponentiate() raises the base to each exponent in the exponents array and stores the result at the respective position in the results array.

SimultaneousExponentiate() must be implemented in a derived class.

Precondition
  `COUNTOF(results) == exponentsCount`
  `COUNTOF(exponents) == exponentsCount`

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

- pubkey.h