Files
secp256k1-zkp/src
merge-script 1aafe15139 Merge bitcoin-core/secp256k1#1777: Make SHA256 compression runtime pluggable
4d92a083bc sha256: speed up writes using multi-block compression (furszy)
0753f8b909 Add API to override SHA256 compression at runtime (furszy)
fdb6a91a5e Introduce hash context to support pluggable SHA256 compression (furszy)

Pull request description:

  Tackling the long-standing request #702.

  Right now we ship our own SHA256 implementation, a standard baseline version that does not take advantage of any hardware-optimized instruction, and it cannot be accessed by the embedding application - it is for internal usage only.

  This means embedding applications often have to implement or include a different version for their use cases, wasting space on constrained environments, and in performance-sensitive setups it forces them to use a slower path than what the platform provides. Many projects already rely on tuned SHA-NI / ARMv8 / or other hardware-optimized code, so always using the baseline implementation we ship within the library is not ideal.

  These changes allow users to supply their own SHA256 compression function at runtime, while preserving the existing default behavior for everyone else. This is primarily intended for environments where the available SHA256 implementation is detected dynamically and recompiling the library with a different implementation is not feasible (equivalent build-time functionality will come in a follow-up PR).

  It introduces a new API:

  ```C89
  secp256k1_context_set_sha256_transform_callback(ctx, fn_transform)
  ```

  This function installs the optimized SHA256 compression into the `secp256k1_context`, which is then used by all internal computations. Important: The provided function is verified to be output-equivalent to the original one.

  As a quick example, using this functionality in Bitcoin-Core will be very straightforward: f68bef06d9

ACKs for top commit:
  real-or-random:
    ACK 4d92a083bc
  w0xlt:
    ACK 4d92a083bc
  theStack:
    ACK 4d92a083bc

Tree-SHA512: 058e2e82071f1ca77254b684458292c621e60d65bbcc5500574429717e7db75bc9f3221129fafd11eb5d33e666a5efec5e9844460d3b194ef3b6b16f2df28fb9
2026-03-04 08:43:07 +01:00
..
2026-02-02 13:01:18 +00:00
2025-09-08 12:26:04 -04:00
2026-02-02 13:01:18 +00:00
2024-04-25 20:23:31 +00:00
2024-04-25 20:23:31 +00:00
2022-11-07 16:37:24 -05:00
2022-11-07 16:37:24 -05:00
2024-09-25 11:05:23 -04:00
2023-02-28 15:54:00 -05:00
2024-09-25 11:05:23 -04:00
2023-02-28 15:54:00 -05:00
2025-09-08 12:26:04 -04:00
2024-10-21 09:18:44 +00:00
2026-03-02 15:06:39 +01:00