C, C++ or Rust - which is best for performance in cryptography?

If I am trying to achieve super-efficient cryptographic implementations, would C, C++ or Rust be better? I've found it really hard to ascertain which is best in general, let alone for the application to cryptography. I understand that Rust often provides superior performance due to its safety, particularly with regard to memory, but I wonder if this can be extrapolated to 'perfectly written' C (or C++) code. Assuming I am very proficient in C, and unlikely to make too many memory/security leaks, do we see any real benefit to using C? Most places I look suggest that there is little performance benefit and that C is primarily used in the area of cryptography when things such as legacy compatibility and faster compilation times are needed. I was always under the impression that C was more performant than both Rust and C++ but perhaps I was misguided.

May 5, 2025 - 20:07
 0

If I am trying to achieve super-efficient cryptographic implementations, would C, C++ or Rust be better? I've found it really hard to ascertain which is best in general, let alone for the application to cryptography. I understand that Rust often provides superior performance due to its safety, particularly with regard to memory, but I wonder if this can be extrapolated to 'perfectly written' C (or C++) code.

Assuming I am very proficient in C, and unlikely to make too many memory/security leaks, do we see any real benefit to using C? Most places I look suggest that there is little performance benefit and that C is primarily used in the area of cryptography when things such as legacy compatibility and faster compilation times are needed.

I was always under the impression that C was more performant than both Rust and C++ but perhaps I was misguided.