vios_app 0.1.1

Small JSON vaults: Argon2id + AES-GCM, with optional AAD binding.
Documentation
// ✅ verify_cia_signature.rs — CIA™ Signature Verification Engine

use sha2::{Sha256, Digest};
use crate::vault::vault_structs::VaultComponents;

/// Verifies the CIA™ signature of a Vault against its contents.
/// Returns true if signature matches expected hash.
pub fn verify_cia_signature(vault: &VaultComponents) -> Result<bool, String> {
    // Serialize metadata for hashing
    let metadata_bytes = bincode::serialize(&vault.metadata)
        .map_err(|e| format!("❌ Failed to serialize metadata: {e}"))?;

    // Combine components to recreate original hash input
    let mut hasher = Sha256::new();
    hasher.update(&metadata_bytes);
    hasher.update(&vault.ciphertext);
    hasher.update(&vault.iv);
    hasher.update(&vault.salt);
    let expected_hash = hasher.finalize();
    let expected_hex = hex::encode(expected_hash);

    // Compare against stored CIA signature
    Ok(expected_hex == vault.cia_signature)
}