MOTION
0.01
Framework for mixed-protocol multi-party computation
|
Go to the documentation of this file.
27 #include <boost/align/aligned_allocator.hpp>
97 auto k1 =
reinterpret_cast<const std::byte*
>(
99 std::transform(k0, k0 +
kBlockSize, k1, k0, [](
auto a,
auto b) {
return a ^ b; });
116 std::transform(k0, k0 +
kBlockSize, other, k0, [](
auto a,
auto b) {
return a ^ b; });
132 std::fill(k0, k0 +
kBlockSize, std::byte(0x00));
208 auto input =
reinterpret_cast<const std::byte*
>(pointer);
209 auto buffer =
reinterpret_cast<std::byte*
>(
block_vector[0].data());
210 std::copy(input, input + 16 *
size, buffer);
256 auto start =
reinterpret_cast<std::byte* __restrict__
>(
258 std::fill(start, start +
ByteSize(), std::byte(0x00));
269 assert(
size() == other.size());
270 auto k0 =
reinterpret_cast<std::byte* __restrict__
>(
272 auto k1 =
reinterpret_cast<const std::byte* __restrict__
>(
274 std::transform(k0, k0 + 16 *
size(), k1, k0, [](
auto a,
auto b) {
return a ^ b; });
283 assert(
size() == other.size());
285 auto k0 =
reinterpret_cast<const std::byte* __restrict__
>(
287 auto k1 =
reinterpret_cast<const std::byte* __restrict__
>(
289 auto kout =
reinterpret_cast<std::byte* __restrict__
>(
291 std::transform(k0, k0 + 16 *
size(), k1, kout, [](
auto a,
auto b) {
return a ^ b; });
307 auto start =
reinterpret_cast<std::byte* __restrict__
>(
309 std::fill(start, start + result.ByteSize(), std::byte(0x00));
324 std::vector<Block128, boost::alignment::aligned_allocator<Block128, kBlockAlignment>>
void resize(std::size_t new_size)
Resize the Block128Vector to contain new_size elements. New elements are left uninitialized.
Definition: block.h:233
void LoadFromMemory(const std::byte *pointer)
Put 16 bytes starting at pointer into this Block128.
Definition: block.h:140
const std::byte * data() const
Definition: block.h:149
Block128Vector(const Block128Vector &other)
Definition: block.h:176
Block128 operator^(const Block128 &other) const
Performs XOR operation between two Block128.
Definition: block.h:105
Block128 & operator^=(const Block128 &__restrict__ other)
Performs XOR-assign operation between two Block128.
Definition: block.h:94
auto begin() const
Returns a const iterator to the first element of the Block128Vector.
Definition: block.h:245
static Block128Vector MakeRandom(std::size_t size)
Creates a vector of size elements filled with random data.
Definition: block.h:315
Block128Vector(std::size_t size, const Block128 &value)
Creates initialized vector of size elements with given value.
Definition: block.h:202
Block128 & operator=(Block128 &&other)
Definition: block.h:54
static constexpr std::size_t kBlockAlignment
Definition: block.h:321
Block128Vector(std::size_t size, const void *__restrict__ pointer)
Creates initialized vector of size elements read from memory.
Definition: block.h:207
static Block128 MakeZero()
Create a zero-initialized Block128.
Definition: block.h:63
const Block128 * data() const
Get const pointer to the first Block128.
Definition: block.h:222
Block128 operator^(const std::byte *__restrict__ other) const
Performs XOR operation between this Block128 and a non-overlapping arbitrary range of bytes.
Definition: block.h:122
bool operator==(const Block128 &other) const
Compares two Block128 for equality.
Definition: block.h:86
static constexpr std::size_t kBlockAlignment
Definition: block.h:161
bool operator!=(const Block128 &other) const
Compares two Block128 for inequality.
Definition: block.h:90
Block128 & operator=(const Block128 &other)
Definition: block.h:48
std::size_t ByteSize() const
Get size of the Block128Vector content in bytes.
Definition: block.h:228
void SetToRandom()
Set all Block128 in this vector to random values.
Definition: block.cpp:47
static Aes128CtrRng & GetThreadInstance()
Definition: aes128_ctr_rng.h:56
Vector of 128 bit / 16 B blocks.
Definition: block.h:168
Block128Vector operator^(const Block128Vector &__restrict__ other) const
Perform a XOR operation between all the Block128 in this vector and the Block128 in a different one o...
Definition: block.h:282
auto end()
Returns an iterator to the element following the last element of the Block128Vector.
Definition: block.h:248
void SetToZero()
Set all Block128 in this vector to zero.
Definition: block.h:255
std::string AsString() const
Format this Block128 as string of hexadecimal digits.
Definition: block.cpp:37
constexpr std::size_t kAlignment
Definition: config.h:42
static Block128Vector MakeZero(std::size_t size)
Creates a zero-filled vector of size elements.
Definition: block.h:305
Block128Vector & operator^=(const Block128Vector &__restrict__ other)
Perform a XOR-assign operation between all the Block128 in this vector and the Block128 in a differen...
Definition: block.h:268
std::array< std::byte, 16 > byte_array
Definition: block.h:164
Block128(const Block128 &other)
Definition: block.h:42
void SetToZero()
Set this Block128 to zero.
Definition: block.h:129
Block128 * data()
Get pointer to the first Block128.
Definition: block.h:219
std::vector< Block128, boost::alignment::aligned_allocator< Block128, kBlockAlignment > > block_vector
Definition: block.h:325
Definition: algorithm_description.cpp:35
Block128Vector(Block128Vector &&other)
Definition: block.h:179
Block128 & operator^=(const std::byte *__restrict__ other)
Performs XOR-assign operation between this Block128 and a non-overlapping arbitrary range of bytes.
Definition: block.h:113
Block128 & operator[](std::size_t index)
Access Block128 at index. Undefined behaviour if index is out of bounds.
Definition: block.h:297
Block of aligned 128 bit / 16 B.
Definition: block.h:34
Block128(Block128 &&other)
Definition: block.h:45
static constexpr std::size_t alignment()
Get alignment of Block128.
Definition: block.h:155
~Block128Vector()=default
Block128()
Definition: block.h:36
const Block128 & operator[](std::size_t index) const
Access Block128 at index. Undefined behaviour if index is out of bounds.
Definition: block.h:301
auto begin()
Returns an iterator to the first element of the Block128Vector.
Definition: block.h:242
static constexpr std::size_t kBlockSize
Definition: block.h:158
static constexpr std::size_t size()
Get size of Block128.
Definition: block.h:152
static Block128 MakeFromMemory(const std::byte *pointer)
Load data from memory and store it in Block128.
Definition: block.h:78
Block128Vector & operator=(Block128Vector &&other)
Definition: block.h:187
void SetToRandom()
Set this Block128 to a random value.
Definition: block.cpp:32
const Block128 & at(std::size_t index) const
Definition: block.h:216
static Block128 MakeRandom()
Create a random-initialized Block128.
Definition: block.h:70
Block128Vector(std::size_t size)
Creates uninitialized vector of size elements.
Definition: block.h:197
void resize(std::size_t new_size, const Block128 &value)
Resize the Block128Vector to contain new_size elements. New elements are set to value.
Definition: block.h:239
Block128Vector & operator=(const Block128Vector &other)
Definition: block.h:182
std::byte * data()
Get a pointer to the beginning of this Block128.
Definition: block.h:148
auto end() const
Returns a const iterator to the element following the last element of the Block128Vector.
Definition: block.h:252
std::size_t size() const
Get size of Block128Vector.
Definition: block.h:225
Block128 & at(std::size_t index)
Access Block128 at index. Throws an exception if index is out of bounds.
Definition: block.h:215