Integrate API_PKC SIG bridge and KAT targets for MAMBA‑Sign profiles#4
Integrate API_PKC SIG bridge and KAT targets for MAMBA‑Sign profiles#4Make1205 wants to merge 10 commits into
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7b070dee51
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| unsigned char *pk, unsigned long long *pk_len_bytes, | ||
| unsigned char *sk, unsigned long long *sk_len_bytes) | ||
| { | ||
| int ret = crypto_sign_keypair((uint8_t *)pk, (uint8_t *)sk); |
There was a problem hiding this comment.
Seed keygen from KAT DRNG instead of system RNG
KAT_SIG.c initializes drng_algorithm from the per-test seed before calling sig_keygen, but this implementation immediately calls crypto_sign_keypair, whose implementation in ref/sign.c draws entropy via randombytes() (OS RNG). That makes generated KAT vectors non-deterministic across runs even with identical seeds, so make kat cannot reliably reproduce the checked-in vectors or produce stable regression artifacts.
Useful? React with 👍 / 👎.
|
|
||
| clean: | ||
| rm -rf $(OUT_DIR) output | ||
| rm -f $(VEC_DIR)/MAMBA-Sign-*-ref.txt $(VEC_DIR)/MAMBA-Sign-*-avx2.txt |
There was a problem hiding this comment.
Keep clean target from deleting checked-in KAT vectors
The new clean rule removes Test_Vector/MAMBA-Sign-*-{ref,avx2}.txt, but these files are committed in this change as package artifacts. Running make clean now deletes tracked deliverables and leaves the repo dirty, which breaks common workflows that start from make clean and expect packaged KAT files to remain available unless explicitly regenerated.
Useful? React with 👍 / 👎.
Motivation
refandavx2implementations to the API_PKCReference_ImplementationandOptimized_Implementationbuild flows respectively so KATs can be produced in the template format.OUTPUT_BLANK_TEST_VECTORS=0, per-instanceALGORITHM_INSTANCEnames (MAMBA‑Sign‑128/192/256/384/512), and keep template files listed as immutable unchanged.Description
API_PKC/Implementations/Reference_Implementation/AlgorithmInstance/SIG_AlgorithmInstance.cnow returnsCRYPTO_PUBLICKEYBYTES/CRYPTO_SECRETKEYBYTES/CRYPTO_BYTESand bridges template calls to the library API by callingcrypto_sign_keypair,crypto_sign_signature(detached), andcrypto_sign_verifywithout changing core logic.API_PKC/Implementations/Reference_Implementation/AlgorithmInstance/SIG_AlgorithmInstance.husingMAMBA_PROFILEand setOUTPUT_BLANK_TEST_VECTORSto0so each build selectsALGORITHM_INSTANCE=MAMBA-Sign-128/192/256/384/512.API_PKC/Makefileto build per-profile KAT executables for both ref and avx2, mappingMAMBA_PROFILE->DILITHIUM_MODEand including required sources (addedrandombytes.cto link the KAT binaries); targets includemake,make clean,make katand per-profilekat-sign{128,192,256,384,512}-{ref,avx2}.API_PKC/README.md, updated.gitignoreto exclude API_PKC artifacts, and produced KAT outputs atAPI_PKC/Test_Vector/MAMBA-Sign-*-{ref,avx2}.txt.1440/480/2420, 192:1952/736/3309, 256:2592/768/4627, 384:2592/1120/5312, 512:3232/1376/6634.Testing
make clean && make && make test-all-fastand observedcorrectness=PASSforrefandavx2across all profiles (CSV written tobuild/mamba_sign_test_all.csv).cd API_PKC && make clean && make && make kat, which produced the KAT filesAPI_PKC/Test_Vector/MAMBA-Sign-*-ref.txtandAPI_PKC/Test_Vector/MAMBA-Sign-*-avx2.txtsuccessfully; an initial linker error forrandombyteswas fixed by addingrandombytes.cto theAPI_PKC/Makefileinputs.randombytes.creports an implicitsyscalldeclaration warning; this is non‑blocking and does not prevent KAT generation.makeandmake katunderAPI_PKCcompleted and KAT files were generated as listed above.Codex Task