Browse Source

make SQRT_MINUS_ONE not static

master
Michael Hamburg 9 years ago
parent
commit
8ee11d449e
2 changed files with 8 additions and 12 deletions
  1. +1
    -3
      src/per_field/f_field.tmpl.h
  2. +7
    -9
      src/per_field/f_generic.tmpl.c

+ 1
- 3
src/per_field/f_field.tmpl.h View File

@@ -80,9 +80,7 @@ mask_t gf_deserialize (gf x, const uint8_t serial[SER_BYTES],int with_highbit);

#define P_MOD_8 $(modulus % 8)
#if P_MOD_8 == 5
static const gf SQRT_MINUS_ONE = {FIELD_LITERAL( /* TODO make not static */
$(ser(msqrt(-1,modulus),gf_lit_limb_bits) if modulus % 4 == 1 else "/* NOPE */")
)};
extern const gf SQRT_MINUS_ONE;
#endif

#ifndef LIMBPERM


+ 7
- 9
src/per_field/f_generic.tmpl.c View File

@@ -1,18 +1,16 @@
/**
* @cond internal
* @file per_field.c
* @copyright
* Copyright (c) 2015-2016 Cryptography Research, Inc. \n
* Released under the MIT License. See LICENSE.txt for license information.
* @author Mike Hamburg
* @brief Generic arithmetic which has to be compiled per field.
*/
/** @brief Generic arithmetic which has to be compiled per field. */

#include "field.h"

static const gf MODULUS = {FIELD_LITERAL(
$(ser(modulus,gf_lit_limb_bits))
)};
#if P_MOD_8 == 5
const gf SQRT_MINUS_ONE = {FIELD_LITERAL(
$(ser(msqrt(-1,modulus),gf_lit_limb_bits) if modulus % 4 == 1 else "/* NOPE */")
)};
#endif

/** Serialize to wire format. */
void gf_serialize (uint8_t serial[SER_BYTES], const gf x, int with_hibit) {


Loading…
Cancel
Save