Commit graph

1459 commits

Author SHA1 Message Date
Michael Rosenberg
94a99d82f8
README: Removed non-existent features 2022-12-12 03:03:40 -05:00
Michael Rosenberg
82a2d4c9e4
Merge branch 'main' into release/4.0 2022-12-12 02:59:09 -05:00
Michael Rosenberg
f38d677759
Updated CHANGELOG; added stable/beta instructions to README 2022-12-12 02:54:25 -05:00
Tony Arcieri
6f237a0810
Use inherent constants for ZERO, ONE, and MINUS_ONE (#470)
For the field element types `FieldElement` and `Scalar`, use inherent
constants instead of (non-const) functions to return these constant
values.

It's likely the original functions predate support for inherent
constants, but now that they're available, they're a better fit for
these sort of constant values.
2022-12-12 01:04:42 -05:00
pinkforest(she/her)
acd78987f9
Document curve25519_dalek_ backend and bits selection (#467)
Co-authored-by: Michael Rosenberg <michael@mrosenberg.pub>
2022-12-11 16:37:50 -05:00
Tony Arcieri
fa45d21b76
Use CryptoRngCore trait (#469)
This is a convenience/marker trait for types which impl `CryptoRng` +
`RngCore` which makes the type signatures a little more readable.

It was introduced in `rand_core` v0.6.4 (now pinned as the minimum
version)
2022-12-11 15:11:15 -05:00
pinkforest(she/her)
cb42e87096
Fixes curve25519_dalek_bits defaults for cross and wasm (#465)
build.rs was using cfg(target) but it has to evaluate this from env TARGET
as build.rs cfg(target) in build context is the builder host and not the target.

This change fixes curve25519_dalek_bits lottery to determine the correct
automatic curve25119_dalek_bits with the help of platforms crate.

As discussed in #456 this also prepares for well known defaults for wasm and
arm serial backend via cfg(curve25519_dalek_bits = "64")

If the wasm32 or armv7 are going to be u64 serial by default these will be
followed up on later.
2022-12-09 21:09:24 -05:00
Tony Arcieri
cc304c29ff
Use --cfg curve25519_dalek_backend to select backend (#455)
Crate features are intended to be additive, whereas only 1-of-N possible
backends can be selected.

Features can also be activated by transitive dependencies, which leads
to a problem of different dependences selecting conflicting backends.
Using `--cfg` instead moves all backend selection control to the
toplevel executable.

This commit switches to the following RUSTFLAGS to enable backends:

- `--cfg curve25519_dalek_backend="fiat"`: uses `fiat-crypto`
- `--cfg curve25519_dalek_backend="simd"`: uses nightly-only SIMD
2022-12-09 03:42:52 -05:00
Michael Rosenberg
f5dada3834
Updates to README (#453)
* Restructure README and CHANGELOG
* Explain semver policy
* Specify feature flags and backends more explicitly
* Remove nightly from the CI bc that didn't belong there
* Add @pinkforest to thankyou list

Co-authored-by: pinkforest <36498018+pinkforest@users.noreply.github.com>
2022-12-09 03:30:44 -05:00
Tony Arcieri
1e490bd001
Fix --no-default-features test warnings; consolidate CI jobs (#461)
Previously `cargo test --no-default-features` would succeed but with
warnings. This commit fixes all of those warnings and tests
`--no-default-features` in CI to ensure that in perpetuity.
2022-12-08 23:26:18 -05:00
Michael Rosenberg
0b72bb5dc2
Made Scalar::bits return an iterator rather than an array (#451)
Addresses issue #448 that Scalar::bits may leave unzeroed bits on the stack
2022-12-08 16:37:42 -05:00
Michael Rosenberg
42e93d7faf
Remove mocks (#460)
Gated random() construtors on cfg(test)
2022-12-08 15:36:22 -05:00
Tony Arcieri
1013560fe4
Remove std feature (#459)
All of the existing usages of `std` can be replaced with `alloc`.

They are legacy usages from before when liballoc was stabilized.
2022-12-08 15:05:59 -05:00
pinkforest(she/her)
6b56edf776
Make digest optional (#446)
As proposed in #442 this makes `digest` an
optional feature that is not covered by the
SemVer public API stability guarantees.

Co-authored-by: Michael Rosenberg <michael@mrosenberg.pub>
2022-12-08 13:59:28 -05:00
pinkforest(she/her)
47a0c3eacc
Make rand_core optional (#447)
As proposed in #442 this makes `rand_core` an
optional feature that is not covered by the
SemVer public API stability guarantees.

Co-authored-by: Michael Rosenberg <michael@mrosenberg.pub>
2022-12-08 13:50:17 -05:00
pinkforest(she/her)
2190332b67
Add target u32/u64 backend override (#454)
As suggested in #453 it is sometimes feasible to
select the backend bits via an override.

This change provides `cfg(curve25519_dalek_bits)`
to override the bits used in serial or fiat target backend.
2022-12-08 11:52:42 -05:00
pinkforest(she/her)
29466f1b45
Minor documentation fixes (#444)
* Docs unlink from dalek.rs

* Link katex assets to jsdelivr

Co-authored-by: Michael Rosenberg <michael@mrosenberg.pub>
2022-12-07 05:36:07 -05:00
pinkforest(she/her)
e01bb1bdc6
Fix all clippy warnings replay (#441)
Also fixes CI not running on all branches

Co-authored-by: Anthony Ramine <nox@nox.paris>
2022-12-04 03:40:51 -05:00
Michael Rosenberg
03b8668b29
Merge pull request #440 from dalek-cryptography/docs-cleanup 2022-11-26 22:00:45 -05:00
Michael Rosenberg
edf6db09ab
Merge pull request #439 from pinkforest/docs-cleanup 2022-11-26 21:42:30 -05:00
Chris Beck
840a9dc866
Relax Rng trait bounds to allow ?Sized Rngs (#394)
This allows the code to compile if you pass it `&mut dyn RngType`,
since trait objects are unsized.

See here for an example of caller code that is simplified by this
change:

https://github.com/mobilecoinfoundation/mobilecoin/pull/1977#discussion_r872906913
2022-11-26 20:56:04 -05:00
Michael Rosenberg
1ddad1858f
Fixed README image layout and gave the logo the alt text described in #89 2022-11-26 14:11:57 -05:00
Michael Rosenberg
01672bfc63
Applied @pinkforest's patch to make make doc build on non-x86_64 arches 2022-11-26 13:53:51 -05:00
Michael Rosenberg
791ba170b1 Cleanup: enabled doc_auto_cfg and doc_cfg_hide 2022-11-26 06:34:48 -05:00
pinkforest
289cc52fef Document backend mod as INTERNALS: 2022-11-26 22:20:18 +11:00
pinkforest
8d236f5279 Fix curve_models link for parallel formulas doc 2022-11-26 22:10:14 +11:00
Michael Rosenberg
fec474b1ba Shouldn't have removed stdsimd feature 2022-11-26 05:58:29 -05:00
Michael Rosenberg
3e1643a99d Fixed features to tell docs.rs to use 2022-11-26 05:55:48 -05:00
Michael Rosenberg
774e56e2c1 Removed unnecessary unstable features 2022-11-26 05:54:22 -05:00
Michael Rosenberg
a35ca1e9cf Added cfg_attr everywhere possible, and simplified cfg over std/alloc 2022-11-26 05:53:28 -05:00
Michael Rosenberg
4b08687093 Fixed broken latex in parallel-formulas.md 2022-11-26 04:10:21 -05:00
pinkforest
ad7c755f49 Documentation migrate to docs.rs hosted
This change migrates all the documentation from dalek.rs
to docs.rs hosted and fixed the backend documentation
generation that was broken.
2022-11-26 11:26:25 +11:00
Michael Rosenberg
c604520311
Made docs makefile use nightly 2022-11-24 02:37:07 -05:00
Michael Rosenberg
969940e954
Wibble 2022-11-24 02:37:07 -05:00
Michael Rosenberg
a743ea5348
Fixed doc warnings 2022-11-24 02:37:05 -05:00
Michael Rosenberg
45d6adba73
Updated CHANGELOG to reflect recent PRs 2022-11-24 02:32:20 -05:00
Michael Rosenberg
6eafb1ebda
Deprecate EdwardsPoint::hash_from_bytes (#438)
* Deprecated `EdwardsPoint::hash_from_bytes` and renamed to
  `EdwardsPoint::nonspec_map_to_curve`

* Added KAT test vectors for `RistrettoPoint::from_uniform_bytes`
2022-11-24 01:45:03 -05:00
Tony Arcieri
f88cf6836b
Use include_str! for .md inclusion in rustdoc (#434)
Previously a now-removed nightly-only feature was used, but now that
it's stable, `include_str!` can be used for all of these cases.
2022-11-14 00:22:50 -05:00
Tony Arcieri
d05afa02a3
Add alloc feature gates to simd tests that need it (#433) 2022-11-14 00:11:23 -05:00
Tony Arcieri
7d275100bf
CI: fix build-simd job (#436)
The `RUSTFLAGS` were getting applied to build scripts, which caused them
to crash with SIGILL.

According to this issue, RUSTFLAGS won't be applied to build scripts
when cross-compiling by passing the `--target` attribute:

https://github.com/rust-lang/cargo/issues/4423

This attempts to work around the problem by explicitly passing:

    --target x86_64-unknown-linux-gnu
2022-11-13 23:21:24 -05:00
Tony Arcieri
081f632d91
Implement simplified backend selection (#428)
As proposed in #414, this commit changes the backend selection approach,
introspecting `target_pointer_width` to select `u32_backend` vs
`u64_backend` (or `fiat_u32_backend`/`fiat_u64_backend` if the
`fiat_backend` feature is enabled).

This helps eliminate the use of non-additive features, and also the
rather confusing errors that happen if multiple backends are selected
(i.e. thousands of lines of rustc errors).

The selection logic checks if `target_pointer_width = "64"` and uses the
64-bit backend, or falls back to the 32-bit backend otherwise. This
means the crate will always have a valid backend regardless of the
pointer width, although there may be odd edge cases for exotic platforms
which would optimally use the 64-bit backend but have a non-"64" target
pointer width for whatever reason. We can handle those cases as they
come up.
2022-11-13 12:17:42 -05:00
pinkforest(she/her)
977eb0d3b7
Bump criterion to 0.4.0 (#432) 2022-11-13 01:36:46 -05:00
Michael Rosenberg
e85e3c047b
Merge pull request #429 from pinkforest/docs/readme/de-dup
Use #[include_str] for top-level docs
2022-11-13 01:03:37 -05:00
pinkforest
62fe24e022 Include README.md into the crate Documentation
As proposed in #426 this commit changes to include README.md into
the crate documentation instead of maintaining a carbon copy in
the code.

This helps to keep the documentation in a single place without
duplicating the documentation in multiple places leading to less
errors and out of date documentation.
2022-11-11 22:36:57 +11:00
Michael Rosenberg
90292dccf8
Relaxed zeroize dependency 2022-11-10 03:44:26 -05:00
Thomas Pornin
d687cc8f82
Fix double-and-compress on Ristretto identity (issue #398). (#399) 2022-11-05 11:35:30 -04:00
Michael Rosenberg
0d75725da3
Merge pull request #424 from rozbb/rustfmt
Did a full formatting pass on the crate. Read the comments in the referenced for
steps to verify that the PR made no semantic changes to the code. Huge credit
goes to @robjtede for this work.
2022-11-04 03:03:32 -04:00
Michael Rosenberg
d2bf310330
cargo fmt 2022-10-28 17:00:24 -04:00
Michael Rosenberg
a959787c2e
Added more #[rusfmt::skip] 2022-10-28 16:58:40 -04:00
Michael Rosenberg
95b368a431
Whitespace formatting fixes on the [rustfmt::skip] functions 2022-10-28 16:32:45 -04:00