Skip to content

Commit

Permalink
Integrate ED module with EC module.
Browse files Browse the repository at this point in the history
  • Loading branch information
tfar committed Nov 10, 2014
1 parent 3310544 commit de14fd3
Show file tree
Hide file tree
Showing 12 changed files with 853 additions and 107 deletions.
16 changes: 10 additions & 6 deletions cmake/doxygen.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Helper macro to add a "doc" target with CMake build system.
# Helper macro to add a "doc" target with CMake build system.
# and configure doxy.config.in to doxy.config
#
# Please note, that the tools, e.g.:
Expand All @@ -11,10 +11,14 @@
find_package(Doxygen)

if (DOXYGEN_FOUND)

if (OPSYS STREQUAL "MACOSX")
set(GENERATE_DOCSET "YES")
else (OPSYS STREQUAL "MACOSX")
set(GENERATE_DOCSET "NO")
endif (OPSYS STREQUAL "MACOSX")
if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/doc/relic.doxygen.in")
message(STATUS "Configured ${CMAKE_CURRENT_SOURCE_DIR}/doc/relic.doxygen.in")
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/doc/relic.doxygen.in
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/doc/relic.doxygen.in
${CMAKE_CURRENT_BINARY_DIR}/doc/relic.doxygen @ONLY )
# use config from BUILD tree
set(DOXY_CONFIG "${CMAKE_CURRENT_BINARY_DIR}/doc/relic.doxygen")
Expand All @@ -29,7 +33,7 @@ if (DOXYGEN_FOUND)
endif(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/doc/relic.doxygen")

endif(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/doc/relic.doxygen.in")

add_custom_target(doc ${DOXYGEN_EXECUTABLE} ${DOXY_CONFIG})
endif(DOXYGEN_FOUND)

endif(DOXYGEN_FOUND)
10 changes: 10 additions & 0 deletions cmake/ed.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
message(STATUS "Elliptic Edwards curve over prime fields arithmetic configuration (ED module):\n")

if (NOT ED_DEPTH)
set(ED_DEPTH 4)
endif(NOT ED_DEPTH)
if (NOT ED_WIDTH)
set(ED_WIDTH 4)
endif(NOT ED_WIDTH)
set(ED_FIX MONTY)
set(ED_MUL MONTY)
2 changes: 1 addition & 1 deletion doc/relic.doxygen.in
Original file line number Diff line number Diff line change
Expand Up @@ -1156,7 +1156,7 @@ HTML_INDEX_NUM_ENTRIES = 100
# The default value is: NO.
# This tag requires that the tag GENERATE_HTML is set to YES.

GENERATE_DOCSET = NO
GENERATE_DOCSET = @GENERATE_DOCSET@

# This tag determines the name of the docset feed. A documentation feed provides
# an umbrella under which multiple documentation sets from a single provider
Expand Down
65 changes: 39 additions & 26 deletions include/relic_conf.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
/** Intel x86-compatible 32-bit architecture. */
#define X86 5
/** AMD64-compatible 64-bit architecture. */
#define X64 6
#define X64 6
/** Architecture. */
#define ARCH @ARCH@

Expand Down Expand Up @@ -176,7 +176,7 @@
/** Chosen multiple precision modular exponentiation method. */
#define BN_MXP @BN_MXP@

/** Basic Euclidean GCD Algorithm. */
/** Basic Euclidean GCD Algorithm. */
#define BASIC 1
/** Lehmer's fast GCD Algorithm. */
#define LEHME 2
Expand All @@ -203,7 +203,7 @@
#define FP_KARAT @FP_KARAT@
/** Prefer Pseudo-Mersenne primes over random primes. */
#cmakedefine FP_PMERS
/** Use -1 as quadratic non-residue. */
/** Use -1 as quadratic non-residue. */
#cmakedefine FP_QNRES
/** Width of window processing for exponentiation methods. */
#define FP_WIDTH @FP_WIDTH@
Expand Down Expand Up @@ -254,8 +254,8 @@
#define EXGCD 4
/** Use implementation provided by the lower layer. */
#define LOWER 7
/** Chosen prime field inversion method. */
#define FP_INV @FP_INV@
/** Chosen prime field inversion method. */
#define FP_INV @FP_INV@

/** Binary modular exponentiation. */
#define BASIC 1
Expand All @@ -274,21 +274,21 @@
/** Integrated extension field arithmetic. */
#define INTEG 3
/* Chosen extension field arithmetic method. */
#define FPX_QDR @FPX_QDR@
#define FPX_QDR @FPX_QDR@

/** Basic cubic extension field arithmetic. */
#define BASIC 1
/** Integrated extension field arithmetic. */
#define INTEG 3
/* Chosen extension field arithmetic method. */
#define FPX_CBC @FPX_CBC@
#define FPX_CBC @FPX_CBC@

/** Basic quadratic extension field arithmetic. */
#define BASIC 1
/** Lazy-reduced extension field arithmetic. */
#define LAZYR 2
/* Chosen extension field arithmetic method. */
#define FPX_RDC @FPX_RDC@
#define FPX_RDC @FPX_RDC@

/** Prime extension field arithmetic method */
#define FPX_METHD "@FPX_METHD@"
Expand Down Expand Up @@ -371,7 +371,7 @@
/** Use implementation provided by the lower layer. */
#define LOWER 7
/** Chosen binary field inversion method. */
#define FB_INV @FB_INV@
#define FB_INV @FB_INV@

/** Binary modular exponentiation. */
#define BASIC 1
Expand Down Expand Up @@ -414,24 +414,24 @@
/** Chosen prime elliptic curve coordinate method. */
#define EP_ADD @EP_ADD@

/** Binary point multiplication. */
/** Binary point multiplication. */
#define BASIC 1
/** Sliding window. */
/** Sliding window. */
#define SLIDE 2
/** Montgomery powering ladder. */
#define MONTY 3
/** Left-to-right Width-w NAF. */
/** Left-to-right Width-w NAF. */
#define LWNAF 4
/** Chosen prime elliptic curve point multiplication method. */
#define EP_MUL @EP_MUL@

/** Binary point multiplication. */
/** Binary point multiplication. */
#define BASIC 1
/** Yao's windowing method. */
#define YAOWI 2
/** NAF windowing method. */
/** NAF windowing method. */
#define NAFWI 3
/** Left-to-right Width-w NAF. */
/** Left-to-right Width-w NAF. */
#define LWNAF 4
/** Single-table comb method. */
#define COMBS 5
Expand All @@ -449,7 +449,7 @@
/** Joint sparse form. */
#define JOINT 4
/** Chosen prime elliptic curve simulteanous point multiplication method. */
#define EP_SIM @EP_SIM@
#define EP_SIM @EP_SIM@

/** Prime elliptic curve arithmetic method. */
#define EP_METHD "@EP_METHD@"
Expand All @@ -472,31 +472,31 @@

/** Affine coordinates. */
#define BASIC 1
/** L�pez-Dahab Projective coordinates. */
/** L�pez-Dahab Projective coordinates. */
#define PROJC 2
/** Chosen binary elliptic curve coordinate method. */
#define EB_ADD @EB_ADD@

/** Binary point multiplication. */
/** Binary point multiplication. */
#define BASIC 1
/** L�pez-Dahab point multiplication. */
/** L�pez-Dahab point multiplication. */
#define LODAH 2
/** Halving. */
#define HALVE 3
/** Left-to-right width-w (T)NAF. */
/** Left-to-right width-w (T)NAF. */
#define LWNAF 4
/** Right-to-left width-w (T)NAF. */
/** Right-to-left width-w (T)NAF. */
#define RWNAF 5
/** Chosen binary elliptic curve point multiplication method. */
#define EB_MUL @EB_MUL@

/** Binary point multiplication. */
/** Binary point multiplication. */
#define BASIC 1
/** Yao's windowing method. */
#define YAOWI 2
/** NAF windowing method. */
/** NAF windowing method. */
#define NAFWI 3
/** Left-to-right Width-w NAF. */
/** Left-to-right Width-w NAF. */
#define LWNAF 4
/** Single-table comb method. */
#define COMBS 5
Expand All @@ -514,11 +514,24 @@
/** Joint sparse form. */
#define JOINT 4
/** Chosen binary elliptic curve simulteanous point multiplication method. */
#define EB_SIM @EB_SIM@
#define EB_SIM @EB_SIM@

/** Prefer curves with efficient endomorphisms. */
#cmakedefine EC_ENDOM

/** Chosen prime elliptic twisted Edwards curve point multiplication method. */
#define ED_MUL @ED_MUL@

/** Build precomputation table for generator. */
#cmakedefine ED_PRECO
/** Width of precomputation table for fixed point methods. */
#define ED_DEPTH @ED_DEPTH@
/** Width of window processing for unknown point methods. */
#define ED_WIDTH @ED_WIDTH@

/** Chosen prime elliptic twisted Edwards curve point multiplication method. */
#define ED_FIX @ED_FIX@

/** Prime curves. */
#define PRIME 1
/** Binary curves. */
Expand All @@ -539,7 +552,7 @@
/** Lazy-reduced extension field arithmetic. */
#define LAZYR 2
/* Chosen extension field arithmetic method. */
#define PP_EXT @PP_EXT@
#define PP_EXT @PP_EXT@

/** Bilinear pairing method. */
#define PP_METHD "@PP_METHD@"
Expand Down
9 changes: 8 additions & 1 deletion include/relic_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ typedef struct _ctx_t {
/** The order of the group of points in the elliptic curve. */
bn_st ep2_r;
/** The cofactor of the group order in the elliptic curve. */
bn_st ep2_h;
bn_st ep2_h;
/** Flag that stores if the prime curve is a twist. */
int ep2_is_twist;
#ifdef EP_PRECO
Expand Down Expand Up @@ -352,6 +352,13 @@ typedef struct _ctx_t {
bn_st ed_r;
/** The cofactor of the Twisted Edwards elliptic curve */
bn_st ed_h;

#ifdef ED_PRECO
/** Precomputation table for generator multiplication. */
ed_st ed_pre[ED_TABLE];
/** Array of pointers to the precomputation table. */
ed_st *ed_ptr[ED_TABLE];
#endif /* ED_PRECO */
#endif

#ifdef WITH_PP
Expand Down
4 changes: 4 additions & 0 deletions include/relic_ec.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@
#define EC_TABLE EP_TABLE
#elif EC_CUR == CHAR2
#define EC_TABLE EB_TABLE
#elif EC_CUR == EDWARD
#define EC_TABLE ED_TABLE
#endif

/**
Expand Down Expand Up @@ -190,6 +192,8 @@ typedef CAT(EC_LOWER, t) ec_t;
#else
#define ec_param_set_any() eb_param_set_any()
#endif
#elif EC_CUR == EDWARD
#define ec_param_set_any() ed_param_set_any()
#endif

/**
Expand Down
Loading

0 comments on commit de14fd3

Please sign in to comment.