proofmode 0.9.0

Capture, share, and preserve verifiable photos and videos
Documentation
pub mod core;
pub mod utils;

#[cfg(any(feature = "sequoia-openpgp", not(feature = "wasm")))]
pub mod native;

#[cfg(feature = "wasm")]
pub mod wasm;

#[cfg(all(feature = "c2pa", not(target_arch = "wasm32")))]
pub mod c2pa;

use crate::generate_error::ProofModeError;
use crate::generate_types::Metadata;
use std::path::Path;

pub fn generate_proof_from_file(
    file_path: &Path,
    storage_path: &Path,
    email: &str,
    passphrase: &str,
    metadata: Option<Metadata>,
) -> Result<String, ProofModeError> {
    #[cfg(any(feature = "sequoia-openpgp", not(feature = "wasm")))]
    {
        native::generate_proof_from_file_sync(file_path, storage_path, email, passphrase, metadata)
    }

    #[cfg(all(feature = "wasm", not(feature = "sequoia-openpgp")))]
    {
        let _ = (file_path, storage_path, email, passphrase, metadata);
        Err(ProofModeError::Crypto(
            "File operations not supported in WASM. Use generate_proof_from_data instead."
                .to_string(),
        ))
    }
}

pub fn generate_proof_from_data(
    media_data: &[u8],
    storage_path: &Path,
    email: &str,
    passphrase: &str,
    metadata: Option<Metadata>,
) -> Result<String, ProofModeError> {
    #[cfg(any(feature = "sequoia-openpgp", not(feature = "wasm")))]
    {
        native::generate_proof_from_data_sync(media_data, storage_path, email, passphrase, metadata)
    }

    #[cfg(all(feature = "wasm", not(feature = "sequoia-openpgp")))]
    {
        let _ = (media_data, storage_path, email, passphrase, metadata);
        Err(ProofModeError::Crypto(
            "Native storage not supported in WASM. Use WASM-specific API instead.".to_string(),
        ))
    }
}