#include #include #include #include "../ref/csidh/csidh.h" static void u512_print(u512 const *x) { for (size_t i=0; i<8; i++) { printf("0x%016lX,", x->c[i]); } printf("\n"); } static void int_print(const int8_t v[37]) { for (size_t i = 0; i<37; i++) printf("0x%X,", (unsigned char)v[i]); printf("\n"); } static void fp_print(fp const *x) { u512 y; fp_dec(&y, x); u512_print(&y); } static void fp_print_n(fp const *x) { for (size_t i=0; i<8; i++) { printf("0x%016lX, ", x->x.c[i]); } printf("\n"); } static void fp_cmp(fp const *x, uint64_t const *org) { u512 y; fp_dec(&y, x); assert(memcmp(&y.c, org, sizeof(y.c)) == 0); } static void testLoopRef() { for(size_t i=0; i<10; i++) { private_key prA, prB; public_key pkA, pkB; public_key shA, shB; // private key csidh_private(&prA); csidh_private(&prB); // public key csidh(&pkA, &base, &prA); csidh(&pkB, &base, &prB); //csidh csidh(&shA, &pkA, &prB); csidh(&shB, &pkB, &prA); //int_print(prA.e); //fp_print(&pkA.A); assert(memcmp(&shA, &shB, sizeof(shB))==0); } } void print_bytes(uint8_t *out, size_t sz) { for(size_t i=0; i