#ifndef __FR_H #define __FR_H #include #define Fr_N64 4 #define Fr_SHORT 0x00000000 #define Fr_LONG 0x80000000 #define Fr_LONGMONTGOMERY 0xC0000000 typedef struct __attribute__((__packed__)) { int32_t shortVal; u_int32_t type; u_int64_t longVal[Fr_N64]; } FrElement; typedef FrElement *PFrElement; extern FrElement Fr_q; extern "C" void Fr_copy(PFrElement r, PFrElement a); extern "C" void Fr_copyn(PFrElement r, PFrElement a, int n); extern "C" void Fr_add(PFrElement r, PFrElement a, PFrElement b); extern "C" void Fr_sub(PFrElement r, PFrElement a, PFrElement b); extern "C" void Fr_neg(PFrElement r, PFrElement a); extern "C" void Fr_mul(PFrElement r, PFrElement a, PFrElement b); extern "C" void Fr_square(PFrElement r, PFrElement a); extern "C" void Fr_band(PFrElement r, PFrElement a, PFrElement b); extern "C" void Fr_bor(PFrElement r, PFrElement a, PFrElement b); extern "C" void Fr_bxor(PFrElement r, PFrElement a, PFrElement b); extern "C" void Fr_bnot(PFrElement r, PFrElement a); extern "C" void Fr_eq(PFrElement r, PFrElement a, PFrElement b); extern "C" void Fr_neq(PFrElement r, PFrElement a, PFrElement b); extern "C" void Fr_lt(PFrElement r, PFrElement a, PFrElement b); extern "C" void Fr_gt(PFrElement r, PFrElement a, PFrElement b); extern "C" void Fr_leq(PFrElement r, PFrElement a, PFrElement b); extern "C" void Fr_geq(PFrElement r, PFrElement a, PFrElement b); extern "C" void Fr_land(PFrElement r, PFrElement a, PFrElement b); extern "C" void Fr_lor(PFrElement r, PFrElement a, PFrElement b); extern "C" void Fr_lnot(PFrElement r, PFrElement a); extern "C" void Fr_toNormal(PFrElement pE); extern "C" void Fr_toLongNormal(PFrElement pE); extern "C" void Fr_toMontgomery(PFrElement pE); void Fr_str2element(PFrElement pE, char const*s); char *Fr_element2str(PFrElement pE); void Fr_idiv(PFrElement r, PFrElement a, PFrElement b); void Fr_mod(PFrElement r, PFrElement a, PFrElement b); void Fr_inv(PFrElement r, PFrElement a); void Fr_div(PFrElement r, PFrElement a, PFrElement b); void Fr_shl(PFrElement r, PFrElement a, PFrElement b); void Fr_shr(PFrElement r, PFrElement a, PFrElement b); void Fr_pow(PFrElement r, PFrElement a, PFrElement b); int Fr_isTrue(PFrElement pE); int Fr_toInt(PFrElement pE); void Fr_init(); extern FrElement Fr_q; #endif // __FR_H