Merkle Tree Signatures (MTS) are a method for signing a large but fixed number of messages. An MTS system depends on a onetime signature method and a collisionresistant hash function.
This specification makes use of the hashbased algorithm specified in [
HASHSIG], which is the Leighton and Micali adaptation [
LM] of the original LamportDiffieWinternitzMerkle onetime signature system [
M1979] [
M1987] [
M1989a] [
M1989b].
As implied by the name, the hashbased signature algorithm depends on a collisionresistant hash function. The hashbased signature algorithm specified in [
HASHSIG] uses only the SHA256 oneway hash function [
SHS], but it establishes an IANA registry [
IANALMS] to permit the registration of additional oneway hash functions in the future.
The MTS system specified in [
HASHSIG] uses a hierarchy of trees. The Ntime Hierarchical Signature System (HSS) allows subordinate trees to be generated when needed by the signer. Otherwise, generation of the entire tree might take weeks or longer.
An HSS signature as specified in [
HASHSIG] carries the number of signed public keys (Nspk), followed by that number of signed public keys, followed by the LMS signature as described in
Section 2.2. The public key for the topmost LMS tree is the public key of the HSS system. The LMS private key in the parent tree signs the LMS public key in the child tree, and the LMS private key in the bottommost tree signs the actual message. The signature over the public key and the signature over the actual message are LMS signatures as described in
Section 2.2.
The elements of the HSS signature value for a standalone tree (a top tree with no children) can be summarized as:
u32str(0) 
lms_signature /* signature of message */
where, u32str() and  are used as defined in [
HASHSIG].
The elements of the HSS signature value for a tree with Nspk signed public keys can be summarized as:
u32str(Nspk) 
signed_public_key[0] 
signed_public_key[1] 
...
signed_public_key[Nspk2] 
signed_public_key[Nspk1] 
lms_signature /* signature of message */
where, as defined in
Section 3.3 of [
HASHSIG], the signed_public_key structure contains the lms_signature over the public key, followed by the public key itself. Note that Nspk is the number of levels in the hierarchy of trees minus 1.
Each tree in the system specified in [
HASHSIG] uses the LeightonMicali Signature (LMS) system. LMS systems have two parameters. The first parameter is the height of the tree, h, which is the number of levels in the tree minus one. The [
HASHSIG] specification supports five values for this parameter: h=5, h=10, h=15, h=20, and h=25. Note that there are 2^h leaves in the tree. The second parameter, m, is the number of bytes output by the hash function, and it is the amount of data associated with each node in the tree. The [
HASHSIG] specification supports only the SHA256 hash function [
SHS], with m=32. As a result, the [
HASHSIG] specification supports five tree sizes; they are identified as:

LMS_SHA256_M32_H5

LMS_SHA256_M32_H10

LMS_SHA256_M32_H15

LMS_SHA256_M32_H20

LMS_SHA256_M32_H25
The [
HASHSIG] specification establishes an IANA registry [
IANALMS] to permit the registration of additional hash functions and additional tree sizes in the future.
As specified in [
HASHSIG], the LMS public key consists of four elements: the lms_algorithm_type from the list above, the otstype to identify the LeightonMicali OneTime Signature (LMOTS) type as discussed in
Section 2.3, the private key identifier (I) as described in
Section 5.3 of [
HASHSIG], and the mbyte string associated with the root node of the tree (T[1]).
The LMS public key can be summarized as:
u32str(lms_algorithm_type)  u32str(otstype)  I  T[1]
As specified in [
HASHSIG], an LMS signature consists of four elements: the number of the leaf (q) associated with the LMOTS signature value, an LMOTS signature value as described in
Section 2.3, a typecode indicating the particular LMS algorithm, and an array of values that is associated with the path through the tree from the leaf associated with the LMOTS signature value to the root. The array of values contains the siblings of the nodes on the path from the leaf to the root but does not contain the nodes on the path itself. The array for a tree with height h will have h values. The first value is the sibling of the leaf, the next value is the sibling of the parent of the leaf, and so on up the path to the root.
The four elements of the LMS signature value can be summarized as:
u32str(q) 
ots_signature 
u32str(type) 
path[0]  path[1]  ...  path[h1]
Merkle Tree Signatures (MTS) depend on a onetime signature method, and [
HASHSIG] specifies the use of the LMOTS, which has five parameters:

n:

The length in bytes of the hash function output. [HASHSIG] supports only SHA256 [SHS], with n=32.

H:

A preimageresistant hash function that accepts byte strings of any length and returns an nbyte string.

w:

The width in bits of the Winternitz coefficients. [HASHSIG] supports four values for this parameter: w=1, w=2, w=4, and w=8.

p:

The number of nbyte string elements that make up the LMOTS signature value.

ls:

The number of bits that are leftshifted in the final step ofthe checksum function, which is defined in Section 4.4 of [HASHSIG].
The values of p and ls are dependent on the choices of the parameters n and w, as described in
Appendix B of [
HASHSIG].
The [
HASHSIG] specification supports four LMOTS variants:

LMOTS_SHA256_N32_W1

LMOTS_SHA256_N32_W2

LMOTS_SHA256_N32_W4

LMOTS_SHA256_N32_W8
The [
HASHSIG] specification establishes an IANA registry [
IANALMS] to permit the registration of additional variants in the future.
Signing involves the generation of C, an nbyte random value.
The LMOTS signature value can be summarized as the identifier of the LMOTS variant, the random value, and a sequence of hash values (y[0] through y[p1]) that correspond to the elements of the public key, as described in
Section 4.5 of [
HASHSIG]:
u32str(otstype)  C  y[0]  ...  y[p1]