-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfp2.cuh
More file actions
33 lines (26 loc) · 1.55 KB
/
fp2.cuh
File metadata and controls
33 lines (26 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include "fp.cuh"
namespace goldilocks {
/// Degree 2 Goldilocks extension field mod x^2 - 7
struct alignas(16) fp2 {
alignas(16) fp data[2];
__device__ constexpr fp2(const fp input0, const fp input1) noexcept : data { input0, input1 } {}
__device__ constexpr fp2(const fp input) noexcept : data { input, fp::zero() } {}
__device__ constexpr fp2() noexcept : data { fp::zero(), fp::zero() } {}
__device__ constexpr fp2 operator*(const fp2& other) const noexcept;
__device__ constexpr fp2 operator+(const fp2& other) const noexcept;
__device__ constexpr fp2 operator-(const fp2& other) const noexcept;
__device__ constexpr fp2 operator-() const noexcept;
__device__ constexpr fp2& operator*=(const fp2& other) noexcept;
__device__ constexpr fp2& operator+=(const fp2& other) noexcept;
__device__ constexpr fp2& operator-=(const fp2& other) noexcept;
__device__ constexpr bool operator==(const fp2& other) const noexcept;
__device__ constexpr bool operator!=(const fp2& other) const noexcept;
__device__ constexpr fp2 scalar_mul(const fp& scalar) const noexcept;
__device__ static constexpr fp2 zero() { return fp2(); }
__device__ static constexpr fp2 one() { return { fp::one() }; }
constexpr fp2& operator=(const fp2& other) noexcept = default;
constexpr fp2& operator=(fp2&& other) noexcept = default;
constexpr fp2(const fp2& other) noexcept = default;
constexpr fp2(fp2&& other) noexcept = default;
};
}