|
@@ -9,8 +9,11 @@ |
|
|
#include "decaf.h" |
|
|
#include "decaf.h" |
|
|
#include "decaf_config.h" |
|
|
#include "decaf_config.h" |
|
|
|
|
|
|
|
|
#define GEN_TABLES |
|
|
|
|
|
#include "curve_data.h" |
|
|
|
|
|
|
|
|
#define API_NS(_id) $(c_ns)_##_id |
|
|
|
|
|
#define SCALAR_BITS $(C_NS)_SCALAR_BITS |
|
|
|
|
|
static const unsigned char base_point_ser_for_pregen[SER_BYTES] = { |
|
|
|
|
|
$(decaf_base) |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
/* To satisfy linker. */ |
|
|
/* To satisfy linker. */ |
|
|
const gf API_NS(precomputed_base_as_fe)[1]; |
|
|
const gf API_NS(precomputed_base_as_fe)[1]; |
|
@@ -24,7 +27,7 @@ const uint8_t API_NS(x_base_point)[X_PUBLIC_BYTES] = {0}; |
|
|
|
|
|
|
|
|
struct niels_s; |
|
|
struct niels_s; |
|
|
const gf_s *API_NS(precomputed_wnaf_as_fe); |
|
|
const gf_s *API_NS(precomputed_wnaf_as_fe); |
|
|
extern const size_t API_NS2(sizeof,precomputed_wnafs); |
|
|
|
|
|
|
|
|
extern const size_t API_NS(sizeof_precomputed_wnafs); |
|
|
|
|
|
|
|
|
void API_NS(precompute_wnafs) ( |
|
|
void API_NS(precompute_wnafs) ( |
|
|
struct niels_s *out, |
|
|
struct niels_s *out, |
|
@@ -82,12 +85,12 @@ int main(int argc, char **argv) { |
|
|
if (ret != DECAF_SUCCESS) return 1; |
|
|
if (ret != DECAF_SUCCESS) return 1; |
|
|
|
|
|
|
|
|
API_NS(precomputed_s) *pre; |
|
|
API_NS(precomputed_s) *pre; |
|
|
ret = posix_memalign((void**)&pre, API_NS2(alignof,precomputed_s), API_NS2(sizeof,precomputed_s)); |
|
|
|
|
|
|
|
|
ret = posix_memalign((void**)&pre, API_NS(alignof_precomputed_s), API_NS(sizeof_precomputed_s)); |
|
|
if (ret || !pre) return 1; |
|
|
if (ret || !pre) return 1; |
|
|
API_NS(precompute)(pre, real_point_base); |
|
|
API_NS(precompute)(pre, real_point_base); |
|
|
|
|
|
|
|
|
struct niels_s *preWnaf; |
|
|
struct niels_s *preWnaf; |
|
|
ret = posix_memalign((void**)&preWnaf, API_NS2(alignof,precomputed_s), API_NS2(sizeof,precomputed_wnafs)); |
|
|
|
|
|
|
|
|
ret = posix_memalign((void**)&preWnaf, API_NS(alignof_precomputed_s), API_NS(sizeof_precomputed_wnafs)); |
|
|
if (ret || !preWnaf) return 1; |
|
|
if (ret || !preWnaf) return 1; |
|
|
API_NS(precompute_wnafs)(preWnaf, real_point_base); |
|
|
API_NS(precompute_wnafs)(preWnaf, real_point_base); |
|
|
|
|
|
|
|
@@ -97,8 +100,7 @@ int main(int argc, char **argv) { |
|
|
printf("/** @warning: this file was automatically generated. */\n"); |
|
|
printf("/** @warning: this file was automatically generated. */\n"); |
|
|
printf("#include \"field.h\"\n\n"); |
|
|
printf("#include \"field.h\"\n\n"); |
|
|
printf("#include <decaf.h>\n\n"); |
|
|
printf("#include <decaf.h>\n\n"); |
|
|
printf("#define API_NS(_id) %s_##_id\n", API_NAME); |
|
|
|
|
|
printf("#define API_NS2(_pref,_id) _pref##_%s_##_id\n", API_NAME); |
|
|
|
|
|
|
|
|
printf("#define API_NS(_id) $(c_ns)_##_id\n"); |
|
|
|
|
|
|
|
|
output = (const gf_s *)real_point_base; |
|
|
output = (const gf_s *)real_point_base; |
|
|
printf("const API_NS(point_t) API_NS(point_base) = {{\n"); |
|
|
printf("const API_NS(point_t) API_NS(point_base) = {{\n"); |
|
@@ -110,10 +112,10 @@ int main(int argc, char **argv) { |
|
|
|
|
|
|
|
|
output = (const gf_s *)pre; |
|
|
output = (const gf_s *)pre; |
|
|
printf("const gf API_NS(precomputed_base_as_fe)[%d]\n", |
|
|
printf("const gf API_NS(precomputed_base_as_fe)[%d]\n", |
|
|
(int)(API_NS2(sizeof,precomputed_s) / sizeof(gf))); |
|
|
|
|
|
printf("__attribute__((aligned(%d),visibility(\"hidden\"))) = {\n ", (int)API_NS2(alignof,precomputed_s)); |
|
|
|
|
|
|
|
|
(int)(API_NS(sizeof_precomputed_s) / sizeof(gf))); |
|
|
|
|
|
printf("__attribute__((aligned(%d),visibility(\"hidden\"))) = {\n ", (int)API_NS(alignof_precomputed_s)); |
|
|
|
|
|
|
|
|
for (i=0; i < API_NS2(sizeof,precomputed_s); i+=sizeof(gf)) { |
|
|
|
|
|
|
|
|
for (i=0; i < API_NS(sizeof_precomputed_s); i+=sizeof(gf)) { |
|
|
if (i) printf(",\n "); |
|
|
if (i) printf(",\n "); |
|
|
field_print(output++); |
|
|
field_print(output++); |
|
|
} |
|
|
} |
|
@@ -121,9 +123,9 @@ int main(int argc, char **argv) { |
|
|
|
|
|
|
|
|
output = (const gf_s *)preWnaf; |
|
|
output = (const gf_s *)preWnaf; |
|
|
printf("const gf API_NS(precomputed_wnaf_as_fe)[%d]\n", |
|
|
printf("const gf API_NS(precomputed_wnaf_as_fe)[%d]\n", |
|
|
(int)(API_NS2(sizeof,precomputed_wnafs) / sizeof(gf))); |
|
|
|
|
|
printf("__attribute__((aligned(%d),visibility(\"hidden\"))) = {\n ", (int)API_NS2(alignof,precomputed_s)); |
|
|
|
|
|
for (i=0; i < API_NS2(sizeof,precomputed_wnafs); i+=sizeof(gf)) { |
|
|
|
|
|
|
|
|
(int)(API_NS(sizeof_precomputed_wnafs) / sizeof(gf))); |
|
|
|
|
|
printf("__attribute__((aligned(%d),visibility(\"hidden\"))) = {\n ", (int)API_NS(alignof_precomputed_s)); |
|
|
|
|
|
for (i=0; i < API_NS(sizeof_precomputed_wnafs); i+=sizeof(gf)) { |
|
|
if (i) printf(",\n "); |
|
|
if (i) printf(",\n "); |
|
|
field_print(output++); |
|
|
field_print(output++); |
|
|
} |
|
|
} |
|
|