18 Commits

Author SHA1 Message Date
Frank Denis
fc55cd458a Hash functions now accept an option set
- This avoids having multiple `init()` functions for every combination
of optional parameters
- The API is consistent across all hash functions
- New options can be added later without breaking existing applications.
  For example, this is going to come in handy if we implement parallelization
  for BLAKE2 and BLAKE3.
- We don't have a mix of snake_case and camelCase functions any more, at
least in the public crypto API

Support for BLAKE2 salt and personalization (more commonly called context)
parameters have been implemented by the way to illustrate this.
2020-08-21 00:51:14 +02:00
Frank Denis
6f9ea9eaef Breaking: sort std/crypto functions into categories
Instead of having all primitives and constructions share the same namespace,
they are now organized by category and function family.

Types within the same category are expected to share the exact same API.
2020-08-20 23:02:05 +02:00
Andrew Kelley
4a69b11e74 add license header to all std lib files
add SPDX license identifier
copyright ownership is zig contributors
2020-08-20 16:07:04 -04:00
Frank Denis
8d60047697 ristretto255: add uniform string->element map & fast equivalence check 2020-08-18 00:31:02 -04:00
Frank Denis
7f9a227abf deinline edwards25519.{add,dbl} 2020-08-16 22:35:28 -07:00
Frank Denis
37ae246405 Inline Fe.{sub,mul,sq} for a performance boost in release-safe mode 2020-08-16 22:35:28 -07:00
Frank Denis
ab6ffa8a3c Work around sqrtRatioM1() issue in release-safe mode 2020-08-16 22:35:28 -07:00
Frank Denis
5ab69633b7 Constify the ladder 2020-08-16 22:35:27 -07:00
Frank Denis
d86cde5752 Add comment, use @truncate 2020-08-16 22:35:27 -07:00
Frank Denis
bcef123d90 Address more review issues 2020-08-16 22:35:27 -07:00
Frank Denis
263c444738 Move loop decrements into continuations
Suggested by @daurnimator
2020-08-16 22:35:27 -07:00
Frank Denis
ed558bfbaa Address @daurnimator feedback 2020-08-16 22:35:27 -07:00
Frank Denis
dd8f7b396c Rename the field and scalar modules
Suggested by @kubkon
2020-08-16 22:35:27 -07:00
Frank Denis
c483bf4f97 Update lib/std/crypto/25519/ristretto255.zig
Co-authored-by: Jakub Konka <kubkon@jakubkonka.com>
2020-08-16 22:35:27 -07:00
Frank Denis
739b68938c Update lib/std/crypto/25519/field25519.zig
Co-authored-by: Jakub Konka <kubkon@jakubkonka.com>
2020-08-16 22:35:27 -07:00
Frank Denis
6af9bc8c68 Initialize structures directly
Suggested by @kubkon, thanks!
2020-08-16 22:35:27 -07:00
Frank Denis
5f9953f41f Remove mem.timingSafeEqual() for now
This requires assembly implementations, and is not needed for
signature verification.

Thanks @daurnimator
2020-08-16 22:35:27 -07:00
Frank Denis
3f0d80f25e Improve curve25519-based crypto
This is a rewrite of the x25519 code, that generalizes support for
common primitives based on the same finite field.

- Low-level operations can now be performed over the curve25519 and
edwards25519 curves, as well as the ristretto255 group.
- Ed25519 signatures have been implemented.
- X25519 is now about twice as fast.
- mem.timingSafeEqual() has been added for constant-time comparison.

Domains have been clearly separated, making it easier to later add
platform-specific implementations.
2020-08-16 22:35:27 -07:00