Skip to content

Conversation

@hanno-becker
Copy link
Contributor

@hanno-becker hanno-becker commented Dec 6, 2025

Following the conversation with @davidchisnall in #1344, this draft PR explores the use of a single configuration file for both internal files and the external-facing headermlkem_native.h.

Signed-off-by: Hanno Becker <beckphan@amazon.co.uk>
Previously, mlkem_native.h required users to set MLK_CONFIG_API_* macros
before including it. Now it directly includes the config file and derives
all API settings from the same configuration used internally.

1. Unified Configuration: Eliminate MLK_CONFIG_API_* macros. The public
   API now uses the same MLK_CONFIG_* macros as the internal build:
   - MLK_CONFIG_API_PARAMETER_SET → MLK_CONFIG_PARAMETER_SET
   - MLK_CONFIG_API_NAMESPACE_PREFIX → MLK_CONFIG_NAMESPACE_PREFIX
   - MLK_CONFIG_API_CONSTANTS_ONLY → MLK_CONFIG_CONSTANTS_ONLY

2. New Config Options:
   - MLK_CONFIG_MULTILEVEL_BUILD: explicit flag for multi-level builds
     This makes it a bit simpler in mlkem_native.h to determine whether
     to append the parameter set to the namespace prefix.
   - MLK_CONFIG_NO_SUPERCOP: We had this before in mlkem_native.h as
     MLK_CONFIG_API_NO_SUPERCOP; it's now in the config and documented.
   - MLK_CONFIG_CONSTANTS_ONLY: We had this before in mlkem_native.h as
     MLK_CONFIG_API_CONSTANTS_ONLY; it's now in the config and documented.

3. Build-Internal vs API Config Separation: Config file now guards
   build-only options with #if defined(MLK_BUILD_INTERNAL).

4. Example Directory Restructuring: All examples refactored with mlkem/
   subdirectories renamed to mlkem_native/ and CFLAGS configuration
   replaced by custom configs.
   Updated READMEs to reflect new paths and clarify which options are
   set in config files vs passed via CFLAGS.

Signed-off-by: Hanno Becker <beckphan@amazon.co.uk>
Signed-off-by: Hanno Becker <beckphan@amazon.co.uk>
@hanno-becker
Copy link
Contributor Author

hanno-becker commented Dec 6, 2025

@davidchisnall I'd be glad if you could try this and see if it makes your integration smoother.

cc @mkannwischer

Signed-off-by: Hanno Becker <beckphan@amazon.co.uk>
Signed-off-by: Hanno Becker <beckphan@amazon.co.uk>
@hanno-becker
Copy link
Contributor Author

hanno-becker commented Dec 7, 2025

As it stands, this is a breaking change (as witnessed e.g. by the breaking AWS-LC integration) that could only be merged as part of a v2 release.

If we keep mlkem_native_config.h as src/config.h as done previously and add a 'backwards compatibility mode' in mlkem_native.h (by checking if the now-removed MLK_CONFIG_API_XXX are set), we might be able to keep this compatible, though.

@hanno-becker
Copy link
Contributor Author

Closing in favor of the (hopefully) API-compatible #1352

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants