``````# @file for_authpath_01_32.py (2023-03-16T14:29Z)
# @author David Ireland <www.di-mgt.com.au/contact>
# @copyright 2023 DI Management Services Pty Ltd

"""Compute the authpaths from scratch for the FORS trees with i=1 and i=32."""

from spx_util import hash_root, authpath
from spx_sha256 import PRF, F

t = 64

leaves = []
skeys = []

# Compute FORS sk and pk values for tree (i = 1)
i = 1
for j in range(t):
treeindex = i * t + j
print(f"fors_sk[{i}][{j}]={sk}")
print(f"fors_pk[{i}][{j}]={pk}")
leaves.append(pk)
skeys.append(sk)

print("leaves=", leaves, sep='\n')

# Compute the root value and the authpath for index 57
idx = 57
print(f"fors_sk[{i}][{idx}]={skeys[idx]}")
assert(skeys[idx] == "229f6db83fc861d6fc5877405f5b9466")

root = hash_root(leaves, adrs, PKseed, i * t)
print(f"root[{i}]={root}")
assert(root == "4ff05f5821b513a402be41ef4e76f81f")
auth = authpath(leaves, adrs, PKseed, idx, i * t, showdebug=True)
print(f"fors_auth_path[{i}]:")
[print(a) for a in auth]
assert(auth[5] == '903938edcd9718d81330ed6645316ce7')

# REPEAT THE ABOVE FOR i=32
leaves = []
skeys = []

# Compute FORS sk and pk values for 33rd tree (i = 32)
i = 32
for j in range(t):
treeindex = i * t + j
print(f"fors_sk[{i}][{j}]={sk}")
print(f"fors_pk[{i}][{j}]={pk}")
leaves.append(pk)
skeys.append(sk)

print("leaves=", leaves, sep='\n')

# Compute the root value and the authpath for index 28
idx = 28
print(f"fors_sk[{i}][{idx}]={skeys[idx]}")
assert(skeys[idx] == "446d9fc66808fcc5e0d47c0c381c7f9e")