-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unnecessary call to secp256k1_sha256_initialize #1179
Comments
I think the call is correct at this level of abstraction. The caller in the However, that means that one could say that the code in the If we really want to fix this code smell, here are three ways:
I prefer solution 2. @Coding-Enthusiast, would be by any chance be interested in working on this? |
My C knowledge is readonly! How about letting the hash module handle the tagged hash computation in general. Something like what bitcoin core project does in the |
We want hard-coded midstates for performance. |
I see. My understanding is that HashWriter precomputes the midstates and is stored in memory to be reused so the performance should be the same. |
@Coding-Enthusiast That's not easily doable in C, as it has no runtime-computed constants. We'd need to store it in the context or so, and compute it on initialization. I think that's overkill for what we're doing here. |
When computing tagged-hashes for Schnorr sigs the 3 methods (challenge, aux, nonce) first call
secp256k1_sha256_initialize
that sets the hashstate (ie. s[0] to s[7] and bytes) to their default SHA256 values then they each immediately change all those values to the precomputed "midstate" values. The first call tosecp256k1_sha256_initialize
seems wasteful.secp256k1/src/modules/schnorrsig/main_impl.h
Lines 16 to 28 in 9a8d65f
secp256k1/src/hash_impl.h
Lines 31 to 41 in 9a8d65f
Cross post: bitcoin/bitcoin#26712
The text was updated successfully, but these errors were encountered: