emp-toolkit
utils_ec.h
Go to the documentation of this file.
1 #ifndef UTILS_EC_H__
2 #define UTILS_EC_H__
3 extern "C" {
4 #include <relic/relic.h>
5 }
6 #include "block.h"
7 
8 #include "hash.h"
9 #define ECC_PACK false
10 #define BIT_LEN 128
11 #define EB_SIZE 65
12 
13 
14 typedef eb_t eb_tpl[2];
15 typedef bn_t bn_tpl[2];
16 
17 #define __batch(func, ...)\
18  template <typename H, typename... T> void func##l(H p, T... t) {\
19  func(p,##__VA_ARGS__);\
20  func##l(t...);\
21  }\
22  template <typename H> void func##l(H p) {\
23  func(p,##__VA_ARGS__);\
24  }
25 
26 __batch(eb_new);
27 __batch(eb_free);
28 __batch(bn_new);
29 __batch(bn_free);
30 
31 #define __batch2(func)\
32 template <typename H1, typename H2, typename H3> void func##_norm(H1 h1, H2 h2, H3 h3) {\
33  func(h1, h2, h3);\
34  eb_norm(h1, h1);\
35 }\
36 
37 __batch2(eb_mul);
38 __batch2(eb_mul_fix);
39 __batch2(eb_sub);
40 __batch2(eb_add);
41 
42 #define __batch3(func)\
43 template <typename H1, typename H2, typename H3, typename H4> void func##_mod(H1 h1, H2 h2, H3 h3, H4 h4) {\
44  func(h1, h2, h3);\
45  bn_mod(h1, h1, h4);\
46 }\
47 
48 __batch3(bn_mul);
49 __batch3(bn_sub);
50 __batch3(bn_add);
51 
52 void bn_to_block(block * b, const bn_t bn);
53 void block_to_bn(bn_t bn, const block * b);
54 static bool initialized = false;
55 void initialize_relic();
56 
57 block KDF(eb_t in);
58 #include "utils_ec.hpp"
59 #endif// UTILS_EC_H__
#define __batch(func,...)
Definition: utils_ec.h:17
__m128i block
Definition: block.h:8
#define __batch3(func)
Definition: utils_ec.h:42
eb_t eb_tpl[2]
Definition: utils_ec.h:14
bn_t bn_tpl[2]
Definition: utils_ec.h:15
block KDF(eb_t in)
Definition: utils_ec.hpp:20
void initialize_relic()
Definition: utils_ec.hpp:8
void block_to_bn(bn_t bn, const block *b)
Definition: utils_ec.hpp:5
#define __batch2(func)
Definition: utils_ec.h:31
void bn_to_block(block *b, const bn_t bn)
Definition: utils_ec.hpp:1