Skip to content

Update to new pqm4 commit#10

Open
rwols wants to merge 8 commits intomainfrom
update-to-new-pqm4-commit
Open

Update to new pqm4 commit#10
rwols wants to merge 8 commits intomainfrom
update-to-new-pqm4-commit

Conversation

@rwols
Copy link
Copy Markdown
Collaborator

@rwols rwols commented Mar 25, 2026

These changes update ML-DSA FIPS 204 (previously known as "PQCrystals-Dilithium") and ML-KEM FIPS 203 (previously known as "PQCrystals-Kyber") to their NIST standards.

Of note here is that the ML-DSA private key and signature byte size has changed. This is noted at the top of the src/main.c file.

Due to these breaking changes we bump the major version to 4.0.

The upstream PQM4 commit chosen is:

a24bb4b662016968c19f5e6a0719c9ad530f0286

There is no clear git tag for the NIST standard at the upstream PQM4 repository, so we go with a commit from the main branch.

The strategy for integrating PQM4 has changed as well. Previously we manually added a subset of PQM4 sources to the repository. But now we checkout the actual PQM4 sources and reuse them.

The only custom integration step necessary is to define the randombytes function, which is done in the src/pqm4_hal directory. Care must be taken to ensure that this directory, as an include directory, comes before other PQM4 include directories. This way, the PQM4 sources will use the randombytes function from the src/pqm4_hal directory. Our randombytes implementation just plugs into the Pinata random generator.

rwols added 5 commits March 24, 2026 14:23
The implementations of Dilithium and Kyber were based on the following PQM4
commit hash:

992f0f226503d43b6d33278ecb60a9168ed8d787

(By "pqm4" we mean this library: https://github.com/mupq/pqm4)

As was mentioned in the file src/dilithium/README.md:

> The above commit seems to most closely match "NIST Submission Round 3" of the
> reference implementation.

We have now upgraded the code to the following pqm commit hash:

a24bb4b662016968c19f5e6a0719c9ad530f0286

As far as I can see, there is no clear git tag for the finalized ML-DSA/ML-KEM
versions on the pqm4 release page, so I'm gambling here that this commit works
fine.

I have moreover made the choice to rely more on CMake and specifying source
files to build, rather than copy-pasting them manually into this source tree.
This seems to work alright. The only hurdle is the "randombytes.h" header file,
which we're supposed to implement ourselves. Although, we also do have to make
sure to have an -I (include) line before the regular includes of mupq/pqm4.
#endif

int getMlDsaAlgorithmVariant() {
return DILITHIUM_MODE;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the name dilithium still appear here?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is a macro from the config.h file from the pqm4 source code.

#define MLDSA_SIGNED_MESSAGE_SIZE (MLDSA_SIGNATURE_SIZE + MLDSA_MESSAGE_SIZE)

/**
* @brief Get the dilithium algorithm variant. There are a few variants and
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again dilithium appearing in comment this time. Probably also in other places?

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