HashProvider

Trait HashProvider 

Source
pub trait HashProvider {
    // Required methods
    fn hash(&self, data: &[u8]) -> [u8; 32];
    fn name(&self) -> &'static str;
}
Expand description

Hash provider trait for identity operations

This trait abstracts the hashing algorithm used for identity operations, following the Dependency Inversion Principle (DIP). The core identity logic depends on this abstraction rather than concrete implementations.

§Design Rationale

  • Decoupling: Core identity logic doesn’t depend on Blake3 directly
  • Testability: Can use mock hash providers in tests
  • Flexibility: Easy to switch hash algorithms if needed
  • Future-proofing: Supports quantum-resistant hashes in the future

Required Methods§

Source

fn hash(&self, data: &[u8]) -> [u8; 32]

Hash arbitrary data to a 32-byte digest

§Arguments
  • data - The data to hash
§Returns

A 32-byte hash digest

Source

fn name(&self) -> &'static str

Get the name of this hash provider (for debugging/logging)

Implementors§