pub fn get_leaf_index(
leaf_id: &str,
) -> Result<ChildNumber, SparkCryptographyError>
Expand description
Calculates the derivation path component for a leaf key based on a leaf ID.
This function hashes the leaf ID using SHA-256 and processes the hash to derive a hardened index for use in leaf key derivation paths.
The index is calculated by:
- Computing SHA-256 hash of the leaf ID
- Interpreting the first 4 bytes of the hash as u32 value
- Modulo the u32 value with 0x80000000 to ensure it fits within valid index range
- Converting to a hardened ChildNumber
§Arguments
leaf_id
: The leaf ID in &str
format to derive the index for.
§Returns
A ChildNumber
representing the derived index, or an error if the derivation fails.