mirror of
https://github.com/luxfi/crypto.git
synced 2026-10-30 16:59:13 +00:00
Adds lux-crypto-{sha256, ripemd160, blake2b, aead, lamport, mldsa,
mlkem, slhdsa, banderwagon, pedersen, ipa, verkle, evm256, kzg} on
top of the existing keccak + secp256k1 + umbrella, gated on
verified-real C-ABI dispatch (nm shows the extern "C" symbols and
spec-vector integration tests assert byte-equality vs published
reference values).
Workspace test sweep (CRYPTO_BUILD_DIR=.../build-cto):
182 passed, 0 failed, 4 ignored (slow SLH-DSA 192f/256f).
Per crate:
* sha256 - 12 tests (FIPS 180-4 / RFC 6234)
* ripemd160 - 14 tests (Dobbertin et al. 1996)
* blake2b - 13 tests (RFC 7693 App. A)
* aead - 11 tests (RFC 8439 §2.8.2)
* lamport - 5 tests / 10 KAT vectors (luxfi/crypto KAT corpus)
* mldsa - 13 tests (FIPS 204 modes 2/3/5)
* mlkem - 12 tests (FIPS 203 modes 2/3/5, implicit rejection)
* slhdsa - 9 + 4 ignored (FIPS 205 sha2/shake 128f)
* banderwagon - 14 tests (16 published 2^i*G doublings KAT)
* pedersen - 12 tests (Banderwagon SRS)
* ipa - 12 tests (576-byte multiproof)
* verkle - 12 tests (256-element SRS)
* evm256 - 4 tests / 12 KAT vectors (BLS Fr, secp256k1 N, etc)
* kzg - 12 tests (verify_proof real; blob ops surfaced as
Internal(-5) since c_kzg_blob.cpp is in a separate
TU not yet linked into libkzg.a)
Refused to ship:
* blake3, poseidon, ed25519, bls — c-abi entry points still return
CRYPTO_ERR_NOTIMPL in luxcpp/crypto/<alg>/c-abi/c_<alg>.cpp.
* poly_mul — c-abi file is empty, no extern "C" exports.
Build: CRYPTO_BUILD_DIR=/path/to/luxcpp/crypto/build-cto cargo test --workspace
Each crate's build.rs links lib<alg>.a (c-abi shim) + lib<alg>_cpu.a
(implementation body); shared dependencies (sha256 for kzg+lamport,
banderwagon for pedersen+ipa+verkle, ipa SRS for pedersen, blst for
kzg, banderwagon_metal stub on macOS) are explicitly linked.
COVERAGE.md updated: 17 member crates, 182/182 tests passing,
deferred algorithms documented with their current c-abi status.
48 lines
1.7 KiB
Rust
48 lines
1.7 KiB
Rust
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 verkle_path = base.join("verkle");
|
|
let ipa_path = base.join("ipa");
|
|
let banderwagon_path = base.join("banderwagon");
|
|
println!("cargo:rustc-link-search=native={}", verkle_path.display());
|
|
println!("cargo:rustc-link-search=native={}", ipa_path.display());
|
|
println!("cargo:rustc-link-search=native={}", banderwagon_path.display());
|
|
println!("cargo:rustc-link-lib=static=verkle");
|
|
println!("cargo:rustc-link-lib=static=verkle_cpu");
|
|
println!("cargo:rustc-link-lib=static=ipa_cpu");
|
|
println!("cargo:rustc-link-lib=static=banderwagon_cpu");
|
|
|
|
if cfg!(target_os = "macos") {
|
|
let metal_lib = banderwagon_path.join("libbanderwagon_metal.a");
|
|
if metal_lib.exists() {
|
|
println!("cargo:rustc-link-lib=static=banderwagon_metal");
|
|
println!("cargo:rustc-link-lib=framework=Metal");
|
|
println!("cargo:rustc-link-lib=framework=Foundation");
|
|
}
|
|
println!("cargo:rustc-link-lib=c++");
|
|
} else {
|
|
println!("cargo:rustc-link-lib=stdc++");
|
|
}
|
|
}
|