Skip to main content

Adrs

Struct Adrs 

Source
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

Source

pub fn new() -> Self

Create a new address with all fields initialized to zero.

Source

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.

Source

pub fn get_layer_address(&self) -> u32

Get the hypertree layer address (0 = bottom layer).

Source

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.

Source

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.

Source

pub fn get_tree_address(&self) -> u64

Get the tree address as a u64 (lower 8 bytes of the 12-byte field).

Source

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.

Source

pub fn get_type(&self) -> u32

Get the current address type.

Source

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.

Source

pub fn set_key_pair_address(&mut self, val: u32)

Set the key pair address (word 5, bytes 20..24).

Source

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.

Source

pub fn set_chain_address(&mut self, val: u32)

Set the WOTS+ chain address (word 6, bytes 24..28).

Source

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).

Source

pub fn set_hash_address(&mut self, val: u32)

Set the WOTS+ hash address (word 7, bytes 28..32).

Source

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.

Source

pub fn set_tree_height(&mut self, val: u32)

Set the Merkle tree height (word 6, bytes 24..28).

Source

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.

Source

pub fn set_tree_index(&mut self, val: u32)

Set the Merkle tree node index (word 7, bytes 28..32).

Trait Implementations§

Source§

impl Clone for Adrs

Source§

fn clone(&self) -> Adrs

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Adrs

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Adrs

§

impl RefUnwindSafe for Adrs

§

impl Send for Adrs

§

impl Sync for Adrs

§

impl Unpin for Adrs

§

impl UnsafeUnpin for Adrs

§

impl UnwindSafe for Adrs

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.