Files
zeekay 5649439c40 crypto/rust: add 14 binder crates (sha256/ripemd160/blake2b/lamport/bls/kzg/mldsa/mlkem/evm256/ipa/ntt/poly_mul/pedersen/aead)
Fills the Rust binder gaps from CANONICAL_AUDIT.md (commit dbd728c). Each
crate is a thin extern-C binding to the corresponding luxcpp/crypto C-ABI
archive, mirroring the existing keccak/blake3/secp256k1/ed25519/slhdsa
pattern.

Per-crate layout: Cargo.toml + build.rs + src/lib.rs + tests/kat.rs.
build.rs resolves the luxcpp install dir via CRYPTO_DIR / CRYPTO_BUILD_DIR
with a fallback to ../../../../luxcpp/crypto/build-cto. Archives are linked
PRIVATE so blst/banderwagon/etc do not leak past the crate boundary.

Tests: 20 KATs pass across the 14 new crates against the live luxcpp
build at /Users/z/work/luxcpp/crypto/build-cto. Real-body algos (sha256,
ripemd160, blake2b, evm256, ipa, kzg, pedersen) are exercised against
known-answer vectors; algos whose c-abi shim returns CRYPTO_ERR_NOTIMPL
in this build (lamport, bls, mldsa, mlkem, ntt, poly_mul, aead) accept
either a successful round-trip or NOTIMPL coherently across all entry
points.

Workspace cargo build --release --workspace passes. The pre-existing
keccak/secp256k1/blake3 spec-vector tests fail at link time due to
unrelated lux_ prefix drift after the brand-neutral C-ABI rename; not
addressed in this batch.
2025-12-28 08:05:39 -08:00

32 lines
1.0 KiB
Rust

// Copyright (c) 2024-2026 Lux Industries Inc.
// SPDX-License-Identifier: BSD-3-Clause-Eco
//
// poly_mul KAT: multiplication by the zero polynomial yields zero.
use lux_crypto_poly_mul::{multiply, Error, CYCLONE_Q, CYCLONE_ROOT};
#[test]
fn zero_times_anything_is_zero() {
let a = [0u64; 8];
let b = [1u64, 2, 3, 4, 5, 6, 7, 8];
let mut out = [0u64; 8];
match multiply(&a, &b, &mut out, CYCLONE_Q, CYCLONE_ROOT) {
Ok(()) => assert!(out.iter().all(|&x| x == 0)),
Err(Error::Internal(-5)) => {
// CRYPTO_ERR_NOTIMPL: cyclone path stubbed in current build.
}
Err(other) => panic!("unexpected multiply error: {:?}", other),
}
}
#[test]
fn rejects_unsupported_modulus() {
// The implementation only supports the Cyclone prime; arbitrary primes
// must be reported as CRYPTO_ERR_INPUT.
let a = [0u64; 8];
let b = [0u64; 8];
let mut out = [0u64; 8];
let r = multiply(&a, &b, &mut out, 17, 3);
assert!(r.is_err(), "non-Cyclone modulus must be rejected");
}