MOTION  0.01
Framework for mixed-protocol multi-party computation
Public Member Functions | Static Public Member Functions | List of all members
encrypto::motion::BitMatrix Class Reference

#include <bit_matrix.h>

Public Member Functions

 BitMatrix ()=default
 
 BitMatrix (std::size_t rows, std::size_t columns, bool value=false)
 Construct a rows x columns BitMatrix with all bits set to value. More...
 
 BitMatrix (std::vector< AlignedBitVector > &&vectors)
 Construct a BitMatrix by moving a vector of AlignedBitVectors. More...
 
 BitMatrix (const std::vector< AlignedBitVector > &vectors)
 Construct a BitMatrix by copying a vector of AlignedBitVectors. More...
 
 BitMatrix (const BitMatrix &other)
 
 BitMatrix (BitMatrix &&other)
 
void operator= (const BitMatrix &other)
 
void operator= (BitMatrix &&other)
 
const AlignedBitVectorGetRow (std::size_t i) const
 Returns a const AlignedBitVector reference to row i of the matrix. More...
 
AlignedBitVectorGetMutableRow (std::size_t i)
 Returns a mutable AlignedBitVector reference to row i of the matrix. More...
 
bool Get (std::size_t row_i, std::size_t column_i) const
 Get Bit at input position. More...
 
void Set (std::size_t row_i, std::size_t column_i, bool value)
 Set or unset bit at input position. More...
 
void AppendRow (const AlignedBitVector &bit_vector)
 Appends a new row by copying the input bit_vector to the matrix. More...
 
void AppendRow (AlignedBitVector &&bit_vector)
 Appends a new row by moving the input bit_vector to the matrix. More...
 
void AppendColumn (const AlignedBitVector &bit_vector)
 Appends a new column by copying the input bit_vector to the matrix. More...
 
void AppendColumn (AlignedBitVector &&bit_vector)
 Appends a new column by moving the input bit_vector to the matrix. More...
 
std::string AsString () const
 Return a string representation of the BitMatrix. More...
 
void ForceSetNumColumns (std::size_t n)
 Force the number of columns to be equal to n. More...
 
void Transpose ()
 Transposes the matrix inplace. More...
 
void Transpose128Rows ()
 Transposes a matrix with exactly 128 rows (faster). More...
 
bool operator== (const BitMatrix &other) const
 Compare with another BitMatrix for equality. More...
 
bool operator!= (const BitMatrix &other) const
 Compare with another BitMatrix for inequality. More...
 
auto GetNumRows () const noexcept
 Get number of rows in the BitMatrix. More...
 
auto GetNumColumns () const noexcept
 Get number of columns in the BitMatrix. More...
 

Static Public Member Functions

static void Transpose128RowsInplace (std::array< std::byte *, 128 > &matrix, std::size_t number_of_columns)
 Transposes a matrix of 128 rows and arbitrary column size inplace. More...
 
static void TransposeUsingBitSlicing (std::array< std::byte *, 128 > &matrix, std::size_t number_of_columns)
 Transposes a matrix of 128 rows and arbitrary column size inplace using BitSlicing. More...
 
static void SenderTransposeAndEncrypt (const std::array< const std::byte *, 128 > &matrix, std::vector< BitVector<>> &y0, std::vector< BitVector<>> &y1, const BitVector<> choices, primitives::Prg &prg_fixed_key, const std::size_t number_of_columns, const std::vector< std::size_t > &bitlengths)
 Transposes a matrix of 128 rows and arbitrary column size and encrypts it for the sender role. More...
 
static void ReceiverTransposeAndEncrypt (const std::array< const std::byte *, 128 > &matrix, std::vector< BitVector<>> &output, primitives::Prg &prg_fixed_key, const std::size_t number_of_columns, const std::vector< std::size_t > &bitlengths)
 Transposes a matrix of 128 rows and arbitrary column size and encrypts it for the recepient role. More...
 

Constructor & Destructor Documentation

◆ BitMatrix() [1/6]

encrypto::motion::BitMatrix::BitMatrix ( )
default

◆ BitMatrix() [2/6]

encrypto::motion::BitMatrix::BitMatrix ( std::size_t  rows,
std::size_t  columns,
bool  value = false 
)
inline

Construct a rows x columns BitMatrix with all bits set to value.

Parameters
rows
columns
value

◆ BitMatrix() [3/6]

encrypto::motion::BitMatrix::BitMatrix ( std::vector< AlignedBitVector > &&  vectors)
inline

Construct a BitMatrix by moving a vector of AlignedBitVectors.

Parameters
vectorsEach AlignedBitVector represents a row of the BitMatrix.
Precondition
All AlignedBitVectors have the same size.

◆ BitMatrix() [4/6]

encrypto::motion::BitMatrix::BitMatrix ( const std::vector< AlignedBitVector > &  vectors)
inline

Construct a BitMatrix by copying a vector of AlignedBitVectors.

Parameters
vectorsEach AlignedBitVector represents a row of the BitMatrix.
Precondition
All AlignedBitVectors have the same size.

◆ BitMatrix() [5/6]

encrypto::motion::BitMatrix::BitMatrix ( const BitMatrix other)
inline

◆ BitMatrix() [6/6]

encrypto::motion::BitMatrix::BitMatrix ( BitMatrix &&  other)
inline

Member Function Documentation

◆ AppendColumn() [1/2]

void encrypto::motion::BitMatrix::AppendColumn ( AlignedBitVector &&  bit_vector)
inline

Appends a new column by moving the input bit_vector to the matrix.

