From c08c4f48791def21367f479147365d59c3a2cd77 Mon Sep 17 00:00:00 2001 From: Michael Hamburg Date: Fri, 30 Jan 2015 11:57:33 -0800 Subject: [PATCH] scalar_copy --- include/decaf.h | 11 +++++++++++ src/decaf.c | 10 ++++++++++ 2 files changed, 21 insertions(+) diff --git a/include/decaf.h b/include/decaf.h index a18e19a..850bdf2 100644 --- a/include/decaf.h +++ b/include/decaf.h @@ -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. * diff --git a/src/decaf.c b/src/decaf.c index de8b5ed..8dd7d87 100644 --- a/src/decaf.c +++ b/src/decaf.c @@ -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; ilimb[i] = a->limb[i]; + } +} + decaf_bool_t decaf_scalar_eq ( const decaf_scalar_t a, const decaf_scalar_t b