From dc7d8fd9e2576c399a7ed25aa98b0f23ffac6766 Mon Sep 17 00:00:00 2001 From: Marko Bencun Date: Thu, 16 Jan 2020 16:48:49 +0100 Subject: [PATCH 1/2] scalar: extend docstring of secp256k1_scalar_set_b32 --- src/scalar.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/scalar.h b/src/scalar.h index 59304cb66e905..1ee50e1fa174b 100644 --- a/src/scalar.h +++ b/src/scalar.h @@ -32,7 +32,11 @@ static unsigned int secp256k1_scalar_get_bits(const secp256k1_scalar *a, unsigne /** Access bits from a scalar. Not constant time. */ static unsigned int secp256k1_scalar_get_bits_var(const secp256k1_scalar *a, unsigned int offset, unsigned int count); -/** Set a scalar from a big endian byte array. */ +/** Set a scalar from a big endian byte array. The scalar will be reduced modulo group order `n`. + * In: bin: pointer to a 32-byte array. + * Out: r: scalar to be set. + * overflow: non-zero if the scalar was bigger or equal to `n` before reduction, zero otherwise (can be NULL). + */ static void secp256k1_scalar_set_b32(secp256k1_scalar *r, const unsigned char *bin, int *overflow); /** Set a scalar to an unsigned integer. */ From dabfea7e217b129d10f0f787722626f388dddb5a Mon Sep 17 00:00:00 2001 From: Marko Bencun Date: Thu, 16 Jan 2020 16:52:09 +0100 Subject: [PATCH 2/2] field: extend docstring of secp256k1_fe_normalize --- src/field.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/field.h b/src/field.h index bb6692ad57835..8283e4b182e70 100644 --- a/src/field.h +++ b/src/field.h @@ -32,10 +32,12 @@ #include "util.h" -/** Normalize a field element. */ +/** Normalize a field element. This brings the field element to a canonical representation, reduces + * its magnitude to 1, and reduces it modulo field size `p`. + */ static void secp256k1_fe_normalize(secp256k1_fe *r); -/** Weakly normalize a field element: reduce it magnitude to 1, but don't fully normalize. */ +/** Weakly normalize a field element: reduce its magnitude to 1, but don't fully normalize. */ static void secp256k1_fe_normalize_weak(secp256k1_fe *r); /** Normalize a field element, without constant-time guarantee. */