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.
46 lines
1.5 KiB
Rust
46 lines
1.5 KiB
Rust
// Build script for lux-crypto-sha256.
|
|
//
|
|
// Discovers `sha256/libsha256.a` produced by `luxcpp/crypto/sha256` and emits
|
|
// the link directives. Resolution order:
|
|
// 1. CRYPTO_DIR -> $CRYPTO_DIR/lib/sha256/libsha256.a
|
|
// 2. CRYPTO_BUILD_DIR -> $CRYPTO_BUILD_DIR/sha256/libsha256.a
|
|
// 3. Default to ../../../../luxcpp/crypto/build-cto/sha256/
|
|
|
|
use std::env;
|
|
use std::path::PathBuf;
|
|
|
|
fn main() {
|
|
let manifest_dir = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap());
|
|
let base: PathBuf = if let Ok(d) = env::var("CRYPTO_DIR") {
|
|
PathBuf::from(d).join("lib")
|
|
} else if let Ok(d) = env::var("CRYPTO_BUILD_DIR") {
|
|
PathBuf::from(d)
|
|
} else {
|
|
manifest_dir
|
|
.join("..")
|
|
.join("..")
|
|
.join("..")
|
|
.join("..")
|
|
.join("luxcpp")
|
|
.join("crypto")
|
|
.join("build-cto")
|
|
};
|
|
|
|
println!("cargo:rerun-if-changed=src/lib.rs");
|
|
println!("cargo:rerun-if-env-changed=CRYPTO_DIR");
|
|
println!("cargo:rerun-if-env-changed=CRYPTO_BUILD_DIR");
|
|
|
|
let lib_path = base.join("sha256");
|
|
println!("cargo:rustc-link-search=native={}", lib_path.display());
|
|
// libsha256.a holds the C-ABI shim; libsha256_cpu.a holds the C++ body it
|
|
// delegates into (namespaced cevm::crypto::sha256). Both are needed.
|
|
println!("cargo:rustc-link-lib=static=sha256");
|
|
println!("cargo:rustc-link-lib=static=sha256_cpu");
|
|
|
|
if cfg!(target_os = "macos") {
|
|
println!("cargo:rustc-link-lib=c++");
|
|
} else {
|
|
println!("cargo:rustc-link-lib=stdc++");
|
|
}
|
|
}
|