mirror of
https://github.com/luxfi/crypto.git
synced 2026-10-30 16:59:13 +00:00
One Rust crate per algorithm, plus an `lux-crypto` umbrella that re-exports
each per-algorithm crate behind a Cargo feature.
5 working crates with verified spec vectors:
- lux-crypto-keccak (Ethereum keccak256)
- lux-crypto-secp256k1 (ecrecover precompile + batch)
- lux-crypto-sha256 (FIPS 180-4)
- lux-crypto-ripemd160 (Bitcoin/Ethereum address derivation)
- lux-crypto-blake2b (RFC 7693)
15 wired-but-NOTIMPL crates (canonical Rust binding shipped, body returns
CRYPTO_ERR_NOTIMPL today; spec-vector tests gated `#[ignore]` with FIXME):
blake3, ed25519, slhdsa, mldsa, mlkem, bls, kzg, bn254, aead, ipa,
pedersen, lamport, ntt, poly-mul, evm256.
cargo check --release --workspace --all-features OK
cargo test --release --workspace 55 pass / 0 fail / 25 ignored
cargo doc --no-deps --workspace clean
cargo publish --dry-run --no-verify OK for all 20 leaf crates
Workspace docs added at rust/{README,PUBLISHING,RUST_CRATE_STATUS}.md.
Per-crate README.md and `Cargo.toml` metadata (description, license,
repository, keywords, categories, readme) wired for crates.io publish.
Build directives normalized: link both `lib<alg>.a` (C-ABI shim) and
`lib<alg>_cpu.a` (CPU body); brand-neutral C symbols (no lux_ prefix) per
the prefix-uniform audit.
1.0 KiB
1.0 KiB
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.