Leighton-Micali Hash-Based Signatures
Slowing down. Last release over 2 years ago, little activity since. Fine for existing code; think twice for a new project.
pip install hsslmspython-hsslms
This is an implementation of Leighton-Micali Hash-Based Signatures in Python according to RFC 8554 <https://www.rfc-editor.org/rfc/rfc8554.html>_. The one time signature keys are generated by using pseudo random generator, which saves a lot of memory to store the private keys in ram and on harddisk.
The implementation is meant as a reference and for educational purposes.
The implementation provides 4 classes:
- LM-OTS One-Time Signatures. These are one-time signatures; each private key MUST be used at most one time to sign a message.
- Leighton-Micali Signatures (LMS). This systemholds a fixed number of one-time signatures, i.e. LM-OTS.
- Hierarchical Signatures (HSS). This system uses a sequence of LMS.
- Persistent Hierarchical Signatures (PersHSS). The same as HSS except that the private key is stored in an encrypted file.
Installation
.. code:: bash
python3 -m pip install hsslms
Example Usage
LM-OTS ^^^^^^
.. code:: python
from os import urandom from hsslms import LM_OTS_Priv
generate a one-time private key
sk = LM_OTS_Priv(LMOTS_ALGORITHM_TYPE.LMOTS_SHA256_N32_W2, urandom(16), 0)
sign a message with the private key
signature = sk.sign(b'abc')
compute the related public key
vk = sk.gen_pub()
verify the signature, if invalid an exception will be raised
vk.verify(b'abc', signature)
LMS ^^^
.. code:: python
from os import urandom from hsslms import LMS_Priv
generate a private key
sk = LMS_Priv(LMS_ALGORITHM_TYPE.LMS_SHA256_M32_H10, LMOTS_ALGORITHM_TYPE.LMOTS_SHA256_N32_W8)
sign a message with the private key, in total 2^10 signatures are available
signature = sk.sign(b'abc')
compute the related public key
vk = sk.gen_pub()
verify the signature, if invalid an exception will be raised
vk.verify(b'abc', signature)
HSS ^^^
.. code:: python
from os import urandom from hsslms import HSS_Priv
generate a private key
sk = HSS_Priv([LMS_ALGORITHM_TYPE.LMS_SHA256_M32_H10]*2, LMOTS_ALGORITHM_TYPE.LMOTS_SHA256_N32_W1)
sign a message with the private key, in total 2^20 signatures are available
signature = sk.sign(b'abc')
compute the related public key
vk = sk.gen_pub()