Skip to content

Feat: add tests to check slh-dsa key gen from seed - #7

Merged
mikelodder7 merged 1 commit into
mainfrom
feat/slh-dsa-test
Feb 20, 2026
Merged

Feat: add tests to check slh-dsa key gen from seed#7
mikelodder7 merged 1 commit into
mainfrom
feat/slh-dsa-test

Conversation

@manel1874

Copy link
Copy Markdown

Forgot to comment on the previous PR that maybe we should add some tests for this.

How to run those from liboqs main folder:

cd build
ninja sig_keypair_from_seed
./tests/sig_keypair_from_seed

@manel1874
manel1874 marked this pull request as ready for review February 20, 2026 17:56
@mikelodder7
mikelodder7 merged commit 282809f into main Feb 20, 2026
11 checks passed
@greptile-apps

greptile-apps Bot commented Feb 20, 2026

Copy link
Copy Markdown

Greptile Summary

This PR extends the existing sig_keypair_from_seed test to cover all 12 SLH-DSA PURE variants (SHA2 and SHAKE, across 128/192/256 security levels). The main changes are:

  • Added get_seed_length() helper that maps algorithm names to the correct SLH-DSA seed length (3 * n bytes: 48 for 128-bit, 72 for 192-bit, 96 for 256-bit), falling back to 32 bytes for Falcon and ML-DSA.
  • Updated seed buffer from fixed 32-byte SEED_LENGTH to 96-byte MAX_SEED_LENGTH to accommodate the largest SLH-DSA seed.
  • Renamed falcon_algorithms to algorithms and added all 12 SLH-DSA PURE entries to the test list.
  • Updated printf format specifier from %u to %zu to match the size_t type of the new seed_len variable.

The algorithm names match the identifiers defined in src/sig/sig.h, and the seed lengths align with the validation logic in each SLH-DSA keypair_from_seed implementation (which enforces seed_len == 3 * prm->n).

Confidence Score: 4/5

  • This PR is safe to merge — it only adds test coverage with no changes to library source code.
  • The PR is test-only and makes straightforward, correct changes. Algorithm names match the library's identifiers, seed lengths are consistent with the SLH-DSA implementation's validation, and the buffer sizing is adequate. The only finding is a stale comment, which is cosmetic.
  • No files require special attention

Important Files Changed

Filename Overview
tests/sig_keypair_from_seed.c Extends keypair-from-seed determinism tests to cover all 12 SLH-DSA PURE variants. Adds a get_seed_length() helper to compute the correct seed sizes (48/72/96 bytes) based on the algorithm's security level. Algorithm names, seed lengths, and array sizing are all correct. One stale comment remains from the pre-SLH-DSA version.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[main] --> B[Loop over algorithms array]
    B --> C{Algorithm type?}
    C -->|Falcon-512/1024| D[get_seed_length → 32 bytes]
    C -->|ML-DSA-44/65/87| D
    C -->|SLH_DSA_*_128*| E[get_seed_length → 48 bytes]
    C -->|SLH_DSA_*_192*| F[get_seed_length → 72 bytes]
    C -->|SLH_DSA_*_256*| G[get_seed_length → 96 bytes]
    D --> H[test_keypair_from_seed_twice]
    E --> H
    F --> H
    G --> H
    H --> I[Generate seed with KAT PRNG]
    I --> J[First keypair_from_seed call]
    J --> K[Second keypair_from_seed call]
    K --> L{Keys match?}
    L -->|Yes| M[SUCCESS]
    L -->|No| N[FAILURE]
Loading

Last reviewed commit: b8fe899

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

1 file reviewed, 1 comment

Edit Code Review Agent Settings | Greptile


OQS_STATUS overall_result = OQS_SUCCESS;

// Test each Falcon variant (Falcon-512 and Falcon-padded-512)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Stale comment after rename
This comment still says "Test each Falcon variant (Falcon-512 and Falcon-padded-512)" but the loop now iterates over all supported algorithms including ML-DSA and SLH-DSA variants. The comment should be updated to reflect the broader scope.

Suggested change
// Test each Falcon variant (Falcon-512 and Falcon-padded-512)
// Test each algorithm variant

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