Open duesee opened 1 year ago
@franziskuskiefer, do you want to provide input on this? Otherwise I could just start and use what I think is appropriate. Naming and order is not super important but let's do that as long as it's easily possible and makes the next steps easier.
Some thought, but just go ahead
Try to make sure that only the actual function in question is measured, i.e. a little other things like allocations etc. For example, we don't care about the time it takes to load a public key to verify a signature. We don't have much influence on that. We want to know how long the function takes to verify a signature.
I think it would help to talk about comparisons (as with OpenSSL) and regression testing separately: To have comparable benchmarks, we should make sure that we "do the same" for HACL and, e.g., OpenSSL. For example, when the API call in HACL is unified such that it always hashes a message before signing, and OpenSSL hashes and signs in two steps, we should make sure to include the hashing step in OpenSSL. Otherwise we compare hashing+sign with sign-only.
For regression testing, I agree with your comment. We can put as much things as needed in the setup and only measure the single function we don't want to regress.
For some benchmarks comparisons and regression testing align, but not for all. I will take a look and point out these cases.
Examine timing anomalies:
(result != 1)
OpenSSL_Ed25519_Verify
seems to be very slow?OpenSSL_K256_ECDSA_Sign
seems to be slow?OpenSSL_K256_ECDSA_Verify
seems to be slow?OpenSSL_K256_ECDH
seems to be slow?EverCrypt_HKDF_SHA2_256_extract_expand
is faster than SHA2-512 variant.HACL_x25519_51_{,base}
seems off.[ ] Vectorized variants are slower? Measure with bigger messages to accomodate for CPU init?
Erroneous setups:
hacl_init_cpu_features()
EverCrypt_AutoConfig2_init()
Setup(...)
Copy&Paste Bugs:
BENCHMARK_CAPTURE
to prevent these errorsUsecases:
(message: &[u8], signature: &[u8], public_key: &[u8])
" and benchmark the whole usecase. Pay attention to missing (or extraneous) checks.state.PauseTiming()
could come in handy, although it is not recommended)ChaCha20Poly1305
ciphertext != expected_ciphertext
new_raw_private
inOpenSSL_Ed25519_Sign
into benchmark?HACL_NaCl_precomputed_combined
before loop to accomodate usecase?HACL_NaCl_precomputed_detached
before loop to accomodate usecase?Chore:
BENCHMARK
for (auto _: state) {
v.s.state.keepRunning()
Unsure:
OpenSSL_blake2b_oneshot
?OpenSSL_blake2s_oneshot
?