Is public key derivation optimised or not? #1132

issue k06a opened this issue on August 4, 2022
  1. k06a commented at 4:31 PM on August 4, 2022: none

    It seems secp256k1_ec_pubkey_create() is not taking advantage of being called from different cores. And I see it's speed is around 25000/sec on my Apple M1 Max CPU.

    I am curious if you're using precached points for private keys 1,2,4,8,… 2^255 and use up to 256 point additions to construct public key from private key?

  2. sipa commented at 4:48 PM on August 4, 2022: contributor

    libsecp256k1 is not a multi-threaded library. If you want to make use of multiple cores, you need to invoke it from multiple threads yourself (the library is thread-safe, in that you can invoke it multiple times simultaneously, and even reuse the same context across threads if you only use functions that take constant contexts).

    Beyond, key generation is very much optimized, and uses significant precomputed table to reduce the number of operations. Generating a key takes far less than 256 point additions.

  3. k06a commented at 6:17 PM on August 4, 2022: none

    @sipa thanks for the detailed answer. I tried to call it from 8 cores but speed of each core dropped proportionally. Even running multiple applications with single thread affects speed significantly.

  4. sipa commented at 6:19 PM on August 4, 2022: contributor

    @k06a CPUs generally slow down when you're using more than one of its cores simultaneously, and even more when you're doing more things than you have cores. This has nothing to do with libsecp256k1.

  5. k06a commented at 6:34 PM on August 5, 2022: none

    Thanks again for your answer. I discovered issue reason between private keys generation and public key derivation - memory mapped file to store results behaves unexpectedly on massive random access writes.

  6. k06a closed this on Aug 5, 2022

Contributors

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin-core/secp256k1. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-19 09:15 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me