emp-toolkit
utils_ec.hpp
Go to the documentation of this file.
1 inline void bn_to_block(block * b, const bn_t bn) {
2  bn_write_bin((uint8_t*)b, sizeof(block), bn);
3 }
4 
5 inline void block_to_bn(bn_t bn, const block * b) {
6  bn_read_bin(bn, (const uint8_t*)b, sizeof(block));
7 }
8 inline void initialize_relic() {
9  if(initialized) return;
10  initialized = true;
11  if (core_init() != STS_OK) {
12  core_clean();
13  exit(1);
14  }
15 
16  eb_param_set(EBACS_B251);
17 }
18 
19 //TODO: fix the following.
20 inline block KDF(eb_t in) {
21  uint8_t tmp[100];
22  int eb_size= eb_size_bin(in, ECC_PACK);
23  eb_write_bin(tmp, eb_size, in, ECC_PACK);
24  return Hash::hash_for_block(&tmp[0], eb_size);
25 }
26 
void block_to_bn(bn_t bn, const block *b)
Definition: utils_ec.hpp:5
__m128i block
Definition: block.h:8
void bn_to_block(block *b, const bn_t bn)
Definition: utils_ec.hpp:1
#define ECC_PACK
Definition: utils_ec.h:9
void initialize_relic()
Definition: utils_ec.hpp:8
block KDF(eb_t in)
Definition: utils_ec.hpp:20
static block hash_for_block(const void *data, int nbyte)
Definition: hash.h:52