Skip to content
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

update to libsecp256k1 0.5.1 for small signing performance improvement #481

Merged
merged 1 commit into from
Aug 6, 2024

Conversation

spoonincode
Copy link
Member

@spoonincode spoonincode commented Aug 6, 2024

Bump libsecp256k1 to v0.5.1.

v0.5.1 changes the default pre computed table size used for signing. The default was changed to match what Bitcoin Core is using (the highest configuration; i.e. largest table). So, change our configuration to match the new default. It seems entirely reasonable to use the same configuration Bitcoin Core does.

On a i7-12700K this improves signing time from about 17.4µs to 16.8µs on a gcc14 build. A 3% improvement at the cost of the secp256k1 context growing by 64KB (inconsequential growth).

@@ -5,8 +5,7 @@ add_library(secp256k1-internal INTERFACE)
target_include_directories(secp256k1-internal INTERFACE secp256k1/src)

target_compile_definitions(secp256k1-internal INTERFACE ENABLE_MODULE_RECOVERY=1
ENABLE_MODULE_EXTRAKEYS=1
COMB_BLOCKS=11
COMB_BLOCKS=43
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These COMB settings come from
https://github.com/bitcoin-core/secp256k1/blob/3fdf146bad042a17f6b2f490ef8bd9d8e774cdbd/CMakeLists.txt#L93-L105
notice the default setting is now 86 and the COMB defines match what is here.

@@ -5,8 +5,7 @@ add_library(secp256k1-internal INTERFACE)
target_include_directories(secp256k1-internal INTERFACE secp256k1/src)

target_compile_definitions(secp256k1-internal INTERFACE ENABLE_MODULE_RECOVERY=1
ENABLE_MODULE_EXTRAKEYS=1
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EXTRAKEYS was added in #142 (comment) and as I suspected at that time, this was indeed a dependency oversight and has been fixed in 0.5.1.

@spoonincode spoonincode merged commit a7daa81 into main Aug 6, 2024
36 checks passed
@spoonincode spoonincode deleted the libsecp256k1_051 branch August 6, 2024 20:09
@ericpassmore
Copy link
Contributor

Note:start
group: STABILITY
category: INTERNALS
summary: Update libsecp256k1 faster speed and matches what Bitcoin Core is using.
Note:end

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.

4 participants