Skip to content

Commit

Permalink
Merge pull request #9 from isakruas/doc/expand-documentation
Browse files Browse the repository at this point in the history
doc/expand-documentation
  • Loading branch information
isakruas authored Apr 23, 2024
2 parents 14eaf76 + 1ecf871 commit 4a0414d
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 6 deletions.
65 changes: 63 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Elliptic Curve Utils (ecutils)
[![Documentation Status](https://readthedocs.org/projects/ecutils/badge/?version=latest)](https://ecutils.readthedocs.io/en/latest/?badge=latest)
[![Documentation Status](https://readthedocs.org/projects/ecutils/badge/?version=latest)](https://ecutils.readthedocs.io/en/stable/?badge=latest)
[![Latest Version](https://img.shields.io/pypi/v/ecutils.svg?style=flat)](https://pypi.python.org/pypi/ecutils/)
[![Downloads](https://static.pepy.tech/badge/ecutils)](https://pepy.tech/project/ecutils)
[![Downloads](https://static.pepy.tech/badge/ecutils/month)](https://pepy.tech/project/ecutils)
Expand Down Expand Up @@ -79,9 +79,70 @@ bob_shared_secret = bob.compute_shared_secret(alice.public_key)
# alice_shared_secret should be equal to bob_shared_secret
```

### MasseyOmura Key Exchange

```python
from ecutils.protocols import MasseyOmura
from ecutils.algorithms import Koblitz

# Initialize the Koblitz instance for the elliptic curve 'secp192k1'
koblitz = Koblitz(curve_name='secp192k1')

# Sender's side
# -------------
# Sender chooses their private key
private_key_sender = 123456789
# Initialize Massey-Omura protocol with the sender's private key
mo_sender = MasseyOmura(private_key_sender, curve_name='secp192k1')

# Encode the message using the Koblitz method
# `j` is used to handle the ambiguity in the decoding process
message, j = koblitz.encode("Hello, world!")

# Perform the first encryption step with Massey-Omura protocol
encrypted_msg_sender = mo_sender.first_encryption_step(message)

# The encoded message is now sent to the receiver...
# (transmission of encrypted_msg_sender)

# Receiver's side
# ---------------
# Receiver chooses their private key
private_key_receiver = 987654321
# Initialize Massey-Omura protocol with the receiver's private key
mo_receiver = MasseyOmura(private_key_receiver, curve_name='secp192k1')

# Perform the second encryption step with Massey-Omura protocol
encrypted_msg_receiver = mo_receiver.second_encryption_step(encrypted_msg_sender)

# The double-encrypted message is sent back to the sender...
# (transmission of encrypted_msg_receiver)

# Sender's side again
# -------------------
# Perform the partial decryption step with Massey-Omura protocol
partial_decrypted_msg = mo_sender.partial_decryption_step(encrypted_msg_receiver)

# The partially decrypted message is sent back to the receiver...
# (transmission of partial_decrypted_msg)

# Receiver's final decryption
# ---------------------------
# Finish decryption with Massey-Omura protocol to get the original message
original_message = mo_receiver.partial_decryption_step(partial_decrypted_msg)

# Decode the message using the Koblitz method
# `j` is used to resolve the mapping from the elliptic curve point back to the message
decoded_message = koblitz.decode(original_message, j)

# The decoded_message contains the original plaintext message
print(decoded_message)
```


## Documentation

For more in-depth use and examples, check out the [official documentation](https://ecutils.readthedocs.io/en/latest/).
For more in-depth use and examples, check out the [official documentation](https://ecutils.readthedocs.io/en/stable/).

## Support

Expand Down
2 changes: 1 addition & 1 deletion docs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ from ecutils.algorithms import DigitalSignature
# The rest of your code goes here
```

Need more guidance? Check out our [documentation](https://ecutils.readthedocs.io/en/latest/).
Need more guidance? Check out our [documentation](https://ecutils.readthedocs.io/en/stable/).

Keep in mind to stay updated; run this every now and then:

Expand Down
2 changes: 1 addition & 1 deletion mkdocs.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Project information
site_name: ECUtils
site_url: https://ecutils.readthedocs.io/en/latest/
site_url: https://ecutils.readthedocs.io/en/stable/
site_author: Isak Ruas
site_description: >-
A comprehensive Python library for elliptic curve operations, providing utilities
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ dependencies = []
dynamic = ["version"]

[project.urls]
Homepage = "https://ecutils.readthedocs.io/en/latest/"
Documentation = "https://ecutils.readthedocs.io/en/latest/"
Homepage = "https://ecutils.readthedocs.io/en/stable/"
Documentation = "https://ecutils.readthedocs.io/en/stable/"
Repository = "https://github.com/isakruas/ecutils.git"
"Bug Tracker" = "https://github.com/isakruas/ecutils/issues"
Changelog = "https://github.com/isakruas/ecutils/blob/master/CHANGELOG.md"
Expand Down

0 comments on commit 4a0414d

Please sign in to comment.