Browse Source

make copies inline

master
Mike Hamburg 9 years ago
parent
commit
df69e59117
5 changed files with 12 additions and 48 deletions
  1. +1
    -1
      Doxyfile
  2. +8
    -4
      include/decaf.h
  3. +3
    -3
      include/decaf.hxx
  4. +0
    -20
      src/decaf.c
  5. +0
    -20
      src/decaf_fast.c

+ 1
- 1
Doxyfile View File

@@ -751,7 +751,7 @@ WARN_LOGFILE =
# spaces.
# Note: If this tag is empty the current directory is searched.

INPUT =
INPUT = include

# This tag can be used to specify the character encoding of the source files
# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses


+ 8
- 4
include/decaf.h View File

@@ -224,10 +224,12 @@ decaf_bool_t decaf_448_scalar_invert (
* @param [out] out Will become a copy of a.
*/
/* PERF: make this memcpy */
void decaf_448_scalar_copy (
static inline void NONNULL2 decaf_448_scalar_copy (
decaf_448_scalar_t out,
const decaf_448_scalar_t a
) API_VIS NONNULL2;
) {
*out = *a;
}

/**
* @brief Set a scalar to an integer.
@@ -276,10 +278,12 @@ decaf_bool_t decaf_448_point_decode (
* @param [out] a A copy of the point.
* @param [in] b Any point.
*/
void decaf_448_point_copy (
static inline void NONNULL2 decaf_448_point_copy (
decaf_448_point_t a,
const decaf_448_point_t b
) API_VIS NONNULL2;
) {
*a=*b;
}

/**
* @brief Test whether two points are equal. If yes, return


+ 3
- 3
include/decaf.hxx View File

@@ -173,13 +173,13 @@ public:
/** @brief Compare in constant time */
inline bool operator==(const Scalar &q) const NOEXCEPT { return !!decaf_448_scalar_eq(s,q.s); }
/** @brief Invert with Fermat's Little Theorem (slow!) */
/** @brief Invert with Fermat's Little Theorem (slow!). If *this == 0, return 0. */
inline Scalar inverse() const NOEXCEPT { Scalar r; decaf_448_scalar_invert(r.s,s); return r; }
/** @brief Divide by inverting q. */
/** @brief Divide by inverting q. If q == 0, return 0. */
inline Scalar operator/ (const Scalar &q) const NOEXCEPT { Scalar r; decaf_448_scalar_mul(r.s,s,q.inverse().s); return r; }
/** @brief Divide by inverting q. */
/** @brief Divide by inverting q. If q == 0, return 0. */
inline Scalar operator/=(const Scalar &q) NOEXCEPT { decaf_448_scalar_mul(s,s,q.inverse().s); return *this; }
/** @brief Scalarmul with scalar on left. */


+ 0
- 20
src/decaf.c View File

@@ -412,16 +412,6 @@ void decaf_448_scalar_add (
decaf_448_subx(out, out->limb, decaf_448_scalar_p, decaf_448_scalar_p, chain);
}

void decaf_448_scalar_copy (
decaf_448_scalar_t out,
const decaf_448_scalar_t a
) {
unsigned int i;
for (i=0; i<DECAF_448_SCALAR_LIMBS; i++) {
out->limb[i] = a->limb[i];
}
}

void decaf_448_scalar_set (
decaf_448_scalar_t out,
decaf_word_t w
@@ -575,16 +565,6 @@ void decaf_448_point_double(decaf_448_point_t a, const decaf_448_point_t b) {
decaf_448_point_add(a,b,b);
}

void decaf_448_point_copy (
decaf_448_point_t a,
const decaf_448_point_t b
) {
gf_cpy(a->x, b->x);
gf_cpy(a->y, b->y);
gf_cpy(a->z, b->z);
gf_cpy(a->t, b->t);
}

void decaf_448_point_negate (
decaf_448_point_t nega,
const decaf_448_point_t a


+ 0
- 20
src/decaf_fast.c View File

@@ -423,16 +423,6 @@ snv decaf_448_halve (
out->limb[i] = out->limb[i]>>1 | chain<<(WBITS-1);
}

void decaf_448_scalar_copy (
decaf_448_scalar_t out,
const decaf_448_scalar_t a
) {
unsigned int i;
for (i=0; i<DECAF_448_SCALAR_LIMBS; i++) {
out->limb[i] = a->limb[i];
}
}

void decaf_448_scalar_set (
decaf_448_scalar_t out,
decaf_word_t w
@@ -623,16 +613,6 @@ void decaf_448_point_double(decaf_448_point_t p, const decaf_448_point_t q) {
decaf_448_point_double_internal(p,q,0);
}

void decaf_448_point_copy (
decaf_448_point_t a,
const decaf_448_point_t b
) {
gf_cpy(a->x, b->x);
gf_cpy(a->y, b->y);
gf_cpy(a->z, b->z);
gf_cpy(a->t, b->t);
}

void decaf_448_point_negate (
decaf_448_point_t nega,
const decaf_448_point_t a


Loading…
Cancel
Save