-
Notifications
You must be signed in to change notification settings - Fork 1
/
core.h
62 lines (51 loc) · 1.55 KB
/
core.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
#ifndef CORE_H
#define CORE_H
#include <relic/relic.h>
#include "FIPS202-opt64/KeccakHash.h"
/* not exactly true, but large enough */
#define MAX_ORDER_SIZE RLC_FP_BYTES
extern unsigned int order_size;
/**
* Sample a random element from Z_p^*
*/
void zp_rand(bn_t b);
/**
* Adds two elements from Z_p.
*
* @param[out] c - the resulting element
* @param[in] a - the first input element
* @param[in] b - the second input element
*/
void zp_add(bn_t c, const bn_t a, const bn_t b);
/**
* Substracts two elements from Z_p.
*
* @param[out] c - the resulting element
* @param[in] a - the first input element
* @param[in] b - the second input element
*/
void zp_sub(bn_t c, const bn_t a, const bn_t b);
/**
* Multiplies two elements from Z_p.
*
* @param[out] c - the resulting element
* @param[in] a - the first input element
* @param[in] b - the second input element
*
* @return BFE_SUCCESS if no error occurs, an error code otherwise.
*/
void zp_mul(bn_t c, const bn_t a, const bn_t b);
/**
* Divides two elements from Z_p.
*
* @param[out] c - the resulting element
* @param[in] a - the first input element
* @param[in] b - the second input element
*/
void zp_div(bn_t c, const bn_t a, const bn_t b);
/**
* Squeezes a Z_p^* from the SHAKE instance by interpreting the hash
* value as binary coded number which is then reduced by the group order.
*/
void hash_squeeze_zp(bn_t bn, Keccak_HashInstance* ctx);
#endif