moloch-core 0.1.0

Core types and primitives for Moloch audit chain
Documentation

Moloch Core - Fundamental types for the Moloch audit chain.

This crate provides the core data structures and cryptographic primitives used throughout the Moloch system:

  • [crypto] - Hashing (BLAKE3) and signatures (Ed25519)
  • [event] - Audit events (the atomic unit of the chain)
  • [block] - Blocks that batch events together
  • [proof] - Merkle proofs for inclusion verification

Example

use moloch_core::{
    crypto::SecretKey,
    event::{ActorId, ActorKind, AuditEvent, EventType, ResourceId, ResourceKind},
    block::BlockBuilder,
};

// Generate a key for signing
let key = SecretKey::generate();

// Create an audit event
let actor = ActorId::new(key.public_key(), ActorKind::User);
let resource = ResourceId::new(ResourceKind::Repository, "myrepo");

let event = AuditEvent::builder()
    .now()
    .event_type(EventType::Push { force: false, commits: 1 })
    .actor(actor)
    .resource(resource)
    .sign(&key)
    .unwrap();

// Create a block containing the event
let sealer = moloch_core::block::SealerId::new(key.public_key());
let block = BlockBuilder::new(sealer)
    .events(vec![event])
    .seal(&key);

assert!(block.validate(None).is_ok());