MOTION  0.01
Framework for mixed-protocol multi-party computation
Namespaces | Functions
helpers.h File Reference
#include <flatbuffers/flatbuffers.h>
#include <fmt/format.h>
#include <random>
#include "condition.h"
#include "primitives/random/default_rng.h"
#include "typedefs.h"
Include dependency graph for helpers.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

 encrypto
 
 encrypto::motion
 

Functions

template<typename UnsignedIntegralType , typename = std::enable_if_t<std::is_unsigned_v<UnsignedIntegralType>>>
std::vector< UnsignedIntegralType > encrypto::motion::RandomVector (std::size_t length)
 Returns a vector of length random unsigned integral values. More...
 
template<typename UnsignedIntegralType , typename = std::enable_if_t<std::is_unsigned_v<UnsignedIntegralType>>>
std::vector< std::uint8_t > encrypto::motion::ToByteVector (const std::vector< UnsignedIntegralType > &values)
 Converts a vector of unsigned integral values to a vector of uint8_t. More...
 
template<typename UnsignedIntegralType , typename = std::enable_if_t<std::is_unsigned_v<UnsignedIntegralType>>>
std::vector< UnsignedIntegralType > encrypto::motion::FromByteVector (const std::vector< std::uint8_t > &buffer)
 Converts a vector of uint8_t to a vector of unsigned integral values. More...
 
template<typename UnsignedIntegralType , typename = std::enable_if_t<std::is_unsigned_v<UnsignedIntegralType>>>
std::vector< UnsignedIntegralType > encrypto::motion::FromByteVector (const flatbuffers::Vector< std::uint8_t > &buffer)
 Converts a flatbuffer vector of uint8_t to a vector of unsigned integral values. More...
 
template<typename T >
std::vector< T > encrypto::motion::AddVectors (const std::vector< T > &a, const std::vector< T > &b)
 Adds each element in a and b and returns the result. More...
 
template<typename T >
std::vector< T > encrypto::motion::SubVectors (const std::vector< T > &a, const std::vector< T > &b)
 Subtracts each element in a and b and returns the result. More...
 
template<typename T >
std::vector< T > encrypto::motion::MultiplyVectors (std::vector< T > a, std::vector< T > b)
 Multiplies each element in a and b and returns the result. More...
 
template<typename T >
std::vector< T > encrypto::motion::AddVectors (std::vector< std::vector< T >> &vectors)
 Performs the AddVectors operation on an arbitrary number of vectors. More...
 
template<typename T >
std::vector< T > encrypto::motion::AddVectors (std::vector< std::vector< T >> &&vectors)
 Performs the AddVectors operation on an arbitrary number of vectors. More...
 
template<typename T >
std::vector< T > encrypto::motion::RestrictAddVectors (const std::vector< T > &a, const std::vector< T > &b)
 Adds each element in a and b and returns the result. It is assumed that the vectors do not overlap. More...
 
template<typename T >
std::vector< T > encrypto::motion::RestrictSubVectors (const std::vector< T > &a, const std::vector< T > &b)
 Subtracts each element in a and b and returns the result. It is assumed that the vectors do not overlap. More...
 
template<typename T >
std::vector< T > encrypto::motion::RestrictMulVectors (const std::vector< T > &a, const std::vector< T > &b)
 Mulitiplies each element in a and b and returns the result. It is assumed that the vectors do not overlap. More...
 
template<typename T >
encrypto::motion::SumReduction (const std::vector< T > &values)
 Returns the sum of each element in values. More...
 
template<typename T >
encrypto::motion::SubReduction (const std::vector< T > &values)
 Returns the difference of each element in values. More...
 
template<typename T >
encrypto::motion::MulReduction (const std::vector< T > &values)
 Returns the product of each element in values. More...
 
template<typename T >
std::vector< T > encrypto::motion::RowSumReduction (const std::vector< std::vector< T >> &values)
 Returns the sum of each row in a matrix. More...
 
template<typename T >
std::vector< T > encrypto::motion::RowSubReduction (const std::vector< std::vector< T >> &values)
 Returns the difference of each row in a matrix. More...
 
template<typename T >
std::vector< T > encrypto::motion::RowMulReduction (const std::vector< std::vector< T >> &values)
 Returns the product of each row in a matrix. More...
 
template<typename UnsignedIntegralType , typename = std::enable_if_t<std::is_unsigned_v<UnsignedIntegralType>>>
bool encrypto::motion::IsPowerOfTwo (UnsignedIntegralType x)
 Check if unisgned integral value is a power of two. More...
 
std::string encrypto::motion::Hex (const std::uint8_t *values, std::size_t n)
 Returns a hexadecimal string representation of the bytes stored in values. More...
 
std::string encrypto::motion::Hex (const std::byte *values, std::size_t n)
 Returns a hexadecimal string representation of the bytes stored in values. More...
 
template<std::size_t N>
std::string encrypto::motion::Hex (const std::array< std::byte, N > &values)
 Returns a hexadecimal string representation of the bytes stored in values. More...
 
template<std::size_t N>
std::string encrypto::motion::Hex (const std::array< std::uint8_t, N > &values)
 Returns a hexadecimal string representation of the bytes stored in values. More...
 
std::string encrypto::motion::Hex (const std::vector< std::uint8_t > &values)
 Returns a hexadecimal string representation of the bytes stored in values. More...
 
std::string encrypto::motion::Hex (const std::vector< std::byte > &values)
 Returns a hexadecimal string representation of the bytes stored in values. More...
 
std::string encrypto::motion::Hex (const std::vector< std::uint8_t > &&values)
 Returns a hexadecimal string representation of the bytes stored in values. More...
 
template<typename T >
std::string encrypto::motion::to_string (std::vector< T > values)
 Returns a string representation of the std::vector values. More...
 
template<typename T >
bool encrypto::motion::Vectors (const std::vector< T > &a, const std::vector< T > &b)
 XXX the std library implements operators for vector comparisions. More...
 
template<typename T >
bool encrypto::motion::Dimensions (const std::vector< std::vector< T >> &values)
 Checks if all the vectors have the same size. More...
 
std::size_t encrypto::motion::DivideAndCeil (std::size_t dividend, std::size_t divisor)
 Divides two size_t and returns the ceiled quotient. More...
 
constexpr std::size_t encrypto::motion::BitsToBytes (const std::size_t bits)
 Returns the number of bytes necessary to store bits bits. More...