From 1ecf8712f743b761031c1fd5235b60130981c293 Mon Sep 17 00:00:00 2001 From: Isak Ruas Date: Tue, 23 Apr 2024 17:52:19 -0300 Subject: [PATCH] doc/expand-documentation --- README.md | 65 ++++++++++++++++++++++++++++++++++++++++++-- docs/installation.md | 2 +- mkdocs.yml | 2 +- pyproject.toml | 4 +-- 4 files changed, 67 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 482a46b..00c97cb 100755 --- a/README.md +++ b/README.md @@ -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) @@ -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 diff --git a/docs/installation.md b/docs/installation.md index 9328b81..e8b05b7 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -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: diff --git a/mkdocs.yml b/mkdocs.yml index 3aa9832..01a3722 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -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 diff --git a/pyproject.toml b/pyproject.toml index 32751e8..76790e2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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"