Commit graph

2431 commits

Author SHA1 Message Date
1bd5990856 Aeneas-compat: make vartime_double_base::mul extraction-clean
Pure refactors (cargo check green under both feature sets), semantics of
mul unchanged:
- dsm_top_index / dsm_loop / dsm_step_p / dsm_step_b helpers: the main
  double-and-add loop becomes a strictly-decreasing while with a
  single-assignment body and parameter-rooted borrows (the original
  loop/break shape with match-updates fails Aeneas' loop fixed point);
- the starting-index scan always returns 255: leading zero NAF digits
  double the identity (a no-op), so the result is unchanged - only the
  variable-time skip is dropped (constant-time behavior improves);
- the downward break-scan (which failed Aeneas' symbolic join) is gone.

With these, Charon+Aeneas extract the complete path - non_adjacent_form,
NafLookupTable5::from/select, the affine basepoint table, the 256-step
dsm_loop, and mul - with zero errors and zero sorries. This opens the
double-scalar-multiplication verification campaign (the EdDSA verify
equation's core).
2026-07-04 11:10:32 +02:00
26284959e4 Aeneas-compat: factor from_bytes_wide through named, closure-free helpers
Pure refactor, semantics identical (cargo check green):
- from_bytes_wide_parts(bytes) -> (Scalar52, Scalar52): the byte-unpack
  loops + the 52-bit lo/hi split, as a named prefix
- split_words_lo / split_words_hi: the two split halves, built with
  Scalar52([...]) struct literals instead of per-index mutation
- from_bytes_wide: parts -> montgomery_mul(lo, R) ->
  montgomery_mul(hi, RR) -> add

Why: the verification side measured that (a) a WP walk whose motives
contain a montgomery_mul call replays its whole body at every kernel
step, and (b) straight-line chains of IndexMut closure back-functions
make kernel defeq exponential in chain depth. Named prefix functions fix
(a); struct-literal construction eliminates the closures and fixes (b).
With this shape the full from_bytes_wide certificate kernel-checks in
77 seconds (was: aborted after 30+ minutes).
2026-07-04 10:23:22 +02:00
b73a5480b6 Aeneas-compat: mask the bare shift in Scalar52::from_bytes_wide
hi[4] = words[7] >> 20  is the only shift in the function whose result is
stored without a trailing mask/or; at the pinned Aeneas (bf13c42e) a bare
`x >> c` as a full RHS extracts ill-typed (wrapping_shr applied to an i32
with an emitted-but-unsubstituted U32 cast). Masking is a semantic no-op:
words[7] >> 20 < 2^44 < 2^52.  Semantics unchanged; needed to bring
from_bytes_wide (the hash-to-scalar reduction) into verification scope.
2026-07-03 22:39:59 +02:00
135ed701b3 chore: remove upstream CI workflows (not our CI infrastructure) 2026-06-30 17:44:30 +02:00
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
Michael Rosenberg
5b796f38c8
ed: Prepare for pre.7 release (#904) 2026-05-06 07:41:59 -04: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
dependabot[bot]
28611ad16c
build(deps): bump rand from 0.9.2 to 0.9.4 (#896) 2026-05-03 19:42:34 -06: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
Teoh Han Hui
71d7e870d7
ed: Fix README feature matrix (#900) 2026-04-27 10:55:15 -04:00
Michael Rosenberg
eb7df80805
Link formal verification results (#899) 2026-04-20 02:03:45 -04:00
Michael Rosenberg
fc23dd4a86
ed: Unvendor STROBE (#895)
* Fix bench build

* Remove vendored strobe impl and use strobe-rs
2026-03-30 09:51:17 -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
ddb8c6813a
ed25519-dalek: bump keccak dependency to v0.2 (#892)
This optional dependency is used by our vendored STROBE implementation
for batch verification.

Release PR: RustCrypto/sponges#117
2026-03-29 16:55:40 -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
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