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

"""Compute all the 33 FORS signature secret keys."""

# Import our libraries to manage ADRS and SHA-256 hash functions
from spx_adrs import Adrs
from spx_sha256 import PRF

PKseed = 'B505D7CFAD1B497499323C8686325E47'
SKseed = '7C9935A0B07694AA0C6D10E4DB6B1ADD'
SPX_FORS_TREES = 33
t = 64

# Indices computed from H_msg
indices = [27, 57, 55, 45, 50, 57, 58, 51, 4, 28, 44, 18, 48, 55, 23, 39,
           28, 50,49, 7, 13, 42, 3, 36, 28, 43, 13, 0, 21, 43, 27, 44, 28]

# Set up ADRS object
adrs = Adrs(Adrs.FORS_TREE, layer=0)
adrs.setTreeAddress(0x28daecdc86eb8761)
adrs.setKeyPairAddress(6)

# Compute all 33 FORS signature sk values
for i in range(SPX_FORS_TREES):
    treeindex = i * t + indices[i]
    adrs.setTreeIndex(treeindex)
    print(f"ADRS={adrs.toHex()}")
    sk = PRF(SKseed, adrs.toHex())
    print(f"fors_sig_sk[{i}]={sk}")