Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add known-answer tests (KATs) #6

Merged
merged 8 commits into from
Feb 14, 2025
Merged

Add known-answer tests (KATs) #6

merged 8 commits into from
Feb 14, 2025

Conversation

mkannwischer
Copy link
Contributor

@mkannwischer mkannwischer commented Feb 13, 2025

Depends on #5 - that one should be merged first.

This PR adds KAT (matching hashes from PQClean) and NISTKAT (matching hashes from pqcrystals) tests.

Both are added to the quickcheck for all parameter sets - that in turn already is executed in CI.

Signed-off-by: Matthias J. Kannwischer <matthias@kannwischer.eu>
Signed-off-by: Matthias J. Kannwischer <matthias@kannwischer.eu>
Signed-off-by: Matthias J. Kannwischer <matthias@kannwischer.eu>
Signed-off-by: Matthias J. Kannwischer <matthias@kannwischer.eu>
Signed-off-by: Matthias J. Kannwischer <matthias@kannwischer.eu>
This includes the known-answer test hashes from
https://github.com/pq-crystals/dilithium/tree/master merged into a single
META.yml file.
It also includes alternative testvector hashes from PQClean
https://github.com/PQClean/PQClean/tree
(those also test the detached signature API).

Additionally, we copy over a script from mlkem-native that allows querying it.
It either uses yq to properly parse the yml, or if that is not available, it
falls back to string processing grep which works fine for the simple structure.

Signed-off-by: Matthias J. Kannwischer <matthias@kannwischer.eu>
This is automatically executed (also in CI) as a part of quickcheck.

This adds known-answer tests following what is done in
https://github.com/PQClean/PQClean/blob/master/test/crypto_sign/testvectors.c

The main added benefit of this test over the NISTKAT tests is that is also
includes the detachted signature API (crypto_sign_signature and
crypto_sign_verify).

Signed-off-by: Matthias J. Kannwischer <matthias@kannwischer.eu>
This is executed (in CI) as a part of quickcheck.

This adds NISTKAT testvector tests to match the testvector hashes from
the official Dilithium implemenetation:
https://github.com/pq-crystals/dilithium.

Signed-off-by: Matthias J. Kannwischer <matthias@kannwischer.eu>
@mkannwischer mkannwischer marked this pull request as ready for review February 13, 2025 11:32
@jakemas jakemas merged commit e0080e7 into main Feb 14, 2025
9 checks passed
@jakemas jakemas deleted the kat branch February 14, 2025 00:45
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