UltrafastSecp256k1/compat/libsecp256k1_shim
Vano Chkheidze c38b659b06
fix: resolve all 213 code-scanning alerts + N-03 CT path for message signing
- bip39.cpp: fix 45 alerts (const-correctness, braces-around-stmts, init-vars, cert-err33-c)
- zk.cpp: fix 25 alerts (const-correctness, braces-around-stmts)
- ufsecp_impl.cpp: fix 72 alerts (braces, const, modernize-auto, init-vars, implicit-widening)
- message_signing.cpp: N-03 security fix (use ct::ecdsa_sign_recoverable on CT path)
- ct_sign.cpp + ct/sign.hpp: add ct::ecdsa_sign_recoverable implementation
- compat/libsecp256k1_shim: add secp256k1_ecdsa_sign_recoverable + secp256k1_ecdsa_recover
- SECURITY.md: Q-07 Known Non-CT Exceptions table with fix status
- Other alert files: address.cpp, coin_address.cpp, eth_signing.cpp, wallet.cpp,
  test_bip39.cpp, test_ethereum.cpp, test_wallet.cpp, test_zk.cpp, test_ffi_round_trip.cpp
2026-03-16 22:48:52 +04:00
..
include fix: resolve all 213 code-scanning alerts + N-03 CT path for message signing 2026-03-16 22:48:52 +04:00
src fix: resolve all 213 code-scanning alerts + N-03 CT path for message signing 2026-03-16 22:48:52 +04:00
CMakeLists.txt fix: resolve all 213 code-scanning alerts + N-03 CT path for message signing 2026-03-16 22:48:52 +04:00
README.md audit: add AUDIT_COVERAGE.md + ASCII cleanup + CT fixes 2026-02-25 19:14:21 +04:00

libsecp256k1 Compatibility Shim

A thin C API wrapper that maps the bitcoin-core/secp256k1 API surface onto UltrafastSecp256k1 internals.

Purpose

Drop-in replacement for projects written against the libsecp256k1 C API. Link this shim instead of libsecp256k1, and existing code works unchanged.

Supported API Surface

Category Functions Status
Context create, destroy, randomize [OK] Stub (context is no-op)
Public Keys pubkey_create, pubkey_parse, pubkey_serialize, pubkey_negate, pubkey_tweak_add, pubkey_tweak_mul, pubkey_combine [OK]
ECDSA ecdsa_sign, ecdsa_verify, signature_parse_compact, signature_serialize_compact, signature_normalize [OK]
Schnorr (BIP-340) schnorrsig_sign32, schnorrsig_verify [OK]
Extra Keys xonly_pubkey_parse, xonly_pubkey_serialize, keypair_create [OK]
Secret Keys seckey_verify, seckey_negate, seckey_tweak_add, seckey_tweak_mul [OK]
DER Signatures signature_parse_der, signature_serialize_der [OK]
Tagged Hash tagged_sha256 [OK]

Usage

# In your CMakeLists.txt
add_subdirectory(path/to/UltrafastSecp256k1/compat/libsecp256k1_shim)
target_link_libraries(my_app PRIVATE secp256k1_shim)

Then in your code -- no changes needed:

#include <secp256k1.h>
#include <secp256k1_schnorrsig.h>

secp256k1_context* ctx = secp256k1_context_create(SECP256K1_CONTEXT_NONE);
// ... all existing code works ...
secp256k1_context_destroy(ctx);

Limitations

  • Context randomization (secp256k1_context_randomize) is accepted but has no effect -- UltrafastSecp256k1 does not use blinding.
  • secp256k1_context_static is provided but points to a dummy.
  • secp256k1_ecdh and secp256k1_ellswift modules are not yet shimmed.
  • Performance characteristics differ (typically faster).

Building

cmake -S . -B build -G Ninja
cmake --build build