]> git.codecow.com Git - Monocypher.git/commit
Elligator: take cofactor from secret key instead of tweak
authorLoup Vaillant <loup@loup-vaillant.fr>
Wed, 18 Mar 2020 14:40:04 +0000 (15:40 +0100)
committerLoup Vaillant <loup@loup-vaillant.fr>
Wed, 18 Mar 2020 15:15:41 +0000 (16:15 +0100)
commit1874deb647df9ece06573fe7f79fd50f2ca6eb20
tree99bd62e204b600e71ee5a6062a3e38a0271c7b13
parentbc1ba59d9521fd19bb5bfde12681399a20359549
Elligator: take cofactor from secret key instead of tweak

This allows the simplification of the implementation of higher level
interfaces.

The idea is, only the scalar and cofactor have any influence over
whether the inverse map succeeds or fail. This means that when it fails,
the padding & sign have not be used at all, and can be "reused" to
generate another random seed.

In practice, this means we can use Chacha20 or Blake2, or any hash that
outputs 64 random bytes from 32 random bytes, use 32 bytes to make an
attempt, then use the *other* 32 bytes to either generate more random
bytes (if we failed), or to use the tweak (if we succeed).

The tweak has also been modified to simplify the implementation. The
sign bit is now the least significant bit, and the padding bits are the
most significant bits. The computational savings are negligible, but
this allows neat micro-simplifications.
src/monocypher.c
tests/gen/elligator-inverse.py