From d2ab89bdc540c6127e027bc3abaf3c2fccd279b1 Mon Sep 17 00:00:00 2001 From: Michael Hamburg Date: Wed, 28 Jan 2015 16:53:42 -0800 Subject: [PATCH] better docs on Elligator --- include/decaf.h | 15 ++++++++++++++- src/decaf.c | 11 +++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/include/decaf.h b/include/decaf.h index 010cfb8..a8ffe7d 100644 --- a/include/decaf.h +++ b/include/decaf.h @@ -192,12 +192,25 @@ decaf_bool_t decaf_valid ( * is indifferentiable from a random oracle. * * @param [in] hashed_data Output of some hash function. - * @param [out] pt The hashed input + * @param [out] pt The data hashed to the curve. */ void decaf_nonuniform_map_to_curve ( decaf_point_t pt, const unsigned char hashed_data[DECAF_SER_BYTES] ) API_VIS NONNULL2; + +/** + * @brief Indifferentiable hash function encoding to curve. + * + * Equivalent to calling decaf_nonuniform_map_to_curve twice and adding. + * + * @param [in] hashed_data Output of some hash function. + * @param [out] pt The data hashed to the curve. + */ +void decaf_uniform_map_to_curve ( + decaf_point_t pt, + const unsigned char hashed_data[2*DECAF_SER_BYTES] +) API_VIS NONNULL2; #undef API_VIS #undef WARN_UNUSED diff --git a/src/decaf.c b/src/decaf.c index d699eee..fbb92fc 100644 --- a/src/decaf.c +++ b/src/decaf.c @@ -414,6 +414,17 @@ void decaf_nonuniform_map_to_curve ( gf_mul(p->t,b,e); } + +void decaf_uniform_map_to_curve ( + decaf_point_t pt, + const unsigned char hashed_data[2*DECAF_SER_BYTES] +) { + decaf_point_t pt2; + decaf_nonuniform_map_to_curve(pt,hashed_data); + decaf_nonuniform_map_to_curve(pt2,&hashed_data[DECAF_SER_BYTES]); + decaf_add(pt,pt,pt2); +} + decaf_bool_t decaf_valid ( const decaf_point_t p ) {