From 64efd989d68b8ed34d645f84ca08b5be9f09c4ce Mon Sep 17 00:00:00 2001 From: Michael Hamburg Date: Fri, 15 Jan 2016 16:03:11 -0800 Subject: [PATCH] use SC_LIMB in generated tables. Add a new "TODO" category, UNIFY for code that might be unified with other code --- Makefile | 2 +- src/decaf.c | 4 ---- src/decaf_gen_tables.c | 26 ++++++++++++++++------- src/include/arch_x86_64/arch_intrinsics.h | 5 +---- 4 files changed, 20 insertions(+), 17 deletions(-) diff --git a/Makefile b/Makefile index abc59cb..bb75045 100644 --- a/Makefile +++ b/Makefile @@ -266,7 +266,7 @@ doc: Doxyfile $(BUILD_OBJ)/timestamp $(HEADERS) # (cd $(BATNAME)/.. && tar czf $(BATBASE).tgz $(BATBASE) ) # Finds todo items in .h and .c files -TODO_TYPES ?= HACK TODO FIXME BUG XXX PERF FUTURE REMOVE MAGIC +TODO_TYPES ?= HACK TODO FIXME BUG XXX PERF FUTURE REMOVE MAGIC UNIFY TODO_LOCATIONS ?= src test Makefile Doxyfile todo:: @(find $(TODO_LOCATIONS) -name '*.h' -or -name '*.c' -or -name '*.cxx' -or -name '*.hxx') | xargs egrep --color=auto -w \ diff --git a/src/decaf.c b/src/decaf.c index ca19f23..5b53af2 100644 --- a/src/decaf.c +++ b/src/decaf.c @@ -38,10 +38,6 @@ extern const gf SQRT_MINUS_ONE; #endif -#if COFACTOR == 8 -extern const gf SQRT_ONE_MINUS_D; /* TODO: Intern this? */ -#endif - /* FIXME: this can be different from DECAF_WORD_BITS, and word_t can be different from decaf_word_t, * eg when mixing and matching implementations for different curves. Homogenize this. */ diff --git a/src/decaf_gen_tables.c b/src/decaf_gen_tables.c index 85feced..641d8e8 100644 --- a/src/decaf_gen_tables.c +++ b/src/decaf_gen_tables.c @@ -37,18 +37,28 @@ void API_NS(precompute_wnafs) ( const API_NS(point_t) base ); -/* TODO: use SC_LIMB? */ -static void scalar_print(const char *name, const API_NS(scalar_t) sc) { +static void scalar_print(const char *name, const API_NS(scalar_t) sc) { /* UNIFY */ printf("const API_NS(scalar_t) %s = {{{\n", name); - unsigned i; - for (i=0; ilimb[i] ); + const int SCALAR_BYTES = (SCALAR_BITS + 7) / 8; + unsigned char ser[SCALAR_BYTES]; + API_NS(scalar_encode)(ser,sc); + int b=0, i, comma=0; + unsigned long long limb = 0; + for (i=0; i>(8-b); + } } printf("}}};\n\n"); } -static void field_print(const gf f) { +static void field_print(const gf f) { /* UNIFY */ const int GF_SER_BYTES = (GF_BITS + 7) / 8; unsigned char ser[GF_SER_BYTES]; gf_serialize(ser,f); @@ -58,7 +68,7 @@ static void field_print(const gf f) { for (i=0; i= GF_LIT_LIMB_BITS) { + if (b >= GF_LIT_LIMB_BITS || i == GF_SER_BYTES-1) { limb &= (1ull< -/* FUTURE: non x86-64 versions of these. - * FUTURE: autogenerate - */ - +/* FUTURE: autogenerate */ static __inline__ __uint128_t widemul(const uint64_t *a, const uint64_t *b) { uint64_t c,d; #ifndef __BMI2__