lib

Core libraries for Radroots
git clone https://radroots.dev/git/lib.git
Log | Files | Refs | README

commit 8329770143ddd719d67f4902026de6b691f6da37
parent d36a3aba66fa2bb0ef58702c1f71c10c891618d2
Author: triesap <tyson@radroots.org>
Date:   Sat, 18 Jul 2026 06:15:19 +0000

blossom: expose verified digest construction

- construct typed hashes from an already verified digest
- retain the canonical lowercase serialization contract
- preserve no-std compatibility for protocol consumers
- cover byte preservation with focused public tests

Diffstat:
Mcrates/blossom/src/hash.rs | 13+++++++++++++
1 file changed, 13 insertions(+), 0 deletions(-)

diff --git a/crates/blossom/src/hash.rs b/crates/blossom/src/hash.rs @@ -12,6 +12,10 @@ const LOWER_HEX: &[u8; 16] = b"0123456789abcdef"; pub struct RadrootsBlossomSha256([u8; SHA256_BYTES]); impl RadrootsBlossomSha256 { + pub const fn from_bytes(bytes: [u8; SHA256_BYTES]) -> Self { + Self(bytes) + } + pub fn digest(bytes: &[u8]) -> Self { let digest = Sha256::digest(bytes); let mut value = [0_u8; SHA256_BYTES]; @@ -272,6 +276,15 @@ mod tests { } #[test] + fn hash_preserves_verified_digest_bytes() { + let bytes = [0xabu8; SHA256_BYTES]; + let hash = RadrootsBlossomSha256::from_bytes(bytes); + + assert_eq!(hash.as_bytes(), &bytes); + assert_eq!(hash.to_hex(), "ab".repeat(SHA256_BYTES)); + } + + #[test] fn hash_rejects_wrong_length_case_and_alphabet() { for value in [ "",