ソースを参照

use SC_LIMB in generated tables. Add a new "TODO" category, UNIFY for code that might be unified with other code

master
Michael Hamburg 8年前
コミット
64efd989d6
4個のファイルの変更20行の追加17行の削除
  1. +1
    -1
      Makefile
  2. +0
    -4
      src/decaf.c
  3. +18
    -8
      src/decaf_gen_tables.c
  4. +1
    -4
      src/include/arch_x86_64/arch_intrinsics.h

+ 1
- 1
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 \


+ 0
- 4
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.
*/


+ 18
- 8
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; i<sizeof(API_NS(scalar_t))/sizeof(decaf_word_t); i++) {
if (i) printf(", ");
printf("0x%0*llxull", (int)sizeof(decaf_word_t)*2, (unsigned long long)sc->limb[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<SCALAR_BYTES; i++) {
limb |= ((uint64_t)ser[i])<<b;
b += 8;
if (b == 64 || i==SCALAR_BYTES-1) {
b = 0;
if (comma) printf(",");
comma = 1;
printf("SC_LIMB(0x%016llx)", limb);
limb = ((uint64_t)ser[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_SER_BYTES; i++) {
limb |= ((uint64_t)ser[i])<<b;
b += 8;
if (b >= GF_LIT_LIMB_BITS) {
if (b >= GF_LIT_LIMB_BITS || i == GF_SER_BYTES-1) {
limb &= (1ull<<GF_LIT_LIMB_BITS) -1;
b -= GF_LIT_LIMB_BITS;
if (comma) printf(",");


+ 1
- 4
src/include/arch_x86_64/arch_intrinsics.h ファイルの表示

@@ -9,10 +9,7 @@

#include <stdint.h>

/* 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__


読み込み中…
キャンセル
保存