Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lamport signature #524

Closed
wants to merge 10 commits into from
Closed

Lamport signature #524

wants to merge 10 commits into from

Conversation

James-E-A
Copy link
Contributor

Is support for Lamport signatures something you'd be interested in adding to the scope of this library?

It's a one-time signature scheme using a hash function as its primitive, and is a necessary cryptographic "building block" for recent linkable ring signature schemes, such as Lu, Au, and Zhang (2019).

>>> from Crypto.PublicKey import Lamport
>>> secret_key = Lamport.generate(512)
>>> public_key = secret_key.publickey()
>>> signature = secret_key.sign("This message has been one-time-signed!".encode())
>>> public_key.verify("This message has been one-time-signed!".encode(), signature)
True
>>> public_key.verify("This message has been one-time-singed!".encode(), signature)
False

@James-E-A
Copy link
Contributor Author

1fdfa3a adds the following behavior:

>>> from Crypto.PublicKey import Lamport
>>> secret_key = Lamport.generate(512)
>>> public_key = secret_key.publickey()
>>> signature = secret_key.sign("This message has been one-time-signed!".encode())
>>> signatoor = secret_key.sign("This message has been two-time-signed!".encode())
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/sweg/.local/lib/python3.8/site-packages/Crypto/PublicKey/Lamport.py", line 73, in sign
    return self._sign(self._h(message))
  File "/home/sweg/.local/lib/python3.8/site-packages/Crypto/PublicKey/Lamport.py", line 66, in _sign
    raise RuntimeError("This key has already been used!")
RuntimeError: This key has already been used!

James-E-A added 7 commits May 5, 2021 19:14
    from Crypto.PublicKey import Lamport
    from Crypto.Hash import MD5
    key = Lamport.generate(size=128, onewayfunc=lambda m: MD5.new(m).digest())
I'm not familiar with type-linted Python...
@James-E-A
Copy link
Contributor Author

Would PKCS8 import and export be a useful or appropriate feature for this? I've got it half coded so far.

@James-E-A
Copy link
Contributor Author

James-E-A commented May 19, 2021

Hmm, if added, this is a niche/research-focused item, so I suppose it'd belong in the experimental module

@James-E-A
Copy link
Contributor Author

Upon further consideration, this truly is too research-focused for inclusion in a general-purpose cryptography library

@James-E-A James-E-A closed this May 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant