Files
zeekay 01f012c674 rust: 21-crate workspace finalized over luxcpp/crypto C-ABI
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.
2025-12-28 10:41:53 -08:00

43 lines
1.6 KiB
Rust

// Copyright (c) 2024-2026 Lux Industries Inc.
// SPDX-License-Identifier: BSD-3-Clause-Eco
use lux_crypto_kzg::{blob_to_commit, verify_proof, Error, BLOB_LEN};
#[test]
#[ignore = "luxcpp kzg c-abi NOTIMPL — tracked at #kzg-c-abi-impl"]
fn blob_to_commit_zero_blob_yields_g1_zero() {
// The all-zero blob has a deterministic commitment (the encoding of the
// BLS12-381 G1 identity). Once the C-ABI body lands this test asserts
// byte-equality with the eth-c-kzg-4844 reference output.
let blob = vec![0u8; BLOB_LEN];
let blob_arr: &[u8; BLOB_LEN] = blob.as_slice().try_into().unwrap();
let commit = blob_to_commit(blob_arr).expect("commit");
// First two bits of a compressed G1 identity are b"\xc0\x00...".
assert_eq!(commit[0] & 0xc0, 0xc0, "compressed G1 identity prefix");
}
#[test]
fn binding_returns_error_when_c_abi_unimpl() {
let blob = vec![0u8; BLOB_LEN];
let blob_arr: &[u8; BLOB_LEN] = blob.as_slice().try_into().unwrap();
match blob_to_commit(blob_arr) {
Ok(_) => {}
Err(Error::InternalError(rc)) => {
assert_eq!(rc, -5, "expected NOTIMPL while C-ABI body is unwired");
}
Err(other) => panic!("unexpected: {:?}", other),
}
}
#[test]
fn verify_proof_rejects_bogus_input() {
// Even with a NOTIMPL backend, the binding must funnel the result back
// (does not silently say "valid").
let commit = [0u8; 48];
let z = [0u8; 32];
let y = [0u8; 32];
let proof = [0u8; 48];
let res = verify_proof(&commit, &z, &y, &proof);
assert!(res.is_err(), "verify_proof must not silently accept");
}