Browse Source

scalar_copy

master
Michael Hamburg 10 years ago
parent
commit
c08c4f4879
2 changed files with 21 additions and 0 deletions
  1. +11
    -0
      include/decaf.h
  2. +10
    -0
      src/decaf.c

+ 11
- 0
include/decaf.h View File

@@ -166,6 +166,17 @@ void decaf_scalar_mul (
const decaf_scalar_t b
) API_VIS NONNULL3;

/**
* @brief Copy a scalar. The scalars may use the same memory, in which
* case this function does nothing.
* @param [in] a A scalar.
* @param [out] out Will become a copy of a.
*/
void decaf_scalar_copy (
decaf_scalar_t out,
const decaf_scalar_t a
) API_VIS NONNULL2;

/**
* @brief Encode a point as a sequence of bytes.
*


+ 10
- 0
src/decaf.c View File

@@ -316,6 +316,16 @@ void decaf_scalar_add (
decaf_subx(out, out->limb, decaf_scalar_p, decaf_scalar_p, chain);
}

void decaf_scalar_copy (
decaf_scalar_t out,
const decaf_scalar_t a
) {
unsigned int i;
for (i=0; i<DECAF_SCALAR_LIMBS; i++) {
out->limb[i] = a->limb[i];
}
}

decaf_bool_t decaf_scalar_eq (
const decaf_scalar_t a,
const decaf_scalar_t b


Loading…
Cancel
Save