github.com/jiajun1992/watercarver@v0.0.0-20191031150618-dfc2b17c0c4a/StadiumForWaterCarver/src/Utils.h (about)

     1  #ifndef __UTILS_H__
     2  #define __UTILS_H__
     3  
     4  #ifdef __cplusplus
     5  extern "C" {
     6  #endif
     7  
     8  // TODO this is kind of a global configuration variable: should be moved to a better config place
     9  // TODO changing this also requires changing CurvePoint.h
    10  #define CURVE_POINT_BYTESIZE 32
    11  
    12  void hello();
    13  
    14  void test();
    15  
    16  #include <stdint.h>
    17  
    18  // key directory
    19  #include "keys.h"
    20  
    21  /******************* Memory ***********************/
    22  char** makeCharArray(int size);
    23  void setArrayString(char **a, char *s, int index, int src_index, int size);
    24  void freeCharArray(char **a, int size);
    25  
    26  void delete_ciphers(void* cipher_table);
    27  void delete_str(void* s);
    28  void delete_int_arr(int* x);
    29  int get_int_elem(int* arr, int i);
    30  
    31  
    32  void *create_pub_key_use_dero_H();
    33  void* create_pub_key(int key_id);
    34  void* create_decryption_key(int keyID);
    35  void delete_key(void* elgammal);
    36  
    37  
    38  /******************* Interface ********************/
    39  void resetM_N(int m, int n);
    40  void init();
    41  long getM();
    42  void* encrypt(void** secrets, int secretLen, int arrayLen, int keyIndex);
    43  void* get_ciphertexts(void* cipher_table, void* len, void* elmenent_size);
    44  void* get_element(void* cipher_table, int index, void* len);
    45  void* get_cipher(void* cipher_table, int i, int j, void* len);
    46  
    47  // for verified input metadata to first chain
    48  // same as encrypt except returned pointer does not have ciphertext directly
    49  void* encrypt_with_proof(void** secrets, int secretLen, int arrayLen, int keyIndex);
    50  // encrypt_cipher_part(encrypt_with_proof(x)) = encrypt(x)
    51  void* encrypt_cipher_part(void* cipher_and_proof);
    52  // returns a proof and its size (written to proof_size)
    53  void* encrypt_proof_part(void* cipher_and_proof, int* proof_size);
    54  // same as delete_ciphers except to be called on encrypt_with_proof instead of encrypt
    55  // note: do not pass parts to other delete functions (will cause double free)
    56  void* delete_ciphers_with_proof(void* x);
    57  // verify a proof output by encrypt_proof_part and their corresponding ciphertexts
    58  int verify_encrypt(void* ciphers, int ciphers_size, void* proof, int proof_size);
    59  
    60  int rows(void* cipher_table);
    61  int cols(void* cipher_table);
    62  
    63  void* parse_ciphers(void* ciphers, int len, void* elgammal);
    64  void* decrypt_cipher(void* ciphers, int i, int j, void* len, void* elgamal);
    65  
    66  
    67  void* shuffle_internal(void* reenc_key,
    68                         char* ciphers_in, int ciphers_array_len, int number_of_elements,
    69                         char** shuffled_ciphers, int* shuffled_ciphers_len,
    70                         int** permutation, int* permutation_len,
    71                         void* pi_in = nullptr, void* R_in = nullptr);
    72  void prove(void* cached_shuffle,
    73             char** proof_out, int* proof_len,
    74             char** public_randoms, int* public_randoms_len);
    75  int verify(int key_index,
    76             char* proof, int proof_len,
    77             char* ciphers_in, int len,
    78             char* post_shuffle_cipehrs, int post_shuffle_cipehrs_len,
    79             char* public_randoms, int public_randoms_len);
    80  
    81  #ifdef __cplusplus
    82  }
    83  #endif
    84  
    85  #endif