28 #define BPU_TEST_ROUNDS 300
30 int main(
int argc,
char **argv) {
36 struct timeval tv, tv_end;
40 fprintf(stderr,
"====== SPEED TEST ======\n");
46 gettimeofday(&tv, NULL);
49 gettimeofday(&tv_end, NULL);
50 res += (tv_end.tv_sec - tv.tv_sec + ((tv_end.tv_usec - tv.tv_usec) / (
double)1000000));
56 gettimeofday(&tv, NULL);
58 gettimeofday(&tv_end, NULL);
59 res_2 += (tv_end.tv_sec - tv.tv_sec + ((tv_end.tv_usec - tv.tv_usec) / (
double)1000000));
61 gettimeofday(&tv, NULL);
63 gettimeofday(&tv_end, NULL);
64 res_3 += (tv_end.tv_sec - tv.tv_sec + ((tv_end.tv_usec - tv.tv_usec) / (
double)1000000));
71 fprintf(stderr,
"%0.6lf\n", res / BPU_TEST_ROUNDS);
72 fprintf(stderr,
"%0.6lf\n", res_2 / BPU_TEST_ROUNDS);
73 fprintf(stderr,
"%0.6lf\n", res_3 / BPU_TEST_ROUNDS);
int BPU_gf2VecMalloc(BPU_T_GF2_Vector **v, int len)
void BPU_gf2VecFree(BPU_T_GF2_Vector **v)
Free dynamically or statically allocated vector.
uint16_t pt_len
PT len in bits.
int BPU_gf2VecRand(BPU_T_GF2_Vector *out, int w)
int BPU_mecsInitParamsGoppa(BPU_T_UN_Mecs_Params *params, const uint16_t m, const uint16_t t, const BPU_T_GF2_16x mod)
int BPU_mecsDecrypt(BPU_T_GF2_Vector *pt, BPU_T_GF2_Vector *ct, const BPU_T_Mecs_Ctx *ctx)
Decrypt cipher text (ct) and save it to plain text.
int BPU_mecsInitCtx(BPU_T_Mecs_Ctx **ctx, const BPU_T_UN_Mecs_Params *params, const BPU_T_EN_Mecs_Types type)
Initialize (register) mecs functions for encryption, decryption and key gen based on type...
basic mecs, without any conversion
int main(int argc, char **argv)
int BPU_mecsFreeCtx(BPU_T_Mecs_Ctx **ctx)
uint16_t ct_len
CT len in bits.
void BPU_mecsFreeParamsGoppa(BPU_T_UN_Mecs_Params *params)
int BPU_mecsGenKeyPair(BPU_T_Mecs_Ctx *ctx)
Key generation, first must be initialized context using BPU_mecsInitCtx().
int BPU_mecsEncrypt(BPU_T_GF2_Vector *ct, const BPU_T_GF2_Vector *pt, const BPU_T_Mecs_Ctx *ctx)
Encrypt plaintext (pt) and save it to cipher text.