Skip to content

[crypto] Standardize file header format for cryptolib and related files#239

Open
pqcfox wants to merge 5 commits intomasterfrom
kat/standardize-cryptolib-headers
Open

[crypto] Standardize file header format for cryptolib and related files#239
pqcfox wants to merge 5 commits intomasterfrom
kat/standardize-cryptolib-headers

Conversation

@pqcfox
Copy link
Copy Markdown
Contributor

@pqcfox pqcfox commented Apr 9, 2026

This PR standardizes the file header format for cryptolib, cryptolib tests and related harnesses, and ACC assembly to match the remainder of the repository.

@pqcfox pqcfox requested a review from jadephilipoom April 9, 2026 14:05
Adds point doubling and a test. The routine is currently unused, but will later
help speed up scalarmult.

Signed-off-by: Jade Philipoom <jadep@zerorisc.com>
While working on the constant-time checker I took a close look at the P-384
scalarmult code and noticed it could use some attention from both performance
and readability perspectives. This commit is a collection of interrelated
improvements to make the code simpler and faster.

- adjust proj_add to take one input in registers to reduce loads/stores
- use specialized point doubling to accelerate scalarmult/verify
- improve randomization techniques and better mask MSBs
- use dedicated buffers instead of scratchpad offsets
- remove some unused constants and stale comments
- rename mod_inv_n_p384 to mod_inv_p384, since it is also used for p

Overall, this resulted in about a 20% speed improvement across top-level P-384
operations.

Full printout from bench/analyze_stats.py, only 1 test each:

Measurement                     | Baseline |     New | Percentage change
p384_ecdsa_sign avg_cycles      |  1683063 | 1338539 |            -20.47
p384_ecdsa_verify avg_cycles    |  1161878 |  930596 |            -19.91
p384_scalar_mult avg_cycles     |  1612992 | 1268470 |            -21.36

Signed-off-by: Jade Philipoom <jadep@zerorisc.com>
This makes the code a little more readable and less fragile. Also changes some
mistaken .data to .bss.

Signed-off-by: Jade Philipoom <jadep@zerorisc.com>
Pass-through after code review.

Signed-off-by: Jade Philipoom <jadep@zerorisc.com>
@pqcfox pqcfox force-pushed the kat/standardize-cryptolib-headers branch from bfce9dd to 9990849 Compare April 20, 2026 11:20
@pqcfox
Copy link
Copy Markdown
Contributor Author

pqcfox commented Apr 20, 2026

Rebased on #238, do not merge until #238 goes in.

@pqcfox pqcfox force-pushed the kat/standardize-cryptolib-headers branch from 9990849 to f45c5c0 Compare April 20, 2026 14:44
@pqcfox pqcfox force-pushed the kat/standardize-cryptolib-headers branch from f45c5c0 to 070594d Compare April 20, 2026 15:15
@pqcfox pqcfox requested a review from mkannwischer April 20, 2026 18:09
@pqcfox pqcfox marked this pull request as ready for review April 20, 2026 18:09
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