# @file wots_layers.py
# @version 1.1.0 (2026-01-26T11:23Z)
# @author David Ireland <https://di-mgt.com.au/contact>
# @copyright 2023-26 DI Management Services Pty Ltd
# @license Apache-2.0
"""Compute the WOTS tree address for each layer."""
from slh_adrs import Adrs
PKseed = 'FA495FB834DEFEA7CC96A81309479135'
w = 16
d = 22
# Starting tree address at layer 0
tree_addr = 0x7cdcef4b8fdb03b0
tree_idx = 0
print(" layer treeaddr type idxleaf ")
print(" [1] [8] [1] [4]")
for layer in range(d):
adrs = Adrs(Adrs.WOTS_HASH, layer=layer)
adrs.setTreeAddress(tree_addr)
adrs.setKeyPairAddress(tree_idx)
print(f"layer={layer:2d},ADRS={adrs.toHexSP()}")
# Compute next tree address
tree_idx = tree_addr & 0x7
tree_addr >>= 3