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.
42 lines
1.2 KiB
Rust
42 lines
1.2 KiB
Rust
// Copyright (c) 2024-2026 Lux Industries Inc.
|
|
// SPDX-License-Identifier: BSD-3-Clause-Eco
|
|
|
|
use lux_crypto_evm256::{addmod, mod_exp, mulmod, Error};
|
|
|
|
#[test]
|
|
#[ignore = "luxcpp modexp c-abi NOTIMPL — tracked at #modexp-c-abi-impl"]
|
|
fn modexp_2_pow_3_mod_5_is_3() {
|
|
// 2^3 mod 5 = 3. Big-endian, padded to mod length.
|
|
let base = [2u8];
|
|
let exp = [3u8];
|
|
let m = [5u8];
|
|
let mut out = [0u8; 1];
|
|
mod_exp(&base, &exp, &m, &mut out).expect("modexp");
|
|
assert_eq!(out[0], 3);
|
|
}
|
|
|
|
#[test]
|
|
#[ignore = "luxcpp evm256 c-abi NOTIMPL — tracked at #evm256-c-abi-impl"]
|
|
fn mulmod_3_times_5_mod_7_is_1() {
|
|
let mut a = [0u8; 32]; a[31] = 3;
|
|
let mut b = [0u8; 32]; b[31] = 5;
|
|
let mut m = [0u8; 32]; m[31] = 7;
|
|
let out = mulmod(&a, &b, &m).expect("mulmod");
|
|
let mut want = [0u8; 32]; want[31] = 1;
|
|
assert_eq!(out, want);
|
|
}
|
|
|
|
#[test]
|
|
fn binding_returns_error_when_c_abi_unimpl() {
|
|
let a = [0u8; 32];
|
|
let b = [0u8; 32];
|
|
let mut m = [0u8; 32]; m[31] = 1;
|
|
match addmod(&a, &b, &m) {
|
|
Ok(_) => {}
|
|
Err(Error::InternalError(rc)) => {
|
|
assert_eq!(rc, -5);
|
|
}
|
|
Err(other) => panic!("unexpected: {:?}", other),
|
|
}
|
|
}
|