]> git.codecow.com Git - Monocypher.git/log
Monocypher.git
6 years agoSaved 32 more bytes
Loup Vaillant [Sun, 6 Oct 2019 23:18:43 +0000 (01:18 +0200)]
Saved 32 more bytes

Also took care of Clang warnings in the process

6 years agoFused sliding windows and scalar multiplication
Loup Vaillant [Sun, 6 Oct 2019 22:45:05 +0000 (00:45 +0200)]
Fused sliding windows and scalar multiplication

At last, we saved some stack. 320 bytes on my machine, which is a bit
disappointing. We may be able to shave off a couple more, but we're
reaching the limit.

6 years agoIncremental left to right sliding windows
Loup Vaillant [Sun, 6 Oct 2019 21:58:38 +0000 (23:58 +0200)]
Incremental left to right sliding windows

The main loop of the scalar multiplication goes one by one, so we can't
have the sliding loop skip indices.  By adding a context that keeps
track of the next needed addition (as well as its value), we'll be able
to fuse the two slides and the scalar multiplication together.

6 years agoSlide from left to right
Loup Vaillant [Sun, 6 Oct 2019 20:12:42 +0000 (22:12 +0200)]
Slide from left to right

Scalar multiplication goes from left to right (from MSB to
LSB). Computing the sliding windows used to go from *right to left*.

This direction mismatch forced us to keep all the signed digits in
memory, which currently incur a little over 500 bytes of stack overhead.
That overhead is avoidable. Avoiding it will allow Monocypher to fit in
smaller embedded devices.

Right now we just change the direction of the sliding. Interleaving will
come later.

6 years agoCosmetic
Loup Vaillant [Sat, 5 Oct 2019 00:03:35 +0000 (02:03 +0200)]
Cosmetic

6 years agoRemoved kex documentation
Loup Vaillant [Fri, 4 Oct 2019 21:15:03 +0000 (23:15 +0200)]
Removed kex documentation

It will be corrected and added later, once we integrate the latest Monokex.

6 years agoCorrected C++ warning
Loup Vaillant [Sun, 29 Sep 2019 19:40:23 +0000 (21:40 +0200)]
Corrected C++ warning

6 years agoRemoved obsolete Monokex
Loup Vaillant [Sun, 29 Sep 2019 19:23:16 +0000 (21:23 +0200)]
Removed obsolete Monokex

That attempt had a crappy API, and was possibly insecure. Monokex has
since evolved significantly.

It will come back later, once we are sure everything is ironed out. In
the mean time, Monokex will ship separately.

6 years agoMissing variable time comment
Loup Vaillant [Sun, 29 Sep 2019 18:23:24 +0000 (20:23 +0200)]
Missing variable time comment

6 years agoignore QtCreator IDE files
Loup Vaillant [Sat, 28 Sep 2019 09:34:20 +0000 (11:34 +0200)]
ignore QtCreator IDE files

Assuming the project is called 'monocypher'.

6 years agoCorrected clang warnings
Loup Vaillant [Sat, 28 Sep 2019 09:30:47 +0000 (11:30 +0200)]
Corrected clang warnings

Those are easily visible through the QtCreator IDE intellisense, but
somehow never showed up when compiling at the command line.  This should
help silence MSVC warnings as well.

6 years agoHoisted negations out of loops
Loup Vaillant [Mon, 29 Jul 2019 22:43:35 +0000 (00:43 +0200)]
Hoisted negations out of loops

Turns out compilers don't do this naturally, and this leads to
observable slow downs in some cases.

Also noted that we are relying on 2's complement representation (we
already were).  We could be more portable by going unsigned, but by this
logic the entire field arithmetic should go unsigned.  It's possible,
but it's not trivial.  I've kinda tried it in the past, and failed.

Every architecture of interest is 2's complement anyway, so I think this
will be good enough.

6 years agoMoved trim_scalar() and scalar_bits() up a slot
Loup Vaillant [Mon, 29 Jul 2019 22:30:22 +0000 (00:30 +0200)]
Moved trim_scalar() and scalar_bits() up a slot

