libcrux icon indicating copy to clipboard operation
libcrux copied to clipboard

Optimize HACL* Raw RSA decryption to use CRT

Open franziskuskiefer opened this issue 1 year ago • 4 comments
trafficstars

franziskuskiefer avatar Jun 03 '24 05:06 franziskuskiefer

Tested on multiple platforms and compilers.

Some observations:

  • compiling with gcc on x64 does not appear to enable HACL_CAN_COMPILE_INTRINSICS in lib_intrinsics.h, leading to a performance degradation. enabling this flag provides a significant boos.
  • optimizing at -O2 (like the Linux Kernel) vs -O3 does not make much difference to this code
  • recent GCCs (e.g. 13) are better at optimizing this code than GCC-11
  • recent clang is still about 10-15% faster than recent GCC
  • the optimizations that work differ for x64 and ARM likely because of the difference in mul instructions and pipelining

Performance

  • Our dec code is 10x slower than optimized OpenSSL assembly that uses CRT
  • On x64, our dec code (without CRT) appears to already be competititive with Kernel code (with CRT)

Next Steps:

  • Send update to Cloudflare
  • Implement and verify CRT

karthikbhargavan avatar Jun 03 '24 05:06 karthikbhargavan

It is not yet clear whether CRT is needed in this round (although I would like to do it.)

karthikbhargavan avatar Jun 03 '24 18:06 karthikbhargavan

Next steps: push upstream to HACL and to consumers

franziskuskiefer avatar Jun 24 '24 07:06 franziskuskiefer

Currently, this does not appear to be a priority since our signing code is already faster than Linux. We will do this in the fall as time permits.

karthikbhargavan avatar Jul 28 '24 14:07 karthikbhargavan

This issue has been marked as stale due to a lack of activity for 60 days. If you believe this issue is still relevant, please provide an update or comment to keep it open. Otherwise, it will be closed in 7 days.

github-actions[bot] avatar Sep 27 '24 02:09 github-actions[bot]

This issue has been closed due to a lack of activity since being marked as stale. If you believe this issue is still relevant, please reopen it with an update or comment.

github-actions[bot] avatar Oct 04 '24 02:10 github-actions[bot]