From 59647d1a9645d26f2643965b5b865c5c6b3fec33 Mon Sep 17 00:00:00 2001 From: Miguel Oliveira Date: Wed, 2 Mar 2022 15:18:28 -0300 Subject: [PATCH] Move clamped Fq decoding into fq.lua --- internal/fq.lua | 18 ++++++++++++++++++ x25519c.lua | 16 ++-------------- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/internal/fq.lua b/internal/fq.lua index 294044b..25120ee 100644 --- a/internal/fq.lua +++ b/internal/fq.lua @@ -280,6 +280,23 @@ local function decodeWide(str) return add(montgomery(low), montgomery(montgomery(high))) end +--- Decodes a scalar using the X25519/Ed25519 bit clamping scheme. +-- +-- @tparam string str A 32-byte string encoding some little-endian number a. +-- @treturn 2²⁶⁵ * clamp(a) mod q as 11 linbs in [0..2²⁴). +-- +local function decodeClamped(str) + -- Decode. + local words = {("