KeccakTools
|
#include <Keccak-fAffineBases.h>
Public Member Functions | |
AffineSpaceOfStates (unsigned int aLaneSize, vector< vector< SliceValue > > &aGenerators, vector< PackedParity > &aGeneratorParities, const vector< SliceValue > &aOffset, PackedParity aOffsetParity) | |
AffineSpaceOfStates (unsigned int aLaneSize, vector< vector< SliceValue > > &aGenerators, vector< vector< RowValue > > &aGeneratorParities, const vector< SliceValue > &aOffset, const vector< RowValue > &aOffsetParity) | |
bool | getOffsetWithGivenParity (PackedParity parity, vector< SliceValue > &output) const |
bool | getOffsetWithGivenParity (const vector< RowValue > &parity, vector< SliceValue > &output) const |
SlicesAffineSpaceIterator | getIterator () const |
SlicesAffineSpaceIterator | getIteratorWithGivenParity (PackedParity parity) const |
SlicesAffineSpaceIterator | getIteratorWithGivenParity (const vector< RowValue > &parity) const |
SlicesAffineSpaceIterator | getIteratorInKernel () const |
void | display (ostream &fout) const |
Public Attributes | |
vector< vector< SliceValue > > | originalGenerators |
vector< vector< RowValue > > | originalParities |
vector< vector< SliceValue > > | kernelGenerators |
vector< vector< SliceValue > > | offsetGenerators |
vector< PackedParity > | offsetParitiesPacked |
vector< vector< RowValue > > | offsetParities |
vector< SliceValue > | offset |
PackedParity | offsetParityPacked |
vector< RowValue > | offsetParity |
bool | packed |
Protected Attributes | |
unsigned int | laneSize |
This class expresses an affine space of states. The members of the affine space are determined by the offset plus any linear combination of the generators. The generators are split into two sets:
AffineSpaceOfStates::AffineSpaceOfStates | ( | unsigned int | aLaneSize, |
vector< vector< SliceValue > > & | aGenerators, | ||
vector< PackedParity > & | aGeneratorParities, | ||
const vector< SliceValue > & | aOffset, | ||
PackedParity | aOffsetParity | ||
) |
This constructor initializes the different attributes from the given generators, the offset and their parities. This function is to be called only if the number of slices is low enough so that PackedParity can contain all the parities.
aLaneSize | The lane size. |
aGenerators | The set of generators of the affine space, each given as a vector of slices. |
aGeneratorParities | The corresponding parities, each given in a PackedParity type. |
aOffset | The offset of the affine space, as a vector of slices. |
aOffsetParity | The parity of the offset, given in a PackedParity type. |
AffineSpaceOfStates::AffineSpaceOfStates | ( | unsigned int | aLaneSize, |
vector< vector< SliceValue > > & | aGenerators, | ||
vector< vector< RowValue > > & | aGeneratorParities, | ||
const vector< SliceValue > & | aOffset, | ||
const vector< RowValue > & | aOffsetParity | ||
) |
This constructor initializes the different attributes from the given generators, the offset and their parities.
aLaneSize | The lane size. |
aGenerators | The set of generators of the affine space, each given as a vector of slices. |
aGeneratorParities | The corresponding parities, each given as a vector of rows. |
aOffset | The offset of the affine space, as a vector of slices. |
aOffsetParity | The parity of the offset, given as a vector of rows. |
void AffineSpaceOfStates::display | ( | ostream & | fout | ) | const |
This method displays the offset and generators.
fout | The stream to display to. |
SlicesAffineSpaceIterator AffineSpaceOfStates::getIterator | ( | ) | const |
This method returns an iterator to all states in the affine space.
SlicesAffineSpaceIterator AffineSpaceOfStates::getIteratorInKernel | ( | ) | const |
Like getIteratorWithGivenParity() with the requested parity being zero.
SlicesAffineSpaceIterator AffineSpaceOfStates::getIteratorWithGivenParity | ( | const vector< RowValue > & | parity | ) | const |
This method returns an iterator to the affine space restricted to a given parity. In the returned iterator, its offset is computed as in method getOffsetWithGivenParity() and its generators are the parity-kernel generators.
parity | The requested parity. |
SlicesAffineSpaceIterator AffineSpaceOfStates::getIteratorWithGivenParity | ( | PackedParity | parity | ) | const |
This method returns an iterator to the affine space restricted to a given parity. In the returned iterator, its offset is computed as in method getOffsetWithGivenParity() and its generators are the parity-kernel generators.
parity | The requested parity. |
bool AffineSpaceOfStates::getOffsetWithGivenParity | ( | PackedParity | parity, |
vector< SliceValue > & | output | ||
) | const |
This method returns a state value (in argument output) with a given parity. From the offset and the parity-offset generators of the affine space, this method computes an element that has the given parity. (Note that other elements with the same parity can be generated by adding any linear combination of parity-kernel generators.) If the given parity cannot be reached, false is returned.
parity | The requested parity. |
output | The state returned by the method with the requested parity, if possible. |
bool AffineSpaceOfStates::getOffsetWithGivenParity | ( | const vector< RowValue > & | parity, |
vector< SliceValue > & | output | ||
) | const |
This method returns a state value (in argument output) with a given parity. From the offset and the parity-offset generators of the affine space, this method computes an element that has the given parity. (Note that other elements with the same parity can be generated by adding any linear combination of parity-kernel generators.) If the given parity cannot be reached, false is returned.
parity | The requested parity. |
output | The state returned by the method with the requested parity, if possible. |
vector<vector<SliceValue> > AffineSpaceOfStates::kernelGenerators |
The set of parity-kernel generators of the affine space.
unsigned int AffineSpaceOfStates::laneSize [protected] |
The lane size.
The offset of the affine space.
vector<vector<SliceValue> > AffineSpaceOfStates::offsetGenerators |
The set of parity-offset generators of the affine space. This can be used to generate an offset for a given parity. The parity-offset generators are organized such that their parity makes an upper-triangular matrix. In other words, whenever a generator has parity bit n set to 1 and parity bits m<n set to 0, the next generators necessarily have parity bits m<=n set to 0.
vector<vector<RowValue> > AffineSpaceOfStates::offsetParities |
If packed is false, this vector contains the parities of offsetGenerators, i.e., offsetParities[i] contains the parity of offsetGenerators[i].
If packed is true, this vector contains the parities of offsetGenerators, i.e., offsetParitiesPacked[i] contains the parity of offsetGenerators[i].
If packed is false, the parity of the offset of the affine space.
If packed is true, the parity of the offset of the affine space.
vector<vector<SliceValue> > AffineSpaceOfStates::originalGenerators |
The set of generators, before separation into parity-kernel and parity-offset sets.
vector<vector<RowValue> > AffineSpaceOfStates::originalParities |
The set of parities, before separation into parity-kernel and parity-offset sets, i.e., originalParities[i] contains the parity of originalGenerators[i].
This attribute indicates whether we are using the packed parities or not.