mirror of
https://github.com/luxfi/crypto.git
synced 2026-07-27 01:54:50 +00:00
lux-crypto-secp256k1
Canonical Rust binding for Lux secp256k1 (EVM ecrecover precompile).
Wraps the secp256k1_ecrecover and secp256k1_ecrecover_batch symbols
exported by luxcpp/crypto/secp256k1. The C-ABI header is
luxcpp/crypto/include/lux/crypto/secp256k1.h.
Conforms to:
- SEC1 v2 §4.1.6 (Public Key Recovery Operation)
- EVM Yellow Paper Appendix E (
ECRECprecompile at 0x...01) - EIP-2 (signature malleability rule:
sin lower half ofn)
Use
use lux_crypto_secp256k1::{ecrecover, ecrecover_batch};
let pk = ecrecover(&hash, &r, &s, v)?; // Single recovery
let (pks, statuses) = ecrecover_batch(&inputs)?; // Batch path
Build
See lux-crypto-keccak/README.md for CRYPTO_DIR / CRYPTO_BUILD_DIR
discovery logic.
Test vectors
tests/spec_vectors.rs covers three independently-verified (hash, r, s, v)
triples generated by the production eth_keys library, plus batch round-trip
and v low-bit recid selection.
Source
C-ABI body: luxcpp/crypto/secp256k1/c-abi/c_secp256k1.cpp.