Those functions are used for both X25519 and EdDSA. Moving them up one
section makes it easier for user to delete the X-25519 section without
affecting EdDSA.

(Overall, Monocypher should let users delete the code they don't
need. This wasn't an explicit goal initially, but the code naturally
turned out that way.  Supporting this use case cost us nothing.)

6 years agoCosmetic
Loup Vaillant [Mon, 29 Jul 2019 22:28:03 +0000 (00:28 +0200)]
Cosmetic

6 years agoSaved 40 bytes of stack for EdDSA signing
Loup Vaillant [Sun, 28 Jul 2019 11:40:01 +0000 (13:40 +0200)]
Saved 40 bytes of stack for EdDSA signing

6 years agoSave some more stack
Loup Vaillant [Thu, 25 Jul 2019 09:23:55 +0000 (11:23 +0200)]
Save some more stack

6 years agoAdded X25519 Whycheproof test vectors
Loup Vaillant [Thu, 25 Jul 2019 06:49:16 +0000 (08:49 +0200)]
Added X25519 Whycheproof test vectors

6 years agoMinor cleanups
Loup Vaillant [Thu, 27 Jun 2019 20:36:23 +0000 (22:36 +0200)]
Minor cleanups

Multiplications by powers of two are supposed to be shifts.
It was not clear how we were ignoring the MSB of curve25519 points.

6 years agoWorked around TIS interpreter volatile bug
Loup Vaillant [Thu, 30 May 2019 22:33:54 +0000 (00:33 +0200)]
Worked around TIS interpreter volatile bug

6 years agoCorrected wrong man page redirection
Loup Vaillant [Tue, 28 May 2019 13:19:44 +0000 (15:19 +0200)]
Corrected wrong man page redirection

6 years agoFixed TweetNaCl speed tests
Loup Vaillant [Mon, 13 May 2019 21:26:26 +0000 (23:26 +0200)]
Fixed TweetNaCl speed tests

6 years agoMerge pull request #125 from fscoto/master
Loup Vaillant [Wed, 17 Apr 2019 06:15:40 +0000 (08:15 +0200)]
Merge pull request #125 from fscoto/master

Document BLAKE2 RFC

6 years agoDocument BLAKE2 RFC
Fabio Scotoni [Wed, 17 Apr 2019 04:19:38 +0000 (06:19 +0200)]
Document BLAKE2 RFC

7 years agoMerge pull request #124 from fscoto/master
Loup Vaillant [Thu, 4 Apr 2019 20:48:49 +0000 (22:48 +0200)]
Merge pull request #124 from fscoto/master

README: nitpicks

7 years agoREADME: nitpick: make links HTTPS where possible
Fabio Scotoni [Thu, 4 Apr 2019 13:11:55 +0000 (15:11 +0200)]
README: nitpick: make links HTTPS where possible

7 years agoREADME: nitpick: missing colon
Fabio Scotoni [Thu, 4 Apr 2019 11:05:36 +0000 (13:05 +0200)]
README: nitpick: missing colon

Options 1 and 2 had colons after them, but option 3 didn't.

7 years agoMerge pull request #123 from fscoto/master
Loup Vaillant [Thu, 4 Apr 2019 06:27:55 +0000 (08:27 +0200)]
Merge pull request #123 from fscoto/master

manual: roff formatting fixes

7 years agomanual: roff formatting fixes
Fabio Scotoni [Thu, 4 Apr 2019 04:22:04 +0000 (06:22 +0200)]
manual: roff formatting fixes

7 years agoMerge pull request #122 from fscoto/master
Loup Vaillant [Wed, 3 Apr 2019 20:21:40 +0000 (22:21 +0200)]
Merge pull request #122 from fscoto/master

Add HISTORY sections

7 years agomanual: Address HISTORY review concerns
Fabio Scotoni [Wed, 3 Apr 2019 17:06:23 +0000 (19:06 +0200)]
manual: Address HISTORY review concerns

7 years agoAdd HISTORY sections
Fabio Scotoni [Wed, 3 Apr 2019 04:08:25 +0000 (06:08 +0200)]
Add HISTORY sections

