Commit graph

2410 commits

Author SHA1 Message Date
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
e1f1e41678
Use getrandom v0.4.0-rc.0 crate release (#861)
rust-random/rand#1697 which updates `rand_core` to v0.10.0-rc-3 for the
`rand` crate has been merged.

This removes `patch.crates-io` for `getrandom` and pins to the merged
commit revision for `rand`, as well as bumping the `getrandom`
dependency of `x25519-dalek` to v0.4.0-rc.0.
2025-12-28 16:45:11 +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
Ben Beasley
7751957445
ed25519-dalek: update hex-literal dev-dependency to version 1 (#854) 2025-12-06 21:14:53 -07: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
Vin Singh
f8481d94d5
x25519: add RFC7748 Diffie-Hellman Curve25519 tests (#721) 2025-12-03 06:11:36 -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
daxpedda
c3a82a8a38
ed25519: update signature to v3.0.0-rc.4 (#828) 2025-09-14 18:11:51 -06: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
Martin von Zweigbergk
65a9efef98
chore(deps): bump toml to 0.9 (#818) 2025-09-04 11:32:20 -04:00
Tony Arcieri
84dc372a89
ed: bump keccak to v0.2.0-rc.0 (#823)
Also bumps `sha3` (in `dev-dependencies`) to v0.11.0-rc.3
2025-09-04 11:27:19 -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
Arthur Gautier
03df416703
chore(deps): bump signature to 3.0.0-rc.2 (#791)
This also relax the dependency to use future RC versions of signatures
2025-07-16 19:11:24 -06:00
daxpedda
c3f91f7620
ed25519: implement MultipartSigner/Verifier (#764) 2025-07-14 09:41:20 -05: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
Michael Rosenberg
e3c2455f63
x: Remove Zeroize impl for secret types (#782) 2025-07-08 21:06:07 +02: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
d159f47f53
ed25519-dalek: use SignatureAlgorithmIdenfier instead of the dynamic counterpart (#779)
This allows to use ed25519 to create certificates for example

This partially reverts #712
2025-07-07 13:57:47 -06: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
Steve Fan
0736088c94
ed: Don't implicitly enable zeroize for ed25519-dalek alloc feature (#761) 2025-07-07 18:02:14 +02: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
Tony Arcieri
37d3ae99d3
x25519: use manual impls instead of zeroize_derive (#776)
The types involved are all simple 1-tuple newtypes where zeroization
only involves calling `zeroize` on the inner type, making all of the
involved impls relatively trivial.

Avoiding custom derive arguably improves auditability as you don't need
to expand a proc macro to see the resulting code. It decreases the
number of required dependencies in order for the `zeroize` feature to
work, where some of those dependencies are incredibly heavy
(particularly `syn`).
2025-07-07 10:14:51 -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