diff --git a/csidh/Makefile b/csidh/Makefile index 13f1b63..46a5db1 100644 --- a/csidh/Makefile +++ b/csidh/Makefile @@ -32,7 +32,7 @@ all: $(CODE_OBJ) $(CC) -o $(BUILD_DIR)/test test/main.c -L$(BUILD_DIR) -lcsidh run: all - GOPATH=$(GOPATH) go run test/test.go + GOPATH=$(GOPATH) go run test/torturer.go clean: rm -rf build diff --git a/csidh/test/main.c b/csidh/test/main.c index b4e4997..3db568c 100644 --- a/csidh/test/main.c +++ b/csidh/test/main.c @@ -13,7 +13,7 @@ static void u512_print(u512 const *x) 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("0x%X,", (unsigned char)v[i]); printf("\n"); } @@ -24,6 +24,13 @@ static void fp_print(fp const *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; @@ -54,19 +61,58 @@ static void testLoopRef() { } } -static void testHardcoded() { - private_key prv; - public_key pub; - uint8_t prv_bytes[] = {0xdb,0x54,0xe4,0xd4,0xd0,0xbd,0xee,0xcb,0xf4,0xd0,0xc2,0xbc,0x52,0x44,0x11,0xee,0xe1,0x14,0xd2,0x24,0xe5,0x0,0xcc,0xf5,0xc0,0xe1,0x1e,0xb3,0x43,0x52,0x45,0xbe,0xfb,0x54,0xc0,0x55,0xb2}; - uint64_t pub_bytes[] = {0x6BCAAD7EFD426976,0x743D780A06D2CDC5,0x841A2D76984849F7,0x1523EB45B3B78D5F,0xCF7A093C773EDF8D,0xFAB0FF04A7B4A54D,0x05DE322C864069D2,0x0C55DC69711DF47A}; +void print_bytes(uint8_t *out, size_t sz) { + for(size_t i=0; i -*/ -import "C" -import "fmt" -//import rand "crypto/rand" -import csidh "github.com/henrydcase/nobs/dh/csidh" -//import "unsafe" -//import "runtime" -import rand "crypto/rand" - -func main() { - prA := csidh.NewPrivateKey() - prA.Generate(rand.Reader) - - prB := csidh.NewPrivateKey() - prB.Generate(rand.Reader) - - for i:=0; i<7; i++ { - var b [37]byte - prA.Generate(rand.Reader) - if !prA.Export(b[:]) { - panic("Export failed") - } - fmt.Printf("%X\n", b) - } - - pkA := csidh.NewPublicKey() - pkA.Generate(&prA) - -/* - print("ONE") - pkB := csidh.NewPublicKey() - pkB.Generate(&prB) - print("ONE") - pkA.DeriveSecret(&pkB, &prA) -*/ -}