7 years agoClarified installation instructions
Loup Vaillant [Tue, 2 Apr 2019 20:59:56 +0000 (22:59 +0200)]
Clarified installation instructions

Related to #120

Made the 3 options (from source, from lib, system wide installation)
clearer, and stated the ability to change compilation flags explicitly.
(Those flags are all standards, but not everyone may know them).

7 years agoMerge pull request #121 from fscoto/master
Loup Vaillant [Tue, 2 Apr 2019 20:32:47 +0000 (22:32 +0200)]
Merge pull request #121 from fscoto/master

makefile: switch from $() to backticks

7 years agomakefile: switch from $() to backticks
Fabio Scotoni [Tue, 2 Apr 2019 11:03:03 +0000 (13:03 +0200)]
makefile: switch from $() to backticks

This fixes building with gmake on Solaris 10,
and likely some other platforms with /bin/sh before POSIX standardized
$() for command substitution.

Addresses issue #120.

7 years agoEdit nipick
Loup Vaillant [Sun, 31 Mar 2019 16:26:09 +0000 (18:26 +0200)]
Edit nipick

7 years agoMerge pull request #119 from fscoto/master
Loup Vaillant [Sun, 31 Mar 2019 13:18:14 +0000 (15:18 +0200)]
Merge pull request #119 from fscoto/master

Update manual with variable changes

7 years agocrypto_kex_{x,xk1} man pages: address review
Fabio Scotoni [Sun, 31 Mar 2019 12:57:26 +0000 (14:57 +0200)]
crypto_kex_{x,xk1} man pages: address review

7 years agoBetter represent Fabio Scotoni's involvment
Loup Vaillant [Sun, 31 Mar 2019 12:03:10 +0000 (14:03 +0200)]
Better represent Fabio Scotoni's involvment

7 years agoUpdate manual with variable changes
Fabio Scotoni [Sat, 30 Mar 2019 19:55:25 +0000 (20:55 +0100)]
Update manual with variable changes

Also pulls the descriptions of the arguments to the front,
which makes them easier to discern.

7 years agoFixed variable shadowing
Loup Vaillant [Sat, 23 Mar 2019 11:14:19 +0000 (12:14 +0100)]
Fixed variable shadowing

7 years agoOptimised Poly1305 loading code
Loup Vaillant [Fri, 22 Mar 2019 20:52:30 +0000 (21:52 +0100)]
Optimised Poly1305 loading code

By actually *rolling* the loading code.  I haven't looked at the
assembly, but I suspect the loop is easier for the compiler to
vectorise.

This results in a 5% speed increase on my machine (Intel i5 Skylake
laptop, gcc 7.3.0).

This fix was made possible by @Sadoon-AlBader on GitHub, who submitted
pull request #118

7 years agoClarified why some buffers are not wiped
Loup Vaillant [Thu, 14 Mar 2019 22:45:44 +0000 (23:45 +0100)]
Clarified why some buffers are not wiped

ge_msub() and ge_double_scalarmult_vartime() aren't clear why they don't
wipe their buffers.  I have added warnings that they indeed don't do so,
and thus should not be used to process secrets.

This also makes clear to auditors that failing to wipe the buffers was
intentional.

7 years agoArgon2 salts are at least 8 bytes
Loup Vaillant [Thu, 14 Mar 2019 22:44:55 +0000 (23:44 +0100)]
Argon2 salts are at least 8 bytes

7 years agoImproved the key exchange API
Loup Vaillant [Wed, 13 Mar 2019 23:10:26 +0000 (00:10 +0100)]
Improved the key exchange API

crypto_kex_ctx is now differentiated into a client specific context, and
a server specific context.  The distinction is entirely artificial (it's
the same thing under the hood), but it prevents some misuses at compile
time, making the API easier to use.

The name of the arguments have also been changed: "local" and "remote"
have been replaced by "client" and "server" whenever appropriate.  The
previous names made implementation easier, but their meaning was context
dependent, and thus confusing. The new names have stable meanings, and
thus easier to document and use.

TODO: update the manual to reflect those changes.

7 years agoMerge pull request #117 from fscoto/master
Loup Vaillant [Tue, 12 Mar 2019 07:14:04 +0000 (08:14 +0100)]
Merge pull request #117 from fscoto/master

