Commit Graph

1243 Commits

Author SHA1 Message Date
Tony Arcieri 7336ca4af8 ml-dsa: use MaybeBox to store VerifyingKey (#1344)
When the `alloc` feature is enabled, uses `Box` to offload the largest
parts of `VerifyingKey` to the heap.

This also extracts an internal `PrecomputedValues` struct to store the
largest components of the key, which are all derived/precomputed values,
as a single contiguous struct in a `MaybeBox`, and extracts some of the
relevant logic to it.
2026-05-09 15:28:23 -06:00
Tony Arcieri e3f07e9ce5 ml-dsa: expand usage docs (#1343) 2026-05-09 14:53:34 -06:00
Tony Arcieri 62fa7ac438 ml-dsa: implement KeyInit, KeyExport, KeySizeUser (#1342)
Implements these traits sourced from the `crypto-common` crate.

Also implements the `Generate` trait for key generation, replacing the
previous `KeyGen` trait, which this commit deprecates in favor of using
`KeyInit` and `Generate`.

This also adds a `getrandom` feature that forwards through to
`crypto-common`, making methods available on the `Generate` trait when
enabled.
2026-05-09 14:19:30 -06:00
Tony Arcieri 20b0095bd9 ml-dsa: factor from_seed method onto SigningKey (#1341)
Extracts a `SigningKey::from_seed` that was previously defined on
`MlDsaParams` via a trait impl.

This changes it to an inherent method, and has the trait method call the
inherent method.

This makes it possible to restrict the visibility of `SigningKey`
fields, addressing a TODO.
2026-05-08 10:12:42 -06:00
Tony Arcieri f9f4c60d78 ml-dsa: rename ExpandedSigningKey field/method to expanded_key (#1340)
This is a vestige from when `SigningKey` was a keypair type.

Also marks it `#[doc(hidden)]` as it exists primarily for testing.
2026-05-08 09:34:29 -06:00
Tony Arcieri e5f9f64231 ml-dsa: extract signing and verifying modules (#1339)
Extracts code previously in `lib.rs` related to the following types into
two modules:

- `signing`: `SigningKey`, `ExpandedSigningKey`
- `verifying`: `VerifyingKey`
2026-05-08 09:04:40 -06:00
Tony Arcieri 0c7cf02d1b ml-dsa: apply and fix workspace-level lints (#1338)
Applies the workspace-level config added in #1323 to this crate and
fixes any failures.
2026-05-07 21:14:26 -06:00
Tony Arcieri ebe040ee89 rfc6979 v0.5.0 (#1337) rfc6979/v0.5.0 2026-05-06 12:55:52 -06:00
xjd 4854bcfa4d ml-dsa: optimize rejection sampling in rej_(ntt|bounded)_poly (#1291)
It seems like filling matrix is a bottleneck of decoding encapsulation key.

With simple changes, it gets better performance.
2026-05-06 12:45:56 -06:00
dependabot[bot] 2399f8ae6e build(deps): bump digest from 0.11.2 to 0.11.3 (#1329) 2026-05-06 12:04:03 -06:00
Tony Arcieri 8c849e0e2f rfc6979: apply and fix workspace-level lints (#1336)
Applies the workspace-level config added in #1323 to this crate and
fixes any failures.
2026-05-06 11:54:08 -06:00
Tony Arcieri 78c2b75436 ed448 v0.5.0 (#1335) ed448/v0.5.0 2026-05-06 11:30:51 -06:00
Tony Arcieri 668b85189c ed448: apply and fix workspace-level lints (#1334)
Applies the workspace-level config added in #1323 to this crate and
fixes any failures.
2026-05-06 11:13:09 -06:00
Tony Arcieri 3f353f90ea ed448: use serdect for serde support (#1333)
Like #1324 did for `ed25519`, this uses the `serdect` crate for the
`serde` implementation, which is a breaking change.

See comments in #1324 for more information.
2026-05-06 10:43:42 -06:00
dependabot[bot] 2ac115c5fe build(deps): bump serdect from 0.4.2 to 0.4.3 (#1330) 2026-05-05 15:21:43 -06:00
Tony Arcieri d5012d5ba3 ed25519: add back serde_bytes support (#1332)
Since `serdect` changes the wire format, this should at least provide
backwards compatibility for `serde_bytes` users.
2026-05-05 15:09:40 -06:00
dependabot[bot] b60664ed3c build(deps): bump crate-ci/typos from 1.45.0 to 1.46.0 (#1331) 2026-05-04 14:16:34 -06:00
dependabot[bot] a1eb4e0982 build(deps): bump signature from 2.2.0 to 3.0.0 (#1328) 2026-05-04 13:44:28 -06:00
Tony Arcieri f2b087c0f3 ed25519 v3.0.0 (#1327) ed25519/v3.0.0 2026-05-03 10:28:50 -06:00
Tony Arcieri 9c1e1fc627 ed25519: fix Zeroize impl for Signature (#1326)
It wasn't actually using `Zeroize` on the underlying values
2026-05-03 10:06:36 -06:00
Tony Arcieri 01e41793c3 ed25519: remove rand_core dev-dependency (#1325)
It's out-of-date and seemingly unused, possibly tied to the interop
documentation which is currently disabled, but we can cross that bridge
when we get there
2026-05-03 09:54:22 -06:00
Tony Arcieri 3c97f39a05 ed25519: use serdect for serde support (#1324)
Follows suit with `serde` support in other RustCrypto crates by using
`serdect` to implement `Serialize` and `Deserialize`, replacing the
previous use of `serde_bytes`.

These serializers use the `serdect::array` serializers which use
efficient format-specific byte encodings (albeit with a length prefix)
when serializing to binary formats, or a hex encoding with human
readable formats like JSON and TOML.
2026-05-03 09:28:36 -06:00
Tony Arcieri 2d7866fa4c ed25519: configure and apply workspace-level lints (#1323)
Adds the workspace-level config from RustCrypto/utils#1411 to this
repo and applies it to `ed25519`.
2026-05-02 21:21:26 -06:00
Tony Arcieri e0d47990aa Update copyright year to 2026 (#1322) 2026-05-02 18:10:44 -06:00
Tony Arcieri 088a4fe7a4 Bump signature dependency to v3 (#1321)
Release PR: RustCrypto/traits#2400
2026-05-02 15:16:18 -06:00
Onyeka Obi 826baa3682 Implement Hash on non-secret Signature and VerifyingKey types (#1309)
Per #1229: Signature and public-key types lack `Hash`, which prevents
use in `HashMap` / `HashSet` keys and similar collections.

- ecdsa: Signature, DER Signature, SignatureWithOid
- ed25519: Signature, pkcs8::PublicKeyBytes
- ed448: Signature, pkcs8::PublicKeyBytes
- ml-dsa: Signature, VerifyingKey
- slh-dsa: Signature, VerifyingKey

Where a trivial derive works (ed25519, ed448), uses derive. Where
generic bounds or upstream gaps require it, uses a manual impl over
the canonical serialized bytes (`to_bytes` / `encode` / `as_bytes`),
which is the natural Hash domain for these types anyway.

Closes #1229
2026-05-01 16:17:15 -06:00
Tony Arcieri f3c409ee83 ml-dsa: add internal MaybeBox type (#1320)
Adds an internal type for opportunistic heap offload which uses `Box`
when the `alloc` feature is available and falls back to stack allocation
when it is not.

So far it's only used for the `z` component of `Signature` but is useful
elsewhere, e.g. for `VerifyingKey`.

It's so generally useful it should probably get extracted somewhere, to
`module-lattice` at the very least, but this is enough to get started.
2026-04-30 11:13:41 -06:00
Tony Arcieri 58bae19939 Cut new prereleases (#1319)
Releases the following, which all now depend either directly or
transitively on `pkcs8` v0.11 (which had breaking changes in the final
release)

- `dsa` v0.7.0-rc.15
- `ecdsa` v0.17.0-rc.18
- `ed25519` v3.0.0-rc.5
- `ed448` v0.5.0-rc.6
- `ml-dsa` v0.1.0-rc.9
- `slh-dsa` v0.2.0-rc.5
- `xmss` v0.1.0-pre.1
ml-dsa/v0.1.0-rc.9 slh-dsa/v0.2.0-rc.5 ecdsa/v0.17.0-rc.18 xmss/v0.1.0-pre.1 ed448/v0.5.0-rc.6 ed25519/v3.0.0-rc.5 dsa/v0.7.0-rc.15
2026-04-28 10:08:48 -06:00
Tony Arcieri 2eadc3c766 ml-dsa: bump module-lattice to v0.2.2 (#1318) 2026-04-28 09:36:10 -06:00
Tony Arcieri 452633d33a ecdsa: bump elliptic-curve to v0.14.0-rc.32 (#1317)
This version requires `pkcs8` v0.11
2026-04-28 09:35:52 -06:00
Tony Arcieri 86c035a74f Bump pkcs8 dependency to v0.11 (#1316)
Release PR: RustCrypto/formats#2314
2026-04-28 08:32:20 -06:00
dependabot[bot] f873b8e758 build(deps): bump hybrid-array from 0.4.10 to 0.4.11 (#1314) 2026-04-27 13:09:18 -06:00
Tony Arcieri d8b1875a9f Bump pkcs8 to v0.11.0-rc.12 (#1312) 2026-04-27 13:07:45 -06:00
dependabot[bot] 00e6eed7b2 build(deps): bump typenum from 1.19.0 to 1.20.0 (#1306) 2026-04-27 10:27:46 -06:00
Tony Arcieri f93d5022da ml-dsa: fix unreachable_pub lint by making Eta pub (#1311)
This lint started failing, seemingly as of Rust 1.95. Though this may
not be the best solution, to get the lint to pass again this makes `Eta`
pub.
2026-04-27 09:15:21 -06:00
Onyeka Obi 0efe0f8936 ecdsa: use absolute 128-bit floor for bits2field (#1310)
Per maintainer suggestion on #1275, replace the curve-specific
`FieldBytesSize / 2` minimum with an absolute 16-byte / 128-bit
floor. The old rule rejected legitimate pairings like SHA-256 with
P-521 (permitted by e.g. XML Signature); the new rule still catches
egregious digest misuse without those false positives.

Closes #1275
2026-04-27 08:50:50 -06:00
Tony Arcieri f467f70447 ecdsa v0.17.0-rc.17 (#1304) ecdsa/v0.17.0-rc.17 2026-04-15 13:41:21 -06:00
Tony Arcieri a39b93d604 ecdsa: bump spki to v0.8 (#1303)
Release PR: RustCrypto/formats#2277
2026-04-15 13:23:50 -06:00
Tony Arcieri 6752ba4cbe ecdsa: use mul_by_generator_and_mul_add_vartime for verification (#1302)
This high-level method can plug into various strategies for efficiently
implementing `aG + bP`, including using basepoint tables, wNAF, or
linear combinations, depending on what crate features are enabled and
what curve-specific optimizations have been implemented.
2026-04-15 12:49:14 -06:00
Peter Membrey ecaf35904d ml-dsa: zeroize NTT-domain derived values in ExpandedSigningKey Drop (#1300)
The existing Drop impl for ExpandedSigningKey (gated on the zeroize
feature) zeroizes rho, K, tr, s1, s2, and t0 but skips the
NTT-domain derived values s1_hat, s2_hat, and t0_hat.

The NTT is invertible, so s1_hat in memory is equivalent to having
s1. This leaves secret key material unzeroized after drop.

Add s1_hat, s2_hat, and t0_hat to the Drop impl. All three are
NttVector types which implement Zeroize via module-lattice.

A_hat (the public matrix derived from rho) is not zeroized here
because NttMatrix does not implement Zeroize in module-lattice.
A_hat is derived from public data (rho) so this is lower priority,
but a follow-up PR to module-lattice could add Zeroize for NttMatrix
for completeness.
2026-04-15 10:53:09 -06:00
Tony Arcieri 66de36e62f xmss: delete Cargo.lock (#1301)
This is leftover from when it was originally imported. It's now a part
of the workspace and uses the workspace's Cargo.lock
2026-04-14 14:27:43 -06:00
Tony Arcieri a9b80562a9 Cargo.lock: bump deps (#1299) 2026-04-14 08:47:04 -06:00
dependabot[bot] 8cb1795140 build(deps): bump elliptic-curve from 0.14.0-rc.29 to 0.14.0-rc.30 (#1292) 2026-04-09 08:47:57 -06:00
Tony Arcieri 66473ecba8 xmss: bump format dependencies (#1290)
Bumps the following dependencies:

- `const-oid` v0.10
- `der` v0.8
- `pkcs8` v0.11.0-rc.11
- `spki` v0.8
2026-04-06 14:16:17 -06:00
dependabot[bot] 37f9be5bca build(deps): bump actions/checkout from 5.0.1 to 6.0.2 (#1289) 2026-04-06 08:52:04 -06:00
dependabot[bot] a031db91a4 build(deps): bump crate-ci/typos from 1.44.0 to 1.45.0 (#1288) 2026-04-06 08:40:58 -06:00
Arthur Gautier d011b9a356 ml-dsa: make PartialEq for ExpandedSigningKey constant time (#1286) 2026-04-03 16:58:36 -06:00
dependabot[bot] f282377eb6 build(deps): bump ctutils from 0.4.0 to 0.4.2 (#1285) 2026-04-03 09:01:18 -06:00
Tony Arcieri fc8907dde0 Bump sha3 dependency to v0.11 (#1283)
Release PR: RustCrypto/hashes#816
2026-04-03 08:34:07 -06:00
Tony Arcieri 76822a8af0 bign-genk v0.1.0-pre.0 (#1282) bign-genk/v0.1.0-pre.0 2026-04-02 22:42:04 -06:00