Open
Conversation
They used shared hashes/XOFs which cause problem if multiple threads try to use the same key object concurrently without external locking.
There was a problem hiding this comment.
Pull request overview
This PR addresses thread-safety issues in Dilithium/ML-DSA public key operations by removing shared mutable XOF/hash state inside key-related helpers, enabling safe concurrent use of the same key object across multiple threads.
Changes:
- Refactors Dilithium symmetric primitives and XOF adapters to return per-call XOF instances (via
std::unique_ptr) instead of shared/reused XOF references. - Updates Dilithium algorithm code to consume the new per-call XOF objects safely.
- Extends the concurrent public-key test suite to include ML-DSA and Dilithium variants (including Dilithium AES).
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/tests/test_concurrent_pk.cpp | Adds concurrent signing/verification coverage for ML-DSA and Dilithium variants. |
| src/lib/pubkey/dilithium/dilithium_round3/dilithium_aes/dilithium_aes.cpp | Makes AES XOF creation per-call to avoid shared mutable state. |
| src/lib/pubkey/dilithium/dilithium_common/dilithium_symmetric_primitives.h | Changes XOF adapter API to return owning XOF instances and removes shared XOF members. |
| src/lib/pubkey/dilithium/dilithium_common/dilithium_symmetric_primitives.cpp | Updates symmetric primitives construction to match removal of shared XOF members. |
| src/lib/pubkey/dilithium/dilithium_common/dilithium_shake/dilithium_shake_xof.h | Updates SHAKE XOF adapter interface to return per-call XOF instances. |
| src/lib/pubkey/dilithium/dilithium_common/dilithium_shake/dilithium_shake_xof.cpp | Implements per-call SHAKE XOF creation for the adapter. |
| src/lib/pubkey/dilithium/dilithium_common/dilithium_algos.cpp | Adjusts callers to handle std::unique_ptr<XOF> returned by symmetric primitives. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
src/lib/pubkey/dilithium/dilithium_round3/dilithium_aes/dilithium_aes.cpp
Show resolved
Hide resolved
src/lib/pubkey/dilithium/dilithium_common/dilithium_symmetric_primitives.h
Show resolved
Hide resolved
src/lib/pubkey/dilithium/dilithium_common/dilithium_symmetric_primitives.h
Show resolved
Hide resolved
src/lib/pubkey/dilithium/dilithium_common/dilithium_shake/dilithium_shake_xof.cpp
Show resolved
Hide resolved
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
They used shared hashes/XOFs which cause problem if multiple threads try to use the same key object concurrently without external locking.