man: fix whitespace and macro invocation issues

7 years agoman: fix whitespace and macro invocation issues
Fabio Scotoni [Tue, 12 Mar 2019 06:17:39 +0000 (07:17 +0100)]
man: fix whitespace and macro invocation issues

- There was some trailing whitespace on some of the lines of the new
  pages that I hadn't noticed.
- There was a .PP instead of .Pp.
- There was a .Fa with no space after it.

7 years agoMerge pull request #116 from fscoto/master
Loup Vaillant [Sun, 10 Mar 2019 17:04:55 +0000 (18:04 +0100)]
Merge pull request #116 from fscoto/master

LICENCE: update copyright year

7 years agoLICENCE: update copyright year
Fabio Scotoni [Sat, 9 Mar 2019 15:12:52 +0000 (16:12 +0100)]
LICENCE: update copyright year

Changes have been made since 2017.

7 years agoMerge pull request #115 from fscoto/master
Loup Vaillant [Thu, 7 Mar 2019 18:47:46 +0000 (19:47 +0100)]
Merge pull request #115 from fscoto/master

Add kex man pages

7 years agoAmerican -> British
Fabio Scotoni [Thu, 7 Mar 2019 10:24:35 +0000 (11:24 +0100)]
American -> British

7 years agoAddress points brought up by @LoupVaillant in review
Fabio Scotoni [Thu, 7 Mar 2019 09:48:35 +0000 (10:48 +0100)]
Address points brought up by @LoupVaillant in review

7 years agoAdd kex man pages
Fabio Scotoni [Wed, 6 Mar 2019 14:29:56 +0000 (15:29 +0100)]
Add kex man pages

7 years agoCorrected undefined behaviour in kex tests
Loup Vaillant [Mon, 4 Mar 2019 22:20:28 +0000 (23:20 +0100)]
Corrected undefined behaviour in kex tests

Calling those functions again on the same status not only does not make
any sense, it can grow the transcript beyond its maximum size of 128
bytes, which triggers a buffer overflow.  We needed to save the context
so we could re-run the relevant function where we left of.

It's the second time the TIS interpreter finds a bug that the other
sanitisers didn't.

7 years agoAdded secure channel protocols (experimental)
Loup Vaillant [Sun, 3 Mar 2019 21:56:29 +0000 (22:56 +0100)]
Added secure channel protocols (experimental)

At long last, the NaCl family of crypto libraries is gaining direct
support for secure channels.

Up until now, the choices were basically invent our own protocol, or
give up and use a TLS library, thus voiding the usability improvements
of NaCl libraries.

Now we have a solution.  It's still a bit experimental, it's not yet
documented, but it's there.  And soon, we will finally be able to shift
the cryptographic right answer for secure channels away from TLS, and
towards the NaCl family.  Or perhaps just Monocypher, if for some reason
Libsodium doesn't follow suit. :-)

7 years agoBuild: allow overwriting of symbolic link
Loup Vaillant [Sat, 2 Mar 2019 17:01:40 +0000 (18:01 +0100)]
Build: allow overwriting of symbolic link

7 years agoMore RFC number corrections
Loup Vaillant [Sun, 24 Feb 2019 08:33:35 +0000 (09:33 +0100)]
More RFC number corrections

RFC 7539 has been obsoleted by RFC 8439.
Incremental EdDSA didn't change to RFC 8032.

7 years agoCorrected RFC number in EdDSA manual
Loup Vaillant [Sat, 23 Feb 2019 19:47:56 +0000 (20:47 +0100)]
Corrected RFC number in EdDSA manual

7 years agoClarified Argon2 allocation in the manual
Loup Vaillant [Sat, 23 Feb 2019 19:32:44 +0000 (20:32 +0100)]
Clarified Argon2 allocation in the manual

7 years agoAdded comment on speed tests
Loup Vaillant [Fri, 22 Feb 2019 20:14:06 +0000 (21:14 +0100)]
Added comment on speed tests

The way I measure timings is not perfectly portable. Users who
get weird results are encouraged to modify this bit of code to
have proper measurements.

