pub const LOCATOR_CONTEXT: [u8; 32] =
hex_literal::hex!("224DFBA2A0DE0FEC0A2073D78B8DCFEE91A037BC7749639A0D5E83DF307BA93A");
pub fn blob_locator(handle: [u8; 32]) -> [u8; 32] {
let mut block = [0; 64];
block[..32].copy_from_slice(&LOCATOR_CONTEXT);
block[32..].copy_from_slice(&handle);
*blake3::hash(&block).as_bytes()
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn locator_matches_its_known_answer() {
assert_eq!(
blob_locator([1; 32]),
hex_literal::hex!("501F0C513B16AB49D80B1C440F848C18A3DDE215F802026B8CEE5C71515CCC51")
);
}
#[test]
fn locator_is_not_the_handle() {
for handle in [[0; 32], [1; 32], [255; 32]] {
assert_ne!(blob_locator(handle), handle);
}
}
}