myl7/fss 2.0.0
Function secret sharing (FSS) primitives including distributed point/comparison function (DPF/DCF)
Loading...
Searching...
No Matches
bytes.cuh
Go to the documentation of this file.
1// SPDX-License-Identifier: Apache-2.0
7
8#pragma once
9#include <fss/group.cuh>
10#include <cuda_runtime.h>
11#include <cassert>
12#include <fss/util.cuh>
13
14namespace fss::group {
15
20class Bytes {
21public:
22 // Groupable interface.
23
25 __host__ __device__ Bytes operator+(Bytes rhs) const {
26 return util::Xor(val_, rhs.val_);
27 }
28
30 __host__ __device__ Bytes operator-() const {
31 return *this;
32 }
33
35 __host__ __device__ Bytes() : val_({0, 0, 0, 0}) {}
36
43 __host__ __device__ static Bytes From(int4 buf) {
44 util::RequireArg((buf.w & 1) == 0, "Bytes::From: the block must have a zero LSB");
45 return Bytes(buf);
46 }
47
49 __host__ __device__ int4 Into() const {
50 return val_;
51 }
52
53private:
54 int4 val_;
55
56 __host__ __device__ Bytes(int4 buf) : val_(buf) {}
57};
58static_assert(Groupable<Bytes>);
59
60} // namespace fss::group
static Bytes From(int4 buf)
Wrap a clamped block as a group element.
Definition bytes.cuh:43
Bytes operator+(Bytes rhs) const
Return the group sum, the bitwise XOR of both values.
Definition bytes.cuh:25
Bytes()
Construct the additive identity.
Definition bytes.cuh:35
int4 Into() const
Return this group element as a clamped block.
Definition bytes.cuh:49
Bytes operator-() const
Return the additive inverse, which is this value in the XOR group.
Definition bytes.cuh:30
Group interface.
Definition group.cuh:49
void RequireArg(bool ok, const char *msg)
Check a caller precondition.
Definition util.cuh:73
int4 Xor(int4 lhs, int4 rhs)
Return the bitwise XOR of two 128-bit blocks.
Definition util.cuh:29