7 years agoFixed speed-sodium build
Loup Vaillant [Fri, 22 Feb 2019 07:53:32 +0000 (08:53 +0100)]
Fixed speed-sodium build

7 years agoRemoved division by zero in speed benchmarks
Loup Vaillant [Sun, 17 Feb 2019 18:25:52 +0000 (19:25 +0100)]
Removed division by zero in speed benchmarks

If some library is so fast that it goes below the resolution of the
timer we're using to measure it, the measured duration may be zero, and
then trigger a division by zero when we convert it to a speed in Hz.

This could possibly happen with a very fast library (Libsodium), on a
very fast machine, with a sufficiently low resolution timer.

This patch reworks and simplifies things a bit, and adds an explicit
check. We now print "too fast to be measured" instead of dividing by
zero.

7 years agoDocumentation typo
Loup Vaillant [Fri, 15 Feb 2019 07:29:49 +0000 (08:29 +0100)]
Documentation typo

7 years agoWrong array size in function argument
Loup Vaillant [Sun, 3 Feb 2019 10:59:02 +0000 (11:59 +0100)]
Wrong array size in function argument

Fixes #114

Most proably harmless, but nevertheless ugly.

7 years agoForgot Libsodium include dependency
Loup Vaillant [Mon, 28 Jan 2019 23:20:31 +0000 (00:20 +0100)]
Forgot Libsodium include dependency

7 years agoAllow the test suite to customise its random seed
Loup Vaillant [Sat, 26 Jan 2019 14:44:01 +0000 (15:44 +0100)]
Allow the test suite to customise its random seed

This will only affect the property based tests, not the test vectors
themselves.  The idea is to let paranoid users run the test suite with
lots and lots of different streams of random numbers, just to be safe.

Test vector generation could undergo a similar transformation, though it
is less likely to be worth the trouble (we'd have to generate the test
vectors, compile the test suite all over again).

7 years agoLink SHA-512 code when using -DED25519_SHA512
Loup Vaillant [Fri, 25 Jan 2019 14:43:02 +0000 (15:43 +0100)]
Link SHA-512 code when using -DED25519_SHA512

