diff --git a/csidh/Makefile b/csidh/Makefile index 46a5db1..4554561 100644 --- a/csidh/Makefile +++ b/csidh/Makefile @@ -29,9 +29,10 @@ $(BUILD_DIR)/%.o: %.s all: $(CODE_OBJ) $(AR) $(BUILD_DIR)/libcsidh.a $^ $(RANLIB) $(BUILD_DIR)/libcsidh.a - $(CC) -o $(BUILD_DIR)/test test/main.c -L$(BUILD_DIR) -lcsidh + $(CC) -o $(BUILD_DIR)/test_ref test/main.c -L$(BUILD_DIR) -lcsidh run: all + $(BUILD_DIR)/test_ref GOPATH=$(GOPATH) go run test/torturer.go clean: diff --git a/csidh/test/main.c b/csidh/test/main.c index 3db568c..8ef2254 100644 --- a/csidh/test/main.c +++ b/csidh/test/main.c @@ -11,12 +11,20 @@ static void u512_print(u512 const *x) printf("\n"); } +void print_bytes(uint8_t *out, size_t sz) { + for(size_t i=0; ix.c[i]); @@ -31,14 +40,15 @@ static void fp_print_n(fp const *x) { printf("\n"); } -static void fp_cmp(fp const *x, uint64_t const *org) +static bool fp_cmp(fp const *l, fp const *r) { - u512 y; - fp_dec(&y, x); - assert(memcmp(&y.c, org, sizeof(y.c)) == 0); + u512 lu,ru; + fp_dec(&lu, l); + fp_dec(&ru, r); + return ( sizeof(lu.c) == sizeof(ru.c) ) && (memcmp(&lu.c, &ru.c, sizeof(lu.c)) == 0); } -static void testLoopRef() { +static bool testLoopRef() { for(size_t i=0; i<10; i++) { private_key prA, prB; public_key pkA, pkB; @@ -55,45 +65,11 @@ static void testLoopRef() { //csidh csidh(&shA, &pkA, &prB); csidh(&shB, &pkB, &prA); - //int_print(prA.e); - //fp_print(&pkA.A); - assert(memcmp(&shA, &shB, sizeof(shB))==0); + return (memcmp(&shA, &shB, sizeof(shB))==0); } } -void print_bytes(uint8_t *out, size_t sz) { - for(size_t i=0; i