Skip to content

ml-dsa: precompute VerifyingKeys when alloc enabled#1346

Merged
tarcieri merged 1 commit into
masterfrom
ml-dsa/precompute-verifying-key-under-alloc
May 9, 2026
Merged

ml-dsa: precompute VerifyingKeys when alloc enabled#1346
tarcieri merged 1 commit into
masterfrom
ml-dsa/precompute-verifying-key-under-alloc

Conversation

@tarcieri
Copy link
Copy Markdown
Member

@tarcieri tarcieri commented May 9, 2026

Adds an alloc-gated verifying_key field to SigningKey, and when the feature is enabled precomputes the key at the time the SigningKey is initialized.

We previously used to do this but stopped to optimize stack usage (see the changes in #1259 and #1261), however when alloc is enabled this isn't an issue since we've moved the relevant data to the heap in this case (see #1344 and #1345), so stack usage is no longer an issue.

This makes it possible to implement signature::KeypairRef for SigningKey which still provides a blanket signature::Keypair impl, so we can always depend on the latter being availble but take advantage of the former when alloc is enabled.

Adds an `alloc`-gated `verifying_key` field to `SigningKey`, and when
the feature is enabled precomputes the key at the time the `SigningKey`
is initialized.

We previously used to do this but stopped to optimize stack usage (see
the changes in #1259 and #1261), however when `alloc` is enabled this
isn't an issue since we've moved the relevant data to the heap in this
case (see #1344 and #1345), so stack usage is no longer an issue.

This makes it possible to implement `signature::KeypairRef` for
`SigningKey` which still provides a blanket `signature::Keypair` impl,
so we can always depend on the latter being availble but take advantage
of the former when `alloc` is enabled.
@tarcieri tarcieri merged commit e7f6a60 into master May 9, 2026
9 checks passed
@tarcieri tarcieri deleted the ml-dsa/precompute-verifying-key-under-alloc branch May 9, 2026 22:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant