Experimentally implement matrix-mult

This commit is contained in:
Leonetienne
2022-05-23 22:42:14 +02:00
parent 3819fbe693
commit ed45b69342
5 changed files with 168 additions and 4 deletions

View File

@@ -0,0 +1,49 @@
#ifndef GCRYPT_BLOCKMATRIX_H
#define GCRYPT_BLOCKMATRIX_H
#include "GCrypt/Block.h"
#include <cstdint>
#include <array>
namespace Leonetienne::GCrypt {
/* This class represents a block as a matrix,
* providing typical matrix operations
*/
class BlockMatrix {
public:
BlockMatrix();
BlockMatrix(const Block& block);
BlockMatrix(const BlockMatrix& other);
//! Will calculate the product of two matrices.
//! Since the matrices values are pretty much sudo-random,
//! they will most likely integer-overflow.
//! So see this as a one-way function.
BlockMatrix MMult(const BlockMatrix& other) const;
BlockMatrix operator*(const BlockMatrix& other) const;
//! Will do a regular matrix-mult, but instead of
//! adding, and multiplying, all ints get xored.
BlockMatrix MXor(const BlockMatrix& other) const;
bool operator==(const BlockMatrix& other) const;
bool operator!=(const BlockMatrix& other) const;
void FromBlock(const Block& block);
Block ToBlock() const;
private:
//! Returns items of data, indexed by 4x4 coordinates
std::uint32_t& Get(const std::uint8_t row, const std::uint8_t column);
//! Returns items of data, indexed by 4x4 coordinates
const std::uint32_t& Get(const std::uint8_t row, const std::uint8_t column) const;
std::array<std::uint32_t, 16> data;
};
}
#endif

View File

@@ -8,7 +8,7 @@ namespace Leonetienne::GCrypt {
constexpr std::size_t BLOCK_SIZE = 512;
// MUST BE > 2
constexpr std::size_t N_ROUNDS = 400;
constexpr std::size_t N_ROUNDS = 10;
}
#endif

View File

@@ -1,7 +1,7 @@
#ifndef GCRYPT_VERSION_H
#define GCRYPT_VERSION_H
#define GCRYPT_VERSION 0.23
#define GCRYPT_VERSION 0.231
#endif