Parameters
bit_vectorThe new column.
Precondition
Size of bit_vector must be equal to the number of rows in the matrix.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ AppendColumn() [2/2]

void encrypto::motion::BitMatrix::AppendColumn ( const AlignedBitVector bit_vector)

Appends a new column by copying the input bit_vector to the matrix.

Parameters
bit_vectorThe new column.
Precondition
Size of bit_vector must be equal to the number of rows in the matrix.
Here is the call graph for this function:

◆ AppendRow() [1/2]

void encrypto::motion::BitMatrix::AppendRow ( AlignedBitVector &&  bit_vector)

Appends a new row by moving the input bit_vector to the matrix.

Parameters
bit_vectorThe new row.
Precondition
Size of bit_vector must be equal to the number of columns in the matrix.

◆ AppendRow() [2/2]

void encrypto::motion::BitMatrix::AppendRow ( const AlignedBitVector bit_vector)

Appends a new row by copying the input bit_vector to the matrix.

Parameters
bit_vectorThe new row.
Precondition
Size of bit_vector must be equal to the number of columns in the matrix.
Here is the call graph for this function:

◆ AsString()

std::string encrypto::motion::BitMatrix::AsString ( ) const

Return a string representation of the BitMatrix.

◆ ForceSetNumColumns()

void encrypto::motion::BitMatrix::ForceSetNumColumns ( std::size_t  n)
inline

Force the number of columns to be equal to n.

Parameters
n

◆ Get()

bool encrypto::motion::BitMatrix::Get ( std::size_t  row_i,
std::size_t  column_i 
) const
inline

Get Bit at input position.

Parameters
row_i
column_i

◆ GetMutableRow()

AlignedBitVector& encrypto::motion::BitMatrix::GetMutableRow ( std::size_t  i)
inline

Returns a mutable AlignedBitVector reference to row i of the matrix.

Note
Changing the size of the underlying BitVector causes Undefined Behaviour. The underlying BitVector can be replaced completely by a BitVector of the same size.
Parameters
i

◆ GetNumColumns()

auto encrypto::motion::BitMatrix::GetNumColumns ( ) const
inlinenoexcept

Get number of columns in the BitMatrix.

◆ GetNumRows()

auto encrypto::motion::BitMatrix::GetNumRows ( ) const
inlinenoexcept

Get number of rows in the BitMatrix.

◆ GetRow()

const AlignedBitVector& encrypto::motion::BitMatrix::GetRow ( std::size_t  i) const
inline

Returns a const AlignedBitVector reference to row i of the matrix.

Parameters
i

◆ operator!=()

bool encrypto::motion::BitMatrix::operator!= ( const BitMatrix other) const
inline

Compare with another BitMatrix for inequality.

Parameters
other

◆ operator=() [1/2]

void encrypto::motion::BitMatrix::operator= ( BitMatrix &&  other)
inline

◆ operator=() [2/2]

void encrypto::motion::BitMatrix::operator= ( const BitMatrix other)
inline

◆ operator==()

bool encrypto::motion::BitMatrix::operator== ( const BitMatrix other) const

Compare with another BitMatrix for equality.

Parameters
other

◆ ReceiverTransposeAndEncrypt()

void encrypto::motion::BitMatrix::ReceiverTransposeAndEncrypt ( const std::array< const std::byte *, 128 > &  matrix,
std::vector< BitVector<>> &  output,
primitives::Prg prg_fixed_key,
const std::size_t  number_of_columns,
const std::vector< std::size_t > &  bitlengths 
)
static

Transposes a matrix of 128 rows and arbitrary column size and encrypts it for the recepient role.

Parameters
matrix
Here is the call graph for this function:
Here is the caller graph for this function:

◆ SenderTransposeAndEncrypt()

void encrypto::motion::BitMatrix::SenderTransposeAndEncrypt ( const std::array< const std::byte *, 128 > &  matrix,
std::vector< BitVector<>> &  y0,
std::vector< BitVector<>> &  y1,
const BitVector<>  choices,
primitives::Prg prg_fixed_key,
const std::size_t  number_of_columns,
const std::vector< std::size_t > &  bitlengths 
)
static

Transposes a matrix of 128 rows and arbitrary column size and encrypts it for the sender role.

Parameters
matrix
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Set()

void encrypto::motion::BitMatrix::Set ( std::size_t  row_i,
std::size_t  column_i,
bool  value 
)
inline

Set or unset bit at input position.

Parameters
row_i
column_i
value

◆ Transpose()

void encrypto::motion::BitMatrix::Transpose ( )

Transposes the matrix inplace.

◆ Transpose128Rows()

void encrypto::motion::BitMatrix::Transpose128Rows ( )

Transposes a matrix with exactly 128 rows (faster).

Precondition
The matrix has exactly 128 rows and at least 1 column.

◆ Transpose128RowsInplace()

void encrypto::motion::BitMatrix::Transpose128RowsInplace ( std::array< std::byte *, 128 > &  matrix,
std::size_t  number_of_columns 
)
static

Transposes a matrix of 128 rows and arbitrary column size inplace.

Parameters
matrix
number_of_columns
Precondition
All rows must be of equal size.

◆ TransposeUsingBitSlicing()

void encrypto::motion::BitMatrix::TransposeUsingBitSlicing ( std::array< std::byte *, 128 > &  matrix,
std::size_t  number_of_columns 
)
static

Transposes a matrix of 128 rows and arbitrary column size inplace using BitSlicing.

Parameters
matrix
number_of_columns
Precondition
All rows must be of size equal to number_of_colums.

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