forked from WeDPR-Team/MP-SPDZ
-
Notifications
You must be signed in to change notification settings - Fork 0
/
P256Element.h
70 lines (47 loc) · 1.55 KB
/
P256Element.h
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/*
* Element.h
*
*/
#ifndef ECDSA_P256ELEMENT_H_
#define ECDSA_P256ELEMENT_H_
#include <openssl/ec.h>
#include <openssl/obj_mac.h>
#include "Math/gfp.h"
class P256Element : public ValueInterface
{
public:
typedef gfp_<2, 4> Scalar;
private:
static EC_GROUP* curve;
EC_POINT* point;
public:
typedef void next;
typedef void Square;
static const true_type invertible;
static int size() { return 0; }
static string type_string() { return "P256"; }
static void init();
P256Element();
P256Element(const P256Element& other);
P256Element(const Scalar& other);
P256Element(word other);
P256Element& operator=(const P256Element& other);
void check();
Scalar x() const;
P256Element operator+(const P256Element& other) const;
P256Element operator-(const P256Element& other) const;
P256Element operator*(const Scalar& other) const;
P256Element& operator+=(const P256Element& other);
P256Element& operator/=(const Scalar& other);
bool operator==(const P256Element& other) const;
bool operator!=(const P256Element& other) const;
void assign_zero() { *this = {}; }
bool is_zero() { return *this == P256Element(); }
void add(octetStream& os) { *this += os.get<P256Element>(); }
void pack(octetStream& os) const;
void unpack(octetStream& os);
octetStream hash(size_t n_bytes) const;
friend ostream& operator<<(ostream& s, const P256Element& x);
};
P256Element operator*(const P256Element::Scalar& x, const P256Element& y);
#endif /* ECDSA_P256ELEMENT_H_ */