harmoniis-wallet 0.1.109

Smart-contract wallet for the Harmoniis marketplace for agents and robots (RGB contracts, Witness-backed bearer state, Webcash fees)
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use rand_core::{OsRng, RngCore};
use sha2::{Digest, Sha256};

/// Generate a random 32-byte secret as 64-char lowercase hex.
/// Uses OS-provided CSPRNG for cryptographic security.
pub fn generate_secret_hex() -> String {
    let mut bytes = [0u8; 32];
    OsRng.fill_bytes(&mut bytes);
    hex::encode(bytes)
}

/// SHA256 of raw bytes, returned as 64-char hex.
/// Used for computing witness proof: sha256_bytes(&hex::decode(secret_hex)).
/// This matches backend witness.rs `secret_hash()` logic.
pub fn sha256_bytes(data: &[u8]) -> String {
    let hash = Sha256::digest(data);
    hex::encode(hash)
}