Crate atlas_common

Crate atlas_common 

Source
Expand description

§Atlas Common

Core functionality shared across Atlas components for machine learning provenance tracking.

This crate provides essential building blocks for creating Content Authenticity Initiative (C2PA) compliant systems for tracking the provenance of machine learning models, datasets, and related assets.

§Features

  • Cryptographic Hashing: SHA-256/384/512 support with constant-time comparison
  • C2PA Metadata: Types and utilities for C2PA manifest management
  • Storage Abstractions: Backend-agnostic storage interfaces
  • Validation: Comprehensive validation for manifests, URNs, and hashes
  • Secure File Operations: Protection against symlink and hardlink attacks

§Feature Flags

  • hash (default): Cryptographic hash functions
  • c2pa (default): C2PA manifest and asset types
  • storage: Storage backend abstractions
  • validation: Validation utilities
  • file-utils: Secure file operation utilities
  • async: Async support for storage operations
  • full: Enable all features

§Example

use atlas_common::{
    hash::{calculate_hash, HashAlgorithm},
    c2pa::{ManifestId, ManifestMetadata, ManifestType},
    Result,
};

fn main() -> Result<()> {
    // Calculate hash of model data
    let model_data = b"pretrained weights";
    let hash = calculate_hash(model_data);
     
    // Create a C2PA manifest ID
    let manifest_id = ManifestId::new();
    println!("Manifest URN: {}", manifest_id.as_urn());
     
    // Create manifest metadata
    let metadata = ManifestMetadata {
        id: manifest_id.as_urn().to_string(),
        name: "GPT-2 Fine-tuned Model".to_string(),
        manifest_type: ManifestType::Model,
        created_at: atlas_common::c2pa::DateTimeWrapper::now_utc().to_rfc3339(),
        hash: Some(hash),
        size: Some(1024 * 1024 * 50),
        version: Some("1.0.0".to_string()),
    };
     
    Ok(())
}

Re-exports§

pub use error::Error;
pub use error::Result;
pub use hash::HashAlgorithm;
pub use hash::Hasher;
pub use c2pa::AssetType;
pub use c2pa::ManifestId;
pub use c2pa::ManifestMetadata;
pub use c2pa::ManifestType;
pub use storage::StorageBackend;
pub use storage::StorageConfig;
pub use storage::StorageType;

Modules§

c2pa
C2PA (Coalition for Content Provenance and Authenticity) support
error
Error types for Atlas Core
file
Secure file operation utilities
hash
Cryptographic hash functionality
storage
Storage backend abstractions
validation
Validation utilities for manifests and hashes

Constants§

VERSION
Library version

Functions§

init
Initialize the library