arsenal-crypto · hash
Declared module signatures, types, configuration, and source documentation.
Source: arsenal/crates/arsenal-crypto/src/hash.rs. SHA-256: 9621f169b03ad4b071e4f054751737da83041277e4cf08f8c2ce264cbc103db1.
This source reference follows declared modules and preserves feature attributes. It includes public declarations and implementation methods in those modules. Private-module exports and trait resolution still require the compiler; not every declaration is a crate-root import. Function bodies and constant values are omitted. Source comments describe their implementation context and are not a production deployment claim.
hash::Hash
A 32-byte hash output
#[derive(Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub struct Hash([u8; 32]);Source line: 16.
hash::Hash::from_bytes
Create a hash from raw bytes
#[must_use]
pub const fn from_bytes(bytes: [u8; 32]) -> Self;Source line: 21.
hash::Hash::digest
Hash some data
#[must_use]
pub fn digest(data: &[u8]) -> Self;Source line: 27.
hash::Hash::digest_many
Hash multiple pieces of data
#[must_use]
pub fn digest_many(parts: &[&[u8]]) -> Self;Source line: 33.
hash::Hash::keyed
Create a keyed hash (MAC)
#[must_use]
pub fn keyed(key: &[u8; 32], data: &[u8]) -> Self;Source line: 43.
hash::Hash::as_bytes
Get the raw bytes
#[must_use]
pub const fn as_bytes(&self) -> &[u8; 32];Source line: 49.
hash::Hash::to_hex
Convert to hex string
#[must_use]
pub fn to_hex(&self) -> String;Source line: 55.
hash::Hash::from_hex
Parse from hex string
Errors
Returns an error if the hex string is invalid
pub fn from_hex(hex_str: &str) -> ArsenalResult<Self>;Source line: 63.
hash::Hash::ct_eq
Constant-time comparison
#[must_use]
pub fn ct_eq(&self, other: &Self) -> bool;Source line: 76.
hash::Hash::verify_keyed
Verify a keyed hash
#[must_use]
pub fn verify_keyed(key: &[u8; 32], data: &[u8], expected: &Self) -> bool;Source line: 86.
hash::Hasher
Incremental hasher for large data
pub struct Hasher {
}Source line: 111.
hash::Hasher::new
Create a new hasher
#[must_use]
pub fn new() -> Self;Source line: 118.
hash::Hasher::new_keyed
Create a keyed hasher
#[must_use]
pub fn new_keyed(key: &[u8; 32]) -> Self;Source line: 126.
hash::Hasher::new_derive_key
Create a hasher for key derivation
#[must_use]
pub fn new_derive_key(context: &str) -> Self;Source line: 134.
hash::Hasher::update
Update the hasher with more data
pub fn update(&mut self, data: &[u8]) -> &mut Self;Source line: 141.
hash::Hasher::finalize
Finalize and get the hash
#[must_use]
pub fn finalize(self) -> Hash;Source line: 148.
hash::Hasher::finalize_xof
Finalize with extended output
pub fn finalize_xof(self, output: &mut [u8]);Source line: 153.
hash::Hasher::reset
Reset the hasher for reuse
pub fn reset(&mut self);Source line: 159.
hash::HashChain
Hash chain for audit log integrity
#[derive(Debug, Clone)]
pub struct HashChain {
}Source line: 178.
hash::HashChain::new
Create a new hash chain with a genesis hash
#[must_use]
pub fn new() -> Self;Source line: 188.
hash::HashChain::from_head
Create from an existing head hash
#[must_use]
pub fn from_head(head: Hash, count: u64) -> Self;Source line: 199.
hash::HashChain::append
Add an entry to the chain
pub fn append(&mut self, data: &[u8]) -> Hash;Source line: 204.
hash::HashChain::head
Get the current head hash
#[must_use]
pub fn head(&self) -> &Hash;Source line: 216.
hash::HashChain::count
Get the entry count
#[must_use]
pub fn count(&self) -> u64;Source line: 222.
hash::HashChain::verify_sequence
Verify that a sequence of entries produces the expected head
#[must_use]
pub fn verify_sequence(entries: &[&[u8]], expected_head: &Hash) -> bool;Source line: 228.
hash::MerkleTree
Merkle tree for efficient verification of large datasets
#[derive(Debug, Clone)]
pub struct MerkleTree {
}Source line: 245.
hash::MerkleTree::new
Create a new empty Merkle tree
#[must_use]
pub fn new() -> Self;Source line: 257.
hash::MerkleTree::from_leaves
Build a Merkle tree from leaf data
#[must_use]
pub fn from_leaves(leaf_data: &[&[u8]]) -> Self;Source line: 267.
hash::MerkleTree::add_leaf
Add a leaf to the tree
pub fn add_leaf(&mut self, data: &[u8]);Source line: 277.
hash::MerkleTree::compute_root
Compute the root hash
pub fn compute_root(&mut self) -> Option<Hash>;Source line: 283.
hash::MerkleTree::root
Get the root hash
#[must_use]
pub fn root(&self) -> Option<&Hash>;Source line: 316.
hash::MerkleTree::len
Get the number of leaves
#[must_use]
pub fn len(&self) -> usize;Source line: 322.
hash::MerkleTree::is_empty
Check if the tree is empty
#[must_use]
pub fn is_empty(&self) -> bool;Source line: 328.
hash::fingerprint_init
Initialize a fingerprint hash chain state.
Computes: BLAKE3("arsenal.fingerprint.init" || agent_did || timestamp || nonce)
This is the server-side computation that matches
[arsenal_core::fingerprint::FingerprintState::init].
#[must_use]
pub fn fingerprint_init(
agent_did: &str,
timestamp: &chrono::DateTime<chrono::Utc>,
nonce: &[u8; 32],
) -> [u8; 32];Source line: 348.
hash::fingerprint_advance
Advance a fingerprint hash chain by one step.
Computes: BLAKE3("arsenal.fingerprint.advance" || state_n || request_id || timestamp)
#[must_use]
pub fn fingerprint_advance(
current_state: &[u8; 32],
request_id: &uuid::Uuid,
timestamp: &chrono::DateTime<chrono::Utc>,
) -> [u8; 32];Source line: 365.
hash::fingerprint_hash
Compute the fingerprint to send as a header from the chain state.
The fingerprint is BLAKE3(state_n) — the raw state is never transmitted,
only its hash. This prevents state reconstruction if the fingerprint header
is intercepted.
#[must_use]
pub fn fingerprint_hash(state: &[u8; 32]) -> [u8; 32];Source line: 384.