Commit graph

110 commits

Author SHA1 Message Date
8fa9083e12 patch: remove ConditionallyNegatable for Aeneas/Charon transpilation
Upstream: dalek-cryptography/curve25519-dalek v5.0.0-rc.1
Required for: formal verification via Aeneas bf13c42e + Charon 9dd7f23c
2026-06-30 17:30:35 +02:00
Nazar Mokrynskyi
4cf8db2369
Support AVX512 on stable Rust (#913)
Fixes #758
2026-06-29 08:44:40 -06:00
Michael Rosenberg
d995caf38f
Prep v5.0-rc.1 (#911) 2026-06-18 07:42:04 +02:00
Michael Rosenberg
1c14d54c60
curve: Bring back ff and group (#909)
* Revert "curve: Remove ff/group features for now (#907)"

This reverts commit 13ac5e66a7.

* Fix build

* Remove group-bits features for soundness concerns

* Update changelog
2026-06-13 16:13:18 -04:00
Riolku
58b331cde9
curve,x,ed: re-export rand_core (#908)
* x25519: re-export rand_core

Since these types appear in our public API, we should re-export it.

Closes #741.
2026-06-08 17:39:51 +02:00
Michael Rosenberg
70e82aa855
Prep v5.0-rc.0 (#906)
* Bump versions for release

* Correct internal lizard docs

* Make changelogs more thorough
2026-05-28 21:46:01 +02:00
Michael Rosenberg
13ac5e66a7
curve: Remove ff/group features for now (#907) 2026-05-25 21:50:58 +02:00
Tony Arcieri
594808680c
ed25519-dalek: bump ed25519 crate dependency to v3.0.0 (#903)
* [WIP] ed25519-dalek: bump `ed25519` crate dependency to v3.0.0

This has two test failures:

    serialisation::serialize_deserialize_signature_json
    serialisation::serialize_signature_size

These are due to a last minute change to use `serdect` for implementing
`serde` support: RustCrypto/signatures#1324.

The signature size regression from `64` to `72` is a deliberate tradeoff
we've accepted in `serdect`. First note that this test is for now the
unmaintained `bincode` crate.

The core problem is that `serde` does not actually provide fixed-size
arrays as a type within its data model (serde-rs/serde#1937) and you're
instead left faking it using `SerializeTuple` and serializing it a
byte-at-a-time as a tuple. While this gives optimal-sized results on
`bincode`, it gives less-than-optimal results on e.g. `rmp-serde` where
the bytes each end up tagged with a type prefix.

`serde` does provide portable APIs for using optimal format-specific
byte encodings, but they carry an additional length prefix, which is
unnecessary and suboptimal for something fixed-width like an Ed25519
signature, but alas as noted earlier `serde` does not actually have
fixed-width arrays in its data model.

The second test failure occurs specifically because `serdect`
introspects the format and uses `base16ct` to perform hex serialization
for human readable formats. While this is a readability improvement for
these formats (and also makes them easier to implement in constant-time,
though it's not relevant here), the drawback is it currently requires
the `alloc` feature for such formats, which is a regression:

    Error("serializer is human readable, which requires the `alloc` crate feature", line: 0, column: 0)

Note that regardless these are both breaking changes to how `serde`
serialization is handled.

See also:
- RustCrypto/formats#1111
- RustCrypto/formats#1112
- dalek-cryptography/ed25519-dalek#140

* Migrate bincode -> postcard

* Bump `serdect` to v0.4.3

Includes `no_alloc` hex serialization support

---------

Co-authored-by: Michael Rosenberg <mrosenberg@cloudflare.com>
2026-05-03 22:26:26 -04:00
Arthur Gautier
3958e0ebf7
bump rustcrypto dependencies to released versions (#902)
This bumps `pkcs8`, `signature`, `spki`, `sha3`, and `der` to newly released versions.

This also bumps the version of `blake2`, `rustcrypto-ff`,
`rustcrypto-group`, and `ed25519` to their latest pre-released versions.
2026-05-02 15:06:44 -06:00
Michael Rosenberg
eb7df80805
Link formal verification results (#899) 2026-04-20 02:03:45 -04:00
Tony Arcieri
bad078de58
Bump cpufeatures to v0.3 (#894)
Release PR: RustCrypto/utils#1446
2026-03-29 17:55:42 -04:00
Tony Arcieri
53a86c7c9c
Bump digest and sha2 to v0.11 (#893)
Release PRs:
- `digest`: RustCrypto/traits#2300
- `sha2`: RustCrypto/hashes#806
2026-03-29 17:29:12 -04:00
Tony Arcieri
20101184a3
curve: add X25519_LOW_ORDER_POINTS constant (#814)
Adds a table of low order points, adapted from
https://cr.yp.to/ecdh.html, which suggests that non-Diffie-Hellman
protocols that depend on "contributory" behavior should reject them.

They're also useful for testing, e.g. how a protocol implementation
handles them during a key exchange (noting that a well-implemented AKE
shouldn't need to explicitly reject them, as someone attempting to use
them for MitM should be spotted as a transcript mismatch).
2026-02-25 10:35:32 -05:00
Michael Rosenberg
61533d75cf
curve,x,ed: Prepare for pre.6 release (#879) 2026-02-04 16:25:03 +01:00
Tony Arcieri
ea475248ae
curve,ed,x: Bump rand_core to v0.10; getrandom to v0.4 (#877)
Also bumps additional RustCrypto dependencies
2026-02-03 12:34:37 -05:00
Michael Rosenberg
59305b4e26
curve,ed: Update digest and sha2 deps (#875)
Co-authored-by: Michael Rosenberg <mrosenberg@cloudflare.com>
2026-02-02 16:39:43 -07:00
Michael Rosenberg
11f5375375
curve,x,ed: Prepare for pre.5 release (#874) 2026-01-25 02:03:25 +01:00
Tony Arcieri
b7531ca318
Bump rand_core to v0.10.0-rc-6 (#873)
This also rips out `rand`: it's just acting as a facade for what we're
using that complicates these sorts of upgrades.
2026-01-25 01:29:05 +01:00
Arthur Gautier
56a6bc07b8
chore(deps): bump rand_core to 0.10.0-rc-5 (#870) 2026-01-21 12:52:56 -07:00
Michael Rosenberg
e5a7986970
curve,ed,x: Bump prerelease version to fix build (#863) 2026-01-03 16:52:34 +01:00
Roland Yang
a65228a674
curve: update curve_models link (#862) 2026-01-03 07:37:42 +01:00
Tony Arcieri
9d6ec949ad
Bump rand_core to v0.10.0-rc-3 (#860)
Most of the changes in this PR are actually from the associated `rand`
crate updates which are happening in rust-random/rand#1697, notably
`OsRng` has been renamed to `SysRng` (and is now provided by the
`getrandom` crate).

We do use some `rand_core` APIs in a few places though, like the STROBE
implementation, where this migrates from `rand_core::le` to
`rand_core::utils`.
2025-12-27 09:53:24 -07:00
GarmashAlex
0a09c4ebb1
perf: use width-8 NAF for static scalars to match NafLookupTable8 (#848) 2025-12-27 08:41:19 -07:00
daxpedda
aaff294bfa
Add allocation-free EdwardsPoint::compress_batch() (#832) 2025-12-19 18:04:32 -05:00
Michael Rosenberg
0fbf15e3c2
x: Remove vestigial feature and update feature docs (#857)
* Clarify features in x25519 README

* Remove alloc feature from x25519 bc it was doing nothing

* Add pubkey constructor benchmark

* Correct code size claim on README

* Update changelog
2025-12-19 06:33:31 -05:00
Michael Rosenberg
3d76df7c24
Fix docs build and prep prerelease (#855)
* Fix failing docs build

* Remove hiding of docsrs cfg gate in crates where it doesn't appear

* Add docsrs build regression check to CI
2025-12-04 18:06:40 -05:00
Michael Rosenberg
81c642d74f
Prep pre.2 prereleases (#849) 2025-11-22 22:09:59 +01:00
Tony Arcieri
23d0d2cec0
Bump rand_core from v0.9 to v0.10.0-rc-2 (#842)
Prior to a final stable release of the @RustCrypto dependencies used by
the dalek crates, we are going to target `rand_core` v0.10.

This updates the `rand` and `rand_core` dependencies as well as the
aforementioned @RustCrypto dependencies to be compatible with
`rand_core` v0.10, which incurred a few API changes:

- `rand_core` no longer includes `OsRng`, so this replaces the `os_rng`
  features with `getrandom` features (same thing we did for @RustCrypto)
  which uses the `getrandom` crate directly
- For `dev-dependencies` it just migrates straight to `rand`, replacing
  `rand_chacha` with the `chacha` feature of `rand` (which pulls in
  `chacha20`), and sourcing `OsRng` from `rand`, its new home (for now)

This PR also switches to using the `rustcrypto-ff`/`rustcrypto-group` crates
(hopefully temporary) which are forks of `ff` and `group` which have crate
releases that have been updated to use  `rand_core` v0.10.0 prereleases.
2025-11-22 10:37:51 -07:00
Tony Arcieri
9e04a586c0
curve: fully migrate to 2018 module conventions (#844)
Enforced via the newly added `clippy::mod_module_files` lint.

Previously a mixture of 2015 (`mod.rs`) module files along with
the 2018 `foo.rs` and `foo/` approach.

All of the toplevel modules (`edwards`, `field`, `montgomery`, and
`scalar`) were using the 2018 convention, except for `backend`,
`ristretto`, and the recently added `lizard` were using the 2015
convention.

This renames the files so everything follows the 2018 convention, and
applies the afforementioned clippy lint which will error if anyone tries
to add new files using the 2015 convention.
2025-11-09 08:49:57 -07:00
Michael Rosenberg
b76b924080
Implement Lizard encoding/decoding (#826)
* Vendor lizard hash to curve from Signal

* Add invalid Lizard encoding test

* Added lizard details to readme and changelog

* Upgrade ristretto.sage to Python3

* Add lizard test vector generation to ristretto.sage

* Added map_to_curve and its inverse

* Use CtOption instead of bitmasks; other cleanup

* Add README to lizard folder

* Split map_to_curve into map_to_curve and map_to_curve_restricted; make its inverse return 16 elements

* Consolidate Ristretto Elligator functions into its own file
2025-10-24 17:20:50 -04:00
Tony Arcieri
adb6a12b4a
ed,x: Cut pre.1 prereleases (#820)
* Cut `pre.1` prereleases

These prereleases included updated RustCrypto dependencies which notably
migrate from `hybrid-array` v0.3 to v0.4
2025-09-04 11:36:45 -04:00
Michael Rosenberg
cf1c77de6e
curve: Bump version to 5.0.0-pre.1 (#822) 2025-09-04 00:21:22 -04:00
Tony Arcieri
59ab400f1b
Bump RustCrypto dependencies (#815)
Updates the following dependencies (which now use `hybrid-array` v0.4
instead of v0.3):

- `blake2` v0.11.0-rc.2
- `digest` v0.11.0-rc.1
- `ed25519` v3.0.0-rc.0
- `sha2` v0.11.0-rc.2
- `sha3` v0.11.0-rc.2
- `signature` v3.0.0-rc.3
2025-09-03 17:12:43 -04:00
daxpedda
44433757a0
Add fixed-array Scalar batch inversion (#789) 2025-08-26 20:54:09 +02:00
Iñigo Querejeta Azurmendi
015707ab4e
Add proper hash_to_curve. (#786)
* Rename hash_to_curve as encode_to_curve

* Implement the inline description of the standard.

* Generalise map_to_field to return an arbitrary number of field elements.

* Implement hash_to_curve as defined in the standard.

* Put elligator behind the "digest" feature.

* Add warning on non-uniformity of `encode_to_curve`.

* Remove the need of Vec for hash_to_field.

* Apply suggestions from code review

* Refactor expand_message_xmd out of hash_to_field

* Add hash-to-curve to benches

* Constraint COUNT to 1 or 2; add note on secure hash function usage

* Correct hash function usage in encode- and hash-to-curve

---------

Co-authored-by: Armando Faz <armfazh@users.noreply.github.com>
Co-authored-by: Michael Rosenberg <mrosenberg@cloudflare.com>
2025-08-26 20:51:39 +02:00
Tony Arcieri
fc8815721c
Scalar::div_by_2 (#805)
* [WIP] Scalar::div_by_2

* debug_assert that carry is 0

* revise tests

* Test multiply by half scalar, double and compress (#804)

* Test `div_by_2` with `proptest` (#806)

---------

Co-authored-by: daxpedda <daxpedda@gmail.com>
2025-08-22 20:45:51 +02:00
yumeiyin
1ad4603e0a
chore: fix some minor issues in sage comments (#788) 2025-08-08 16:13:28 -04:00
Arthur Gautier
246723eefe
workspace: use a global patch.crates-io to avoid duplicates (#793)
When pulling crates via git (to grab non-released yet fixes or
otherwise), the `path = "../"` in each crate crates duplicates unless
you pull the whole tree in your local `[patch.crates-io]`.

This creates issues in downstream packaging (nix, ...) where a crate
version can only appear once.
Those are somewhat difficult to diagnose.

Using a `[patch.crates-io]` in the workspace serves the same purpose but
does not create the duplication in consumers' tree.
2025-07-18 08:26:13 -06:00
Tony Arcieri
c6e32a2c7a
curve: add yanking notes for v4.2.0 (#794)
Yanked due to #785
2025-07-17 21:52:40 -04:00
Michael Rosenberg
fc8a8a5276
Cut pre.0 prereleases (#784) 2025-07-09 19:04:17 +02:00
Michael Rosenberg
6a515e60a8
Update all READMEs and CHANGELOGs (#783)
* Update changelogs and readmes

* Fix missing/wrong features in readmes

* ed: Remove std entirely

* ed: Fix deprecated warnings in bench

* Document removing std from ed
2025-07-08 21:46:55 -04:00
Aaron Feickert
55e3e00d97
curve: Remove unnecessary CofactorGroup documentation (#683) 2025-07-07 21:42:31 -04:00
Michael Rosenberg
86832640ed
curve: Undeprecate Scalar::from_bits (#780) 2025-07-07 17:15:06 -04:00
Aaron Feickert
9e4ec01fa2
curve: Use constant-time compressed edwards equality testing (#684) 2025-07-07 23:02:51 +02:00
Aaron Feickert
d54b196d18
curve: Use constant-time compressed equality testing (#669) 2025-07-07 23:01:55 +02:00
Michael Rosenberg
445fd7d59d
curve,x: Clear deprecated functions (#778) 2025-07-07 22:33:05 +02:00
Arthur Gautier
a99efe2304
curve,ed,x: Bump rand_core to 0.9 (#777)
---------

Co-authored-by: pinkforest <36498018+pinkforest@users.noreply.github.com>
2025-07-07 15:36:11 -04:00
Tony Arcieri
a9aa94736b
Bump digest, ed25519, signature, and sha2 (#676)
Bumps the aforementioned dependencies to their latest (pre)releases.
2025-07-07 11:34:26 -06:00
Tony Arcieri
53df025bb3
Bump edition to 2024 and crate versions to prereleases (#775)
This represents the first breaking change in a new release series,
bumping all crates to the 2024 edition of Rust.

As such, the version numbers of all crates have been incremented to
represent a new prerelease series:

- `curve25519-dalek`: v5.0.0-pre
- `ed25519-dalek`: v3.0.0-pre
- `x25519-dalek`: v3.0.0-pre

Note that this commit isn't intended to cut associated crate releases of
these on crates.io, but is merely bumping the version numbers to denote
there are pending breaking changes.

This commit also includes rustfmt changes which were made as part of the
2024 edition.

Also includes clippy fixes.
2025-07-07 11:52:25 -04:00
Iñigo Querejeta Azurmendi
25a9dbb811
curve: Hash to curve and field as defined in the standard (#377)
* Implementation of `hash_to_field` as defined in the standard
* Implementation of `hash_to_curve` as defined in the standard, by changing the mechanism over which we chose the sign.
* For the point above, had to change the `elligator_encode` to return whether `eps` is a square or not (required for `hash_to_curve`).
* Included test vectors of the draft.
* Included `FieldElement::from_bytes_wide(bytes: &u8; 64])` to reduce integers encoded in 64 bytes.
2025-07-05 22:01:26 +02:00