pub struct Adrs { /* private fields */ }Expand description
A 32-byte address structure used to domain-separate hash function calls in SLH-DSA.
Every hash invocation in SLH-DSA includes an Adrs value that encodes the position
within the signing hierarchy (layer, tree, leaf, chain step, etc.). This ensures that
hash outputs at different positions are cryptographically independent.
The type-specific fields (bytes 20..32) have different interpretations depending on the address type:
- WOTS_HASH / WOTS_PK / WOTS_PRF: key pair address, chain address, hash address
- TREE: padding (0), tree height, tree index
- FORS_TREE / FORS_ROOTS / FORS_PRF: key pair address, tree height, tree index
Implementations§
Source§impl Adrs
impl Adrs
Sourcepub fn as_bytes(&self) -> &[u8; 32]
pub fn as_bytes(&self) -> &[u8; 32]
Get a reference to the raw 32-byte address value.
This is passed directly to hash functions as part of their input.
Sourcepub fn get_layer_address(&self) -> u32
pub fn get_layer_address(&self) -> u32
Get the hypertree layer address (0 = bottom layer).
Sourcepub fn set_layer_address(&mut self, val: u32)
pub fn set_layer_address(&mut self, val: u32)
Set the hypertree layer address.
Layer 0 is the bottom of the hypertree (closest to the FORS trees);
layer d - 1 is the top.
Sourcepub fn set_tree_address(&mut self, val: u64)
pub fn set_tree_address(&mut self, val: u64)
Set the tree address from a u64 index.
The tree address occupies bytes 4..16 (words 1, 2, 3). The u64 value is stored
in the lower 8 bytes (words 2 and 3); the upper 4 bytes (word 1) are zeroed.
This identifies which XMSS tree within the current layer is being addressed.
Sourcepub fn get_tree_address(&self) -> u64
pub fn get_tree_address(&self) -> u64
Get the tree address as a u64 (lower 8 bytes of the 12-byte field).
Sourcepub fn set_type_and_clear(&mut self, addr_type: u32)
pub fn set_type_and_clear(&mut self, addr_type: u32)
Set the address type and zero all type-specific fields (bytes 20..32).
This must be called when switching address types to ensure leftover values
from a previous type do not leak into the new context. Use one of the
address type constants: WOTS_HASH, WOTS_PK, TREE, FORS_TREE,
FORS_ROOTS, WOTS_PRF, or FORS_PRF.
Sourcepub fn get_key_pair_address(&self) -> u32
pub fn get_key_pair_address(&self) -> u32
Get the key pair address (word 5, bytes 20..24).
Used by WOTS+ and FORS address types to identify which leaf key pair is being operated on within the current XMSS tree.
Sourcepub fn set_key_pair_address(&mut self, val: u32)
pub fn set_key_pair_address(&mut self, val: u32)
Set the key pair address (word 5, bytes 20..24).
Sourcepub fn get_chain_address(&self) -> u32
pub fn get_chain_address(&self) -> u32
Get the WOTS+ chain address (word 6, bytes 24..28).
Identifies which of the len hash chains within a WOTS+ instance is being computed.
Sourcepub fn set_chain_address(&mut self, val: u32)
pub fn set_chain_address(&mut self, val: u32)
Set the WOTS+ chain address (word 6, bytes 24..28).
Sourcepub fn get_hash_address(&self) -> u32
pub fn get_hash_address(&self) -> u32
Get the WOTS+ hash address (word 7, bytes 28..32).
Identifies the step within a WOTS+ hash chain (0 to w - 2).
Sourcepub fn set_hash_address(&mut self, val: u32)
pub fn set_hash_address(&mut self, val: u32)
Set the WOTS+ hash address (word 7, bytes 28..32).
Sourcepub fn get_tree_height(&self) -> u32
pub fn get_tree_height(&self) -> u32
Get the Merkle tree height (word 6, bytes 24..28).
Used by TREE and FORS_TREE address types. Height 0 corresponds to leaves; increasing heights move toward the root.
Sourcepub fn set_tree_height(&mut self, val: u32)
pub fn set_tree_height(&mut self, val: u32)
Set the Merkle tree height (word 6, bytes 24..28).
Sourcepub fn get_tree_index(&self) -> u32
pub fn get_tree_index(&self) -> u32
Get the Merkle tree node index (word 7, bytes 28..32).
Identifies the node’s horizontal position within its tree level.
Sourcepub fn set_tree_index(&mut self, val: u32)
pub fn set_tree_index(&mut self, val: u32)
Set the Merkle tree node index (word 7, bytes 28..32).