When the $CFLAGS variable contains the -DED25519_SHA512 option (by
default it doesn't), the code from src/optional/sha512.c is
automatically linked to the final libraries (libmonocypher.a and
libmonocypher.so).

That way, users who need to install a ED25519 compliant version of
Monocypher can do so simply by altering the compilation options with the
$CFLAGS variable.

7 years agoMade L an array of *signed* integers
Loup Vaillant [Sun, 20 Jan 2019 21:42:38 +0000 (22:42 +0100)]
Made L an array of *signed* integers

Was unsigned previously, causing a bunch of implementation defined
conversions.  No machine nowadays are no 2's complement, but it's still
cleaner that way.

7 years agoTry not to waste the stack
Loup Vaillant [Fri, 14 Dec 2018 20:12:33 +0000 (21:12 +0100)]
Try not to waste the stack

7 years agoFixed MSVC W4 warnings
Loup Vaillant [Fri, 14 Dec 2018 20:03:54 +0000 (21:03 +0100)]
Fixed MSVC W4 warnings

Fixes #112

7 years agoDecoupled window widths, minimised stack usage
Loup Vaillant [Thu, 6 Dec 2018 00:04:37 +0000 (01:04 +0100)]
Decoupled window widths, minimised stack usage

The width of the pre-computed window affects the program size. It has
been set to 5 (8 elements) so we can approach maximum performance
without bloating the program too much.

The width of the cached window affects the *stack* size. It has been set
to 3 (2 elements) to avoid blowing up the stack (this matters most on
embedded environments). The performance hit is measurable, yet very
reasonable.

Footgun wielders can adjust those widths as they see fit.

7 years agoInlined window caching
Loup Vaillant [Wed, 5 Dec 2018 23:46:07 +0000 (00:46 +0100)]
Inlined window caching

7 years agoOptimised addition of base point window
Loup Vaillant [Wed, 5 Dec 2018 23:39:49 +0000 (00:39 +0100)]
Optimised addition of base point window

7 years agoFully pre-compute the base point window
Loup Vaillant [Wed, 5 Dec 2018 22:44:33 +0000 (23:44 +0100)]
Fully pre-compute the base point window

7 years agoParameterise sliding window width with a macro
Loup Vaillant [Wed, 5 Dec 2018 22:16:55 +0000 (23:16 +0100)]
Parameterise sliding window width with a macro

This is more general, perhaps even more readable this way. This also
lays the groundwork for using different window widths for the
pre-computed window and the cached one. (The cached window has to be
smaller to save stack space, while the pre-computed constant is allowed
to be bigger).

7 years agoTest -DBLAKE2_NO_UNROLLING flag
Loup Vaillant [Thu, 29 Nov 2018 22:05:23 +0000 (23:05 +0100)]
Test -DBLAKE2_NO_UNROLLING flag

7 years agoConvert int indices to size_t
Loup Vaillant [Thu, 29 Nov 2018 21:32:39 +0000 (22:32 +0100)]
Convert int indices to size_t

Fixes #111 (MSVC warnings)

All indices in Monocypher are size_t.  We might as well be consistent.

7 years agoAdded -DBLAKE2_NO_UNROLLING preprocessor option
Loup Vaillant [Sat, 10 Nov 2018 12:59:38 +0000 (13:59 +0100)]
Added -DBLAKE2_NO_UNROLLING preprocessor option

Less bloat, faster on some embedded platforms.

7 years agoConst correctness
Loup Vaillant [Fri, 2 Nov 2018 16:27:41 +0000 (17:27 +0100)]
Const correctness

7 years agoNo intermediate buffer for HChacha20
Loup Vaillant [Tue, 23 Oct 2018 19:06:47 +0000 (21:06 +0200)]
No intermediate buffer for HChacha20

That buffer wasn't really needed, so I optimised it away

7 years agoOverlap test for HChacha20
Loup Vaillant [Tue, 23 Oct 2018 19:05:12 +0000 (21:05 +0200)]
Overlap test for HChacha20

7 years agoManual: wrong nonce size in examples
Loup Vaillant [Sun, 23 Sep 2018 16:24:03 +0000 (18:24 +0200)]
Manual: wrong nonce size in examples

7 years agoRemoved version numbers from coverage script
Loup Vaillant [Sat, 15 Sep 2018 13:21:29 +0000 (15:21 +0200)]
Removed version numbers from coverage script

7 years agoMerge pull request #108 from fscoto/master+doc/windows-random
Loup Vaillant [Tue, 28 Aug 2018 14:22:02 +0000 (16:22 +0200)]
Merge pull request #108 from fscoto/master+doc/windows-random

Recommend BCryptGenRandom on Windows

7 years agoRecommend BCryptGenRandom on Windows
Fabio Scotoni [Tue, 28 Aug 2018 13:23:22 +0000 (15:23 +0200)]
Recommend BCryptGenRandom on Windows

CryptGenRandom is deprecated.

7 years agoBetter code coverage for EdDSA
Loup Vaillant [Fri, 24 Aug 2018 22:28:30 +0000 (00:28 +0200)]
Better code coverage for EdDSA

7 years agoC++ compatibility
Loup Vaillant [Thu, 23 Aug 2018 18:25:48 +0000 (20:25 +0200)]
C++ compatibility

7 years ago2.0.5 changelog
Loup Vaillant [Thu, 23 Aug 2018 18:15:36 +0000 (20:15 +0200)]
2.0.5 changelog

7 years agofe_ccopy() now works the same as fe_cswap()
Loup Vaillant [Mon, 20 Aug 2018 16:58:19 +0000 (18:58 +0200)]
fe_ccopy() now works the same as fe_cswap()

7 years agocosmetic
Loup Vaillant [Sat, 18 Aug 2018 10:23:14 +0000 (12:23 +0200)]
cosmetic

7 years agoAdded tests for HChacha20
Loup Vaillant [Thu, 16 Aug 2018 19:29:13 +0000 (21:29 +0200)]
Added tests for HChacha20

Not that it needed any (XChacha20 were enough), but it's easier to
communicate to outsiders that HChacha20 is correct when we have explicit
test vectors.

7 years agoProperly prevent S malleability
Loup Vaillant [Wed, 15 Aug 2018 18:02:03 +0000 (20:02 +0200)]
Properly prevent S malleability

S malleability was mostly prevented in a previous commit, for reasons
that had nothing to do with S malleability.  This mislead users into
thinking Monocypher was not S malleable.

To avoid confusion, I properly verify that S is strictly lower than L
(the order of the curve).  S malleability is no longer a thing.

We still have nonce malleability, but that one can't be helped.

Also added Wycheproof test vectors about malleability.

7 years agoSimplified sliding windows a bit
Loup Vaillant [Tue, 14 Aug 2018 10:59:17 +0000 (12:59 +0200)]
Simplified sliding windows a bit

7 years agoRemoved sliding windows edge cases
Loup Vaillant [Mon, 13 Aug 2018 11:05:39 +0000 (13:05 +0200)]
Removed sliding windows edge cases

By making sure the scalar's most significant bits are 0, we remove an
edge case, and can skip the epilogue of the sliding windows.

This adds 2 bytes to the sliding windows representation of the scalars,
but also makes the code smaller and simpler.

7 years agoCorrected wrong comment
Loup Vaillant [Sun, 12 Aug 2018 11:04:39 +0000 (13:04 +0200)]
Corrected wrong comment

7 years agoSigned sliding windows for EdDSA
Loup Vaillant [Sat, 11 Aug 2018 18:05:28 +0000 (20:05 +0200)]
Signed sliding windows for EdDSA

Signed sliding windows are effectively one bit wider than their unsigned
counterparts, without doubling the size of the corresponding look up
table.  Going from 4-bit unsigned to 5-bit signed allowed us to gain
almost 17 additions on average.

This gain is less impressive than it sounds: the whole operation still
costs 254 doublings and 56 additions, and going signed made window
construction and look up a bit slower.  Overall, we barely gained 2.5%.

We could gain a bit more speed still by precomputing the look up table
for the base point, but the gains would be similar, and the costs in
code size and complexity would be even bigger.

7 years agoReduced EdDSA malleability for sliding windows
Loup Vaillant [Sat, 11 Aug 2018 16:19:35 +0000 (18:19 +0200)]
Reduced EdDSA malleability for sliding windows

Signed sliding windows can overflow the initial scalar by one bit.  This
is not a problem when the scalar is reduced modulo L, which is smaller
than 2^253.  The second half of the signature however is controlled by
the attacker, and can be any value.

Legitimate signatures however always reduce modulo L.  They don't really
have to, but this helps with determinism, and enables test vectors.  So
we can safely reject any signature whose second half exceeds L.

This patch rejects anything above 2^253-1, thus guaranteeing that the
three most significant bits are cleared.  This eliminate s-malleability
in most cases, but not all.  Besides, there is still nonce malleability.

Users should still assume signatures are malleable.

7 years agoEdDSA double scalarmult can now subtract
Loup Vaillant [Sat, 11 Aug 2018 16:06:35 +0000 (18:06 +0200)]
EdDSA double scalarmult can now subtract

This allows it to handle signed sliding windows (not yet implemented).

7 years agoEdDSA sliding windows now indicate the number
Loup Vaillant [Sat, 11 Aug 2018 15:36:14 +0000 (17:36 +0200)]
EdDSA sliding windows now indicate the number

This is in preparation for signed sliding windows.  Instead of choosing
-1 for doing nothing, and an index to point to the table, we write how
much we add directly (that means 0 for nothing).  We divide the number
by 2 to get the index.

The double scalarmult routine doesn't handle negative values yet.

7 years agoThank Mike Hamburg for his advice on comb algorithms
Loup Vaillant [Fri, 10 Aug 2018 23:39:20 +0000 (01:39 +0200)]
Thank Mike Hamburg for his advice on comb algorithms

7 years agoReferenced the signed comb for EdDSA
Loup Vaillant [Fri, 10 Aug 2018 20:48:14 +0000 (22:48 +0200)]
Referenced the signed comb for EdDSA