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.
56 lines
1.4 KiB
Rust
56 lines
1.4 KiB
Rust
// Copyright (c) 2024-2026 Lux Industries Inc.
|
|
// SPDX-License-Identifier: BSD-3-Clause-Eco
|
|
//
|
|
// RIPEMD-160 known-answer tests from Dobbertin/Bosselaers/Preneel test suite
|
|
// (1996) and matched against OpenSSL test corpus.
|
|
|
|
use lux_crypto_ripemd160::{hash, DIGEST_LEN};
|
|
|
|
fn from_hex(s: &str) -> [u8; DIGEST_LEN] {
|
|
let b = s.as_bytes();
|
|
assert_eq!(b.len(), 2 * DIGEST_LEN);
|
|
let nibble = |c: u8| -> u8 {
|
|
match c {
|
|
b'0'..=b'9' => c - b'0',
|
|
b'a'..=b'f' => c - b'a' + 10,
|
|
b'A'..=b'F' => c - b'A' + 10,
|
|
_ => panic!("non-hex"),
|
|
}
|
|
};
|
|
let mut out = [0u8; DIGEST_LEN];
|
|
for i in 0..DIGEST_LEN {
|
|
out[i] = (nibble(b[2 * i]) << 4) | nibble(b[2 * i + 1]);
|
|
}
|
|
out
|
|
}
|
|
|
|
#[test]
|
|
fn empty_string() {
|
|
let want = from_hex("9c1185a5c5e9fc54612808977ee8f548b2258d31");
|
|
assert_eq!(hash(b""), want);
|
|
}
|
|
|
|
#[test]
|
|
fn a() {
|
|
let want = from_hex("0bdc9d2d256b3ee9daae347be6f4dc835a467ffe");
|
|
assert_eq!(hash(b"a"), want);
|
|
}
|
|
|
|
#[test]
|
|
fn abc() {
|
|
let want = from_hex("8eb208f7e05d987a9b044a8e98c6b087f15a0bfc");
|
|
assert_eq!(hash(b"abc"), want);
|
|
}
|
|
|
|
#[test]
|
|
fn message_digest() {
|
|
let want = from_hex("5d0689ef49d2fae572b881b123a85ffa21595f36");
|
|
assert_eq!(hash(b"message digest"), want);
|
|
}
|
|
|
|
#[test]
|
|
fn alphabet() {
|
|
let want = from_hex("f71c27109c692c1b56bbdceb5b9d2865b3708dbc");
|
|
assert_eq!(hash(b"abcdefghijklmnopqrstuvwxyz"), want);
|
|
}
|