|
MOTION
0.01
Framework for mixed-protocol multi-party computation
|
Class representing a series of bits and providing single bit access. More...
#include <bit_vector.h>
Public Member Functions | |
| BitVector () noexcept | |
| BitVector (BitVector &&bit_vector) noexcept | |
| BitVector (const BitVector &bit_vector) noexcept | |
| BitVector< Allocator > & | operator= (const BitVector< Allocator > &other) noexcept |
| BitVector< Allocator > & | operator= (BitVector< Allocator > &&other) noexcept |
| template<typename OtherAllocator > | |
| BitVector (const BitVector< OtherAllocator > &bit_vector) noexcept | |
| Copy from a BitVector with different allocator. More... | |
| template<typename OtherAllocator > | |
| BitVector< Allocator > & | operator= (const BitVector< OtherAllocator > &other) noexcept |
| Copy-assign from BitVector with different allocator. More... | |
| BitVector (const std::vector< bool > &data) | |
| Initialize from a std::vector<bool>. More... | |
| BitVector (const std::vector< bool > &data, std::size_t number_of_bits) | |
| Initialize from a std::vector<bool>. More... | |
| BitVector (std::size_t number_of_bits, bool value=false) noexcept | |
Construct a BitVector with exactly number_of_bits bits set to value. More... | |
| BitVector (const unsigned char *buffer, std::size_t bits) | |
| Initialize BitVector from buffer. More... | |
| BitVector (const std::byte *buffer, std::size_t bits) | |
| Initialize BitVector from buffer. More... | |
| template<typename OtherAllocator > | |
| BitVector (const std::vector< std::byte, OtherAllocator > &data, std::size_t number_of_bits) | |
| Initialize by copying content of std::vector. More... | |
| BitVector (std::vector< std::byte, Allocator > &&data, std::size_t number_of_bits) | |
| Initialize by moving content of std::vector (requires same allocator). More... | |
| bool | Empty () const |
| Check if BitVector is empty. More... | |
| auto | GetSize () const noexcept |
| Get size of BitVector. More... | |
| const auto & | GetData () const noexcept |
| Get const reference to content of BitVector. More... | |
| auto & | GetMutableData () noexcept |
| Get reference to content of BitVector. More... | |
| void | Assign (const BitVector &other) noexcept |
| Copy-assign other BitVector. More... | |
| void | Assign (BitVector &&other) noexcept |
| Move-assign other BitVector. More... | |
| void | Set (bool value) noexcept |
| Sets or unsets all bits in the BitVector. More... | |
| void | Set (bool value, std::size_t position) |
Sets or unsets the bit at position in the BitVector. More... | |
| bool | Get (std::size_t position) const |
| Get bit at given position. More... | |
| void | Resize (std::size_t number_of_bits, bool zero_fill=false) noexcept |
Resize BitVector to size number_of_bits. New bits are uninitialized by default. More... | |
| void | Reserve (std::size_t number_of_bits) |
Reserves new space for BitVector, so that it can contain at least number_of_bits bits. More... | |
| void | Append (bool bit) noexcept |
| Appends a bit to BitVector. More... | |
| void | Append (const BitVector< Allocator > &other) noexcept |
| Appends another BitVector to BitVector. More... | |
| void | Append (BitVector &&other) noexcept |
| Appends another BitVector to BitVector. More... | |
| void | Append (const BitSpan &other) |
| Appends a BitSpan to BitVector. More... | |
| void | Append (BitSpan &&other) |
| Appends a BitSpan to BitVector. More... | |
| void | Append (const std::byte *pointer, const std::size_t append_bit_size) noexcept |
Appends append_bit_size bytes starting from pointer to BitVector. More... | |
| void | Copy (const std::size_t dest_from, const std::size_t dest_to, const BitVector &other) |
| copies the first (dest_to - dest_from) bits from other to the bits [dest_from, dest_to) in this. More... | |
| void | Copy (const std::size_t dest_from, const BitVector &other) |
| copies other to this[dest_from...dest_from+GetSize()]. More... | |
| BitVector | Subset (std::size_t from, std::size_t to) const |
Returns a new BitVector containing the bits of this BitVector between positions from and to. More... | |
| std::string | AsString () const noexcept |
| Returns a string representation of this BitVector. More... | |
| void | Clear () noexcept |
| Clear this Bitvector. More... | |
| void | Invert () |
| In-place bit-wise invert. More... | |
| bool | operator[] (std::size_t position) const |
| Get bit at given position in the BitVector. More... | |
| BitVector | operator~ () const |
| Return an inverted copy of this BitVector. More... | |
| template<typename OtherAllocator > | |
| BitVector | operator& (const BitVector< OtherAllocator > &other) const noexcept |
| Perform AND operation between every bit of two BitVectors. More... | |
| BitVector | operator& (const BitSpan &other) const noexcept |
| Perform AND operation between every bit of a BitVector and a BitSpan. More... | |
| template<typename OtherAllocator > | |
| BitVector | operator^ (const BitVector< OtherAllocator > &other) const noexcept |
| Perform XOR operation between every bit of two BitVectors. More... | |
| BitVector | operator^ (const BitSpan &other) const noexcept |
| Perform XOR operation between every bit of a BitVector and a BitSpan. More... | |
| template<typename OtherAllocator > | |
| BitVector | operator| (const BitVector< OtherAllocator > &other) const noexcept |
| Perform OR operation between every bit of two BitVectors. More... | |
| BitVector | operator| (const BitSpan &other) const noexcept |
| Perform OR operation between every bit of a BitVector and a BitSpan. More... | |
| template<typename OtherAllocator > | |
| bool | operator!= (const BitVector< OtherAllocator > &other) const noexcept |
| Compares two BitVectors for inequality. More... | |
| bool | operator!= (const BitSpan &other) const noexcept |
| Compares a BitVector and a BitSpan for inequality. More... | |
| template<typename OtherAllocator > | |
| bool | operator== (const BitVector< OtherAllocator > &other) const noexcept |
| Compares two BitVectors for equality. More... | |
| bool | operator== (const BitSpan &other) const noexcept |
| Compares a BitVector and a BitSpan for equality. More... | |
| template<typename OtherAllocator > | |
| BitVector & | operator&= (const BitVector< OtherAllocator > &other) noexcept |
| Perform AND-assign operation between every bit of this and the other BitVector. More... | |
| BitVector & | operator&= (const BitSpan &other) noexcept |
| Perform AND-assign operation between every bit of this and a BitSpan. More... | |
| template<typename OtherAllocator > | |
| BitVector & | operator^= (const BitVector< OtherAllocator > &other) noexcept |
| Perform XOR-assign operation between every bit of this and the other BitVector. More... | |
| BitVector & | operator^= (const BitSpan &other) noexcept |
| Perform XOR-assign operation between every bit of this and a BitSpan. More... | |
| template<typename OtherAllocator > | |
| BitVector & | operator|= (const BitVector< OtherAllocator > &other) noexcept |
| Perform OR-assign operation between every bit of this and the other BitVector. More... | |
| BitVector & | operator|= (const BitSpan &other) noexcept |
| Perform OR-assign operation between every bit of this and a BitSpan. More... | |
| template<typename OtherAllocator > | |
| BitVector< Allocator > | operator& (const BitVector< OtherAllocator > &other) const noexcept |
| template<typename OtherAllocator > | |
| BitVector< Allocator > | operator^ (const BitVector< OtherAllocator > &other) const noexcept |
| template<typename OtherAllocator > | |
| BitVector< Allocator > | operator| (const BitVector< OtherAllocator > &other) const noexcept |
| template<typename OtherAllocator > | |
| BitVector< Allocator > & | operator&= (const BitVector< OtherAllocator > &other) noexcept |
| template<typename OtherAllocator > | |
| BitVector< Allocator > & | operator^= (const BitVector< OtherAllocator > &other) noexcept |
| template<typename OtherAllocator > | |
| BitVector< Allocator > & | operator|= (const BitVector< OtherAllocator > &other) noexcept |
Static Public Member Functions | |
| static BitVector | SecureRandom (const std::size_t size) noexcept |
| Returns a random BitVector. More... | |
| static BitVector | RandomSeeded (const std::size_t size, const std::size_t seed=0) noexcept |
| Returns a random BitVector using an input seed. Internally uses Mersenne twister, do not use as cryptographic randomness! More... | |
| static bool | OrReduceBitVector (const BitVector &bit_vector) |
| Performs OR operation between all bits in BitVector. More... | |
| static BitVector | OrBitVectors (const std::vector< BitVector > &bit_vectors) |
Performs OR operation between all BitVectors in bit_vectors. More... | |
| static bool | AndReduceBitVector (const BitVector &bit_vector) |
| Performs AND operation between all bits in BitVector. More... | |
| static BitVector | AndBitVectors (const std::vector< BitVector > &bit_vectors) |
Performs AND operation between all BitVectors in bit_vectors. More... | |
| static std::vector< BitVector > | AndBitVectors (const std::vector< BitVector > &a, const std::vector< BitVector > &b) |
Performs AND operation between every BitVector in a and b. More... | |
| static std::vector< BitVector > | AndBitVectors (const std::vector< std::vector< BitVector >> &bit_vectors) |
Performs AndBitVectors operation between all vectors of BitVector in bit_vectors. More... | |
| static bool | XorReduceBitVector (const BitVector &bit_vector) |
| Performs XOR operation between all bits in BitVector. More... | |
| static BitVector | XorBitVectors (const std::vector< BitVector > &bit_vectors) |
Performs XOR operation between all BitVectors in bit_vectors. More... | |
| static std::vector< BitVector > | XorBitVectors (const std::vector< BitVector > &a, const std::vector< BitVector > &b) |
Performs XOR operation between every BitVector in a and b. More... | |
| static std::vector< BitVector > | XorBitVectors (const std::vector< std::vector< BitVector >> &bit_vectors) |
Performs XorBitVectors operation between all vectors of BitVector in bit_vectors. More... | |
| static bool | IsEqualSizeDimensions (const std::vector< BitVector > &bit_vectors) |
Check if all Bitvectors in bit_vectors are of equal dimension. More... | |
| static constexpr bool | IsAligned () noexcept |
| Returns true if Allocator is aligned allocator. More... | |
Friends | |
| template<typename OtherAllocator > | |
| class | BitVector |
| class | BitSpan |
Related Functions | |
(Note that these are not member functions.) | |
| template<typename T , typename = std::enable_if_t<std::is_floating_point_v<T> || std::is_unsigned_v<T>>, typename Allocator = std::allocator<std::byte>> | |
| std::vector< BitVector< Allocator > > | ToInput (T value) |
| Converts a value of an unsigned integer type or a floating point type to a vector of BitVector. More... | |
| template<typename UnsignedIntegralType , typename = std::enable_if_t<std::is_unsigned_v<UnsignedIntegralType>>, typename Allocator = std::allocator<std::byte>> | |
| std::vector< UnsignedIntegralType > | ToVectorOutput (std::vector< BitVector< Allocator >> bit_vectors) |
| Converts a vector of UnsignedIntegralType to a vector of BitVectors. More... | |
Class representing a series of bits and providing single bit access.
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inline |
Initialize from a std::vector<bool>.
| data |
|
explicit |
Initialize from a std::vector<bool>.
| data | |
| number_of_bits | Expected number of bits. |
data must be of size equal to number_of_bits.
|
explicitnoexcept |
Construct a BitVector with exactly number_of_bits bits set to value.
| number_of_bits | |
| value |
|
inline |
Initialize BitVector from buffer.
| buffer | |
| bits | Size of the buffer. |
| encrypto::motion::BitVector< Allocator >::BitVector | ( | const std::byte * | buffer, |
| std::size_t | bits | ||
| ) |
Initialize BitVector from buffer.
| buffer | |
| bits | Size of the buffer. |
|
explicit |
Initialize by copying content of std::vector.
| data | |
| number_of_bits | Expected number of bits. |
data must be of size equal to number_of_bits.
|
explicit |
Initialize by moving content of std::vector (requires same allocator).
| data | |
| number_of_bits | Expected number of bits. |
data must be of size equal to number_of_bits.
|
static |
Performs AND operation between every BitVector in a and b.
| a | |
| b |
a and b must be of equal size.
|
static |
Performs AND operation between all BitVectors in bit_vectors.
| bit_vectors |
|
static |
Performs AndBitVectors operation between all vectors of BitVector in bit_vectors.
| bit_vectors |
|
static |
Performs AND operation between all bits in BitVector.
| bit_vector |
| void encrypto::motion::BitVector< Allocator >::Append | ( | BitSpan && | other | ) |
|
noexcept |
|
noexcept |
| void encrypto::motion::BitVector< Allocator >::Append | ( | const BitSpan & | other | ) |
|
noexcept |
|
noexcept |
Appends append_bit_size bytes starting from pointer to BitVector.
| pointer | |
| append_bit_size |
|
inlinenoexcept |
Move-assign other BitVector.
| other |
|
inlinenoexcept |
Copy-assign other BitVector.
| other |
|
noexcept |
Returns a string representation of this BitVector.
|
noexcept |
Clear this Bitvector.

| void encrypto::motion::BitVector< Allocator >::Copy | ( | const std::size_t | dest_from, |
| const BitVector< Allocator > & | other | ||
| ) |
copies other to this[dest_from...dest_from+GetSize()].
| an | std::out_of_range exception if this is smaller than other. |
| void encrypto::motion::BitVector< Allocator >::Copy | ( | const std::size_t | dest_from, |
| const std::size_t | dest_to, | ||
| const BitVector< Allocator > & | other | ||
| ) |
copies the first (dest_to - dest_from) bits from other to the bits [dest_from, dest_to) in this.
| an | std::out_of_range exception if accessing invalid positions in this or other. |

|
inline |
| bool encrypto::motion::BitVector< Allocator >::Get | ( | std::size_t | position | ) | const |
Get bit at given position.
| position |

|
inlinenoexcept |
|
inlinenoexcept |
Get reference to content of BitVector.
|
inlinenoexcept |
| void encrypto::motion::BitVector< Allocator >::Invert |
In-place bit-wise invert.

|
inlinestaticconstexprnoexcept |
Returns true if Allocator is aligned allocator.
|
static |
Check if all Bitvectors in bit_vectors are of equal dimension.
| bit_vectors |
|
noexcept |
|
noexcept |
Compares two BitVectors for inequality.
| other |
|
noexcept |
|
noexcept |
Perform AND operation between every bit of two BitVectors.
| other |
|
noexcept |
|
noexcept |
|
noexcept |
Perform AND-assign operation between every bit of this and the other BitVector.
| other |
|
noexcept |
|
noexcept |
|
noexcept |
|
noexcept |
Copy-assign from BitVector with different allocator.
| OtherAllocator |
| other |
|
noexcept |
|
noexcept |
Compares two BitVectors for equality.
| other |
|
inline |
Get bit at given position in the BitVector.
| position |
|
noexcept |
|
noexcept |
Perform XOR operation between every bit of two BitVectors.
| other |
|
noexcept |
|
noexcept |
|
noexcept |
Perform XOR-assign operation between every bit of this and the other BitVector.
| other |
|
noexcept |
|
noexcept |
|
noexcept |
Perform OR operation between every bit of two BitVectors.
| other |
|
noexcept |
|
noexcept |
|
noexcept |
Perform OR-assign operation between every bit of this and the other BitVector.
| other |
|
noexcept |
| BitVector< Allocator > encrypto::motion::BitVector< Allocator >::operator~ |
Return an inverted copy of this BitVector.
|
static |
Performs OR operation between all BitVectors in bit_vectors.
| bit_vectors |
|
static |
Performs OR operation between all bits in BitVector.
| bit_vector |
|
staticnoexcept |
|
inline |
Reserves new space for BitVector, so that it can contain at least number_of_bits bits.
| number_of_bits |

|
noexcept |
Resize BitVector to size number_of_bits. New bits are uninitialized by default.
| number_of_bits | |
| zero_fill | Sets new bits to 0 if option is set to true. |

|
staticnoexcept |
|
noexcept |
Sets or unsets all bits in the BitVector.
| value |

| void encrypto::motion::BitVector< Allocator >::Set | ( | bool | value, |
| std::size_t | position | ||
| ) |
Sets or unsets the bit at position in the BitVector.
| value | |
| position |
| BitVector< Allocator > encrypto::motion::BitVector< Allocator >::Subset | ( | std::size_t | from, |
| std::size_t | to | ||
| ) | const |
|
static |
Performs XOR operation between every BitVector in a and b.
| a | |
| b |
a and b must be of equal size.
|
static |
Performs XOR operation between all BitVectors in bit_vectors.
| bit_vectors |

|
static |
Performs XorBitVectors operation between all vectors of BitVector in bit_vectors.
| bit_vectors |
|
static |
Performs XOR operation between all bits in BitVector.
| bit_vector |
|
friend |
|
friend |
|
related |
Converts a value of an unsigned integer type or a floating point type to a vector of BitVector.
A vector of BitVectors allows to interleave multiple arithmetic values intended to be used in a SIMD way. Let x be an arithmetic value, with x0,...,xn being its little-endian bit representation. This value is then represented by a value v of type std::vector<BitVector> with v[j][0] == xj. Now, if we interleave x with y and z of the same bit representation, then: v[j][0] == xj, v[j][1] == yj, v[j][2] == zj.
UnsignedIntegralType. | T |
| value |

|
related |
Converts a vector of UnsignedIntegralType to a vector of BitVectors.
A vector of BitVectors allows to interleave multiple arithmetic values intended to be used in a SIMD way. Let x be an arithmetic value, with x0,...,xn being its little-endian bit representation. This value is then represented by a value v of type std::vector<BitVector> with v[j][0] == xj. Now, if we interleave x with y and z of the same bit representation, then: v[j][0] == xj, v[j][1] == yj, v[j][2] == zj.
bit_vectors is equal to number of bits in UnsignedIntegralType bit_vectors has size equal to bit_vectors.size() | UnsignedIntegralType |
| bit_vectors |
1.8.17