The Merkle signature scheme can be used to sign a limited number of messages with one public key. The number of possible messages must be a power of two, so we denote the possible number of messages as. The first step of generating the public key is to generate private/public key pairs of some one-time signature scheme. For each, a hash value of the public key is computed. With these hash values a hash tree is built, by placing these hash values as leaves and recursively hashing to form a binary tree. Let denote the node in the tree with height and left-right position. Then, the hash values are the leaves. The value for each inner node of the tree is the hash of the concatenation of its two children. For example, and. In this way, a tree with leaves and nodes is built. The private key of the Merkle signature scheme is the entire set of pairs. One of the major problems with the scheme is that the size of the private key scales linearly with the number of messages to be sent. The public key is the root of the tree,. The individual public keys can be made public without breaking security. However, as they are not needed in the public key, it is more practical to keep them secret to minimize its size.
Signature generation
To sign a message with the Merkle signature scheme, the signer picks a key pair, signs using the one-time signature scheme, and then adds additional information to prove that it was indeed one of the original key pairs. First, the signer chooses a pair which had not previously been used to sign any other message, and uses the one-time signature scheme to sign the message, resulting in a signature and corresponding public key. To prove to the message verifier that was in fact one of the original key pairs, the signer simply includes intermediate nodes of the Merkle tree so that the verifier can verify was used to compute the public key at the root of the tree. The path in the hash tree from to the root be nodes, call them, with being a leaf and being the root. We know that is a child of. To let the verifier calculate the next node given the previous, they need to know the other child of, the sibling node of. We call this node, so that. Hence, nodes are needed, to reconstruct from. An example of an authentication path is illustrated in the figure on the right. These nodes, the, and the one-time signature, together constitute a signature of using the Merkle signature scheme:. Note that when using Lamport signature scheme for signing, the contains a part of the private key.
Signature verification
The receiver knows the public key, the message, and the signature. First, the receiver verifies the one-time signature of the message using the one-time signature public key. If is a valid signature of, the receiver computes by hashing the public key of the one-time signature. For, the nodes of of the path are computed with. If equals the public key of the Merkle signature scheme, the signature is valid.