Skip to content

ml-dsa: Rename KeyGen::key_gen_internal to from_seed#1054

Merged
tarcieri merged 1 commit into
RustCrypto:masterfrom
hoxxep:ml-dsa-keygen-from-seed
Sep 12, 2025
Merged

ml-dsa: Rename KeyGen::key_gen_internal to from_seed#1054
tarcieri merged 1 commit into
RustCrypto:masterfrom
hoxxep:ml-dsa-keygen-from-seed

Conversation

@hoxxep
Copy link
Copy Markdown
Contributor

@hoxxep hoxxep commented Sep 3, 2025

This is an alternative to #1046 to reduce copying the seed derivation logic. Implementing a from_seed as raised in issue #1045.

  • Renames KeyGen::key_gen_internal to KeyGen::from_seed.
  • Adds SigningKey::from_seed. This internally calls KeyGen::from_seed for now, as the majority of the computational work is the same for both keys. A future PR could be slightly more efficient by specialising the SigningKey from_seed method by skipping the couple of extra steps performed to also compute a VerifyingKey, but ml-dsa: SigningKey::from_seed(&B32) implementation #1046 shows this only nets a 20us / 10% speed up.
  • Adds a test to the from_seed implementations don't deviate from each other in future, if more efficient implementations are provided.

I am not sure why key_gen_internal was commented to be behind a feature flag or private, as I believe deriving from a seed value is a must-have, assuming this implementation correctly matches the spec. I can look through the spec and codebase for test vectors to make sure, if desired?

Cheers!

Comment thread ml-dsa/src/lib.rs
@hoxxep hoxxep force-pushed the ml-dsa-keygen-from-seed branch 2 times, most recently from 46fcc7b to e4514bc Compare September 3, 2025 14:05
Comment thread ml-dsa/src/lib.rs Outdated
@hoxxep hoxxep force-pushed the ml-dsa-keygen-from-seed branch from e4514bc to 8121172 Compare September 3, 2025 14:30
@tarcieri
Copy link
Copy Markdown
Member

I'll follow up myself with my requested changes from earlier

@tarcieri tarcieri merged commit ecc8d27 into RustCrypto:master Sep 12, 2025
5 checks passed
@hoxxep
Copy link
Copy Markdown
Contributor Author

hoxxep commented Sep 12, 2025

Thanks @tarcieri. Initialising a verifying key from seed was removed and this PR doesn't have the code duplication the previous one suffered from. Apologies if I missed other suggestions?

@tarcieri
Copy link
Copy Markdown
Member

Upon another pass it looks fine, thanks!

@tarcieri tarcieri mentioned this pull request May 17, 2026
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.

2 participants