forked from 6iKezbAD3CZnf/merkletree-poseidon-cuda
-
Notifications
You must be signed in to change notification settings - Fork 0
/
field.cuh
43 lines (31 loc) · 762 Bytes
/
field.cuh
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
34
35
36
37
38
39
40
41
42
43
#ifndef FIELD_CUH_
#define FIELD_CUH_
#include <iostream>
#include <cstdint>
#include "uint128_t.cuh"
#define GOLDILOCKS_PRIME 0xffffffff00000001
class F {
public:
__host__ __device__
F() : value(0) {}
__host__ __device__
F(uint64_t v) : value(v % GOLDILOCKS_PRIME) {}
__host__ __device__
F operator+(const F& other) const;
__host__ __device__
F operator*(const F& other) const;
// Comparison
bool operator==(const F& other) const;
// Stream insertion operator
friend std::ostream& operator<<(std::ostream& os, const F& f) {
os << f.value;
return os;
}
__host__ __device__
uint64_t to_u64() {
return value;
}
private:
uint64_t value;
};
#endif // FIELD_CUH_