Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
breezy-codes committed Jun 29, 2024
1 parent a3042c0 commit 8055878
Show file tree
Hide file tree
Showing 115 changed files with 19,891 additions and 1,433 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Welcome to my Cryptography Projects project! This is where I will be sharing all

My passion for cryptography started in my first semester of university in Discrete Mathematics, where I wrote a HD report on the RSA algorith, DHKE algorithm and ECC. This continued into my second semester in my Cryptography subject, where I wrote a HD report on Quantum Cryptography and the Shor's algorithm. Both of these reports were featured in the **[Deakin Maths Yearbook 2023](https://nla.gov.au/nla.obj-3336557334/view)**. I have since been exploring different cryptographic algorithms and concepts, and I'm excited to share my findings with you.

Access the handy maths symbol cheat sheet to help with covering these topics here: [Cheat Sheet](./maths/cheat-sheet.md)

## About This Project

Expand All @@ -23,7 +24,7 @@ Here are some of the topics I have covered or intend to cover in this project:

## How to Use This Project

You can browse the project, or download the GitHub repository and run the Jupyter notebooks on your local machine. Each notebook is self-contained and can be read independently, but I recommend starting with the introductory notebooks if you are new to cryptography. Feel free to explore the topics that interest you the most, and don't hesitate to reach out if you have any questions or feedback.
Each page on the website is it's own notebook file, you can explore each on the website or download and run the notebooks on your local machine. Feel free to explore the topics that interest you the most, and don't hesitate to reach out if you have any questions or feedback.

### To Download the github repository:

Expand Down
130 changes: 99 additions & 31 deletions RSA-Algorithm/RSA-example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -10,45 +10,110 @@
"\n",
"Let's break down the mathematics behind the RSA algorithm:\n",
"\n",
"1. **Key Generation**:\n",
" - Choose two distinct prime numbers $p$ and $q$.\n",
" - Compute $n$ as the product of $p$ and $q$:\n",
" \n",
"```{prf:algorithm} RSA Key Generation\n",
":label: alg-rsa-key-generation\n",
"\n",
"**Input:**\n",
"- Two distinct prime numbers $p$ and $q$.\n",
"\n",
"**Objective:** Generate the public and private keys for RSA encryption.\n",
"\n",
"**Procedure:**\n",
"1. **Choose Two Primes:**\n",
" - Select two distinct prime numbers $p$ and $q$.\n",
"\n",
"2. **Compute $n$:**\n",
" - Calculate the product of $p$ and $q$:\n",
"\n",
" $$\n",
" n = p \\times q\n",
" $$\n",
"\n",
" - Compute the totient function $\\phi(n)$:\n",
" \n",
"3. **Compute the Totient Function $\\phi(n)$:**\n",
" - Calculate the totient function:\n",
"\n",
" $$\n",
" \\phi(n) = (p-1) \\times (q-1)\n",
" $$\n",
"\n",
" - Choose an integer $e$ such that $1 < e < \\phi(n)$ and $e$ is coprime with $\\phi(n)$. Typically, $e = 65537$ is chosen.\n",
" - Compute the modular multiplicative inverse of $e$ modulo $\\phi(n)$ to get $d$:\n",
" \n",
"4. **Choose $e$:**\n",
" - Select an integer $e$ such that $1 < e < \\phi(n)$ and $e$ is coprime with $\\phi(n)$. Typically, $e = 65537$ is chosen.\n",
"\n",
"5. **Compute $d$:**\n",
" - Calculate the modular multiplicative inverse of $e$ modulo $\\phi(n)$ to get $d$:\n",
"\n",
" $$\n",
" d \\equiv e^{-1} \\mod \\phi(n)\n",
" $$\n",
"\n",
" - The public key is $(e, n)$ and the private key is $(d, n)$.\n",
"**Output:**\n",
"- Public key $(e, n)$\n",
"- Private key $(d, n)$\n",
"```\n",
"\n",
"```{admonition} Explanation\n",
":class: tip, dropdown\n",
"\n",
"2. **Encryption**:\n",
"In RSA key generation, two distinct prime numbers $p$ and $q$ are chosen to compute the modulus $n$. The totient function $\\phi(n)$ is then calculated. An integer $e$ is selected such that it is coprime with $\\phi(n)$, and the modular multiplicative inverse of $e$ is computed to obtain $d$. The public key is $(e, n)$, and the private key is $(d, n)$. \n",
"```\n",
"\n",
"```{prf:algorithm} RSA Encryption\n",
":label: alg-rsa-encryption\n",
"\n",
"**Input:**\n",
"- Plaintext message $M$.\n",
"- Public key $(e, n)$.\n",
"\n",
"**Objective:** Encrypt the plaintext message using the RSA algorithm.\n",
"\n",
"**Procedure:**\n",
"1. **Convert Plaintext to Integer:**\n",
" - Convert the plaintext message $M$ into an integer $m$ such that $0 \\leq m < n$.\n",
" - Compute the ciphertext $c$ using the public key $(e, n)$:\n",
" \n",
"\n",
"2. **Compute Ciphertext:**\n",
" - Calculate the ciphertext $c$ using the public key $(e, n)$:\n",
"\n",
" $$\n",
" c \\equiv m^e \\mod n\n",
" $$\n",
"\n",
"3. **Decryption**:\n",
" - Compute the plaintext integer $m$ from the ciphertext $c$ using the private key $(d, n)$:\n",
"**Output:**\n",
"- Ciphertext $c$\n",
"```\n",
"\n",
"```{admonition} Explanation\n",
":class: tip, dropdown\n",
"To encrypt a plaintext message using RSA, the message is first converted into an integer $m$ within the range $0 \\leq m < n$. The ciphertext $c$ is then computed using the public key $(e, n)$ by raising $m$ to the power of $e$ and taking the result modulo $n$.\n",
"```\n",
"\n",
"```{prf:algorithm} RSA Decryption\n",
":label: alg-rsa-decryption\n",
"\n",
"**Input:**\n",
"- Ciphertext $c$.\n",
"- Private key $(d, n)$.\n",
"\n",
"**Objective:** Decrypt the ciphertext using the RSA algorithm.\n",
"\n",
"**Procedure:**\n",
"1. **Compute Plaintext Integer:**\n",
" - Calculate the plaintext integer $m$ from the ciphertext $c$ using the private key $(d, n)$:\n",
" \n",
" $$\n",
" m \\equiv c^d \\mod n\n",
" $$\n",
" \n",
" - Convert the integer $m$ back to the original plaintext message $M$."
"\n",
"2. **Convert Integer to Plaintext:**\n",
" - Convert the integer $m$ back to the original plaintext message $M$.\n",
"\n",
"**Output:**\n",
"- Plaintext message $M$\n",
"```\n",
"\n",
"```{admonition} Explanation\n",
":class: tip, dropdown\n",
"To decrypt a ciphertext using RSA, the ciphertext $c$ is raised to the power of $d$ and taken modulo $n$ using the private key $(d, n)$. The resulting integer $m$ is then converted back to the original plaintext message $M$.\n",
"```"
]
},
{
Expand All @@ -74,7 +139,11 @@
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"metadata": {
"tags": [
"hide-input"
]
},
"outputs": [],
"source": [
"import numpy as np\n",
Expand Down Expand Up @@ -199,8 +268,6 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"```{admonition} Euler's Totient Function\n",
":class: tip\n",
"Euler's totient function, $\\phi(n)$, is crucial for generating the RSA keys. It is calculated using the formula:\n",
"\n",
"$$\n",
Expand All @@ -209,7 +276,8 @@
"\n",
"where $p$ and $q$ are prime numbers.\n",
"\n",
"#### Example:\n",
"```{admonition} Example\n",
":class: tip, dropdown\n",
"\n",
"Given:\n",
"\n",
Expand All @@ -229,6 +297,7 @@
"$$\n",
"\\phi(n) = (97 - 1) \\times (101 - 1) = 96 \\times 100 = 9600\n",
"$$\n",
"\n",
"```"
]
},
Expand Down Expand Up @@ -268,16 +337,14 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"```{admonition} Private Key Calculation\n",
":class: tip\n",
"\n",
"The private key $d$ is the modular multiplicative inverse of $e$ modulo $\\phi(n)$. This means we need to find $d$ such that:\n",
"\n",
"$$\n",
"d \\equiv e^{-1} \\mod \\phi(n)\n",
"$$\n",
"\n",
"Given:\n",
"```{admonition} Example\n",
":class: tip, dropdown\n",
"\n",
"$$\n",
"e = 17\n",
Expand All @@ -294,6 +361,7 @@
"$$\n",
"d = 5657\n",
"$$\n",
"\n",
"```"
]
},
Expand Down Expand Up @@ -336,15 +404,15 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"```{admonition} Encryption\n",
":class: tip\n",
"\n",
"To encrypt a message $M$, convert it to an integer $m$ such that $0 \\leq m < n$. Then, use the public key $(e, n)$ to compute the ciphertext $c$:\n",
"\n",
"$$\n",
"c \\equiv m^e \\mod n\n",
"$$\n",
"\n",
"```{admonition} Example\n",
":class: tip, dropdown\n",
"\n",
"Suppose the plaintext message $M$ is represented as the integer $m = 1234$.\n",
"\n",
"Given the public key:\n",
Expand Down Expand Up @@ -401,15 +469,15 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"```{admonition} Decryption\n",
":class: tip\n",
"\n",
"To decrypt the ciphertext $c$, use the private key $(d, n)$ to compute the plaintext integer $m$:\n",
"\n",
"$$\n",
"m \\equiv c^d \\mod n\n",
"$$\n",
"\n",
"```{admonition} Example\n",
":class: tip, dropdown\n",
"\n",
"Given the private key:\n",
"\n",
"$$\n",
Expand Down
21 changes: 4 additions & 17 deletions RSA-Algorithm/RSA-with-large-num.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@
"ExecuteTime": {
"end_time": "2024-06-15T06:21:18.822173Z",
"start_time": "2024-06-15T06:21:18.381489Z"
}
},
"tags": [
"hide-input"
]
},
"outputs": [],
"source": [
Expand Down Expand Up @@ -198,14 +201,6 @@
"print_rsa_values(p, q, n, e, totient_n, message, ciphertext, decrypted_message)"
]
},
{
"cell_type": "markdown",
"id": "06e5bb36",
"metadata": {},
"source": [
"---"
]
},
{
"cell_type": "markdown",
"id": "b004f97f",
Expand Down Expand Up @@ -342,14 +337,6 @@
"print_rsa_values(p, q, n, e, totient_n, message, ciphertext, decrypted_message)"
]
},
{
"cell_type": "markdown",
"id": "6b66190a",
"metadata": {},
"source": [
"---"
]
},
{
"cell_type": "markdown",
"id": "893a0048",
Expand Down
Binary file modified _build/.doctrees/README.doctree
Binary file not shown.
Binary file modified _build/.doctrees/RSA-Algorithm/RSA-example.doctree
Binary file not shown.
Binary file modified _build/.doctrees/RSA-Algorithm/RSA-with-large-num.doctree
Binary file not shown.
Binary file modified _build/.doctrees/ciphers/ceaser-cipher.doctree
Binary file not shown.
Binary file modified _build/.doctrees/ciphers/hill-cipher.doctree
Binary file not shown.
Binary file modified _build/.doctrees/environment.pickle
Binary file not shown.
Binary file added _build/.doctrees/maths/cheat-sheet.doctree
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified _build/.doctrees/maths/number-theory/finding-coprimes.doctree
Binary file not shown.
Binary file modified _build/.doctrees/maths/number-theory/gcd-lcm.doctree
Binary file not shown.
Binary file modified _build/.doctrees/maths/number-theory/prime-factorisation.doctree
Binary file not shown.
Binary file not shown.
Binary file modified _build/.doctrees/maths/number-theory/prime-num-intro.doctree
Binary file not shown.
Binary file modified _build/.doctrees/maths/number-theory/prime-numbers.doctree
Binary file not shown.
2 changes: 1 addition & 1 deletion _build/html/.buildinfo
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Sphinx build info version 1
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
config: 0b3da256136c2dc85fa7923d4c0d1363
config: 75d0d2ae59b9531001e9a758d81deffc
tags: 645f666f9bcd5a90fca523b33c5a78b7
44 changes: 39 additions & 5 deletions _build/html/README.html
Original file line number Diff line number Diff line change
Expand Up @@ -187,12 +187,13 @@
<p aria-level="2" class="caption" role="heading"><span class="caption-text">Number Theory</span></p>
<ul class="nav bd-sidenav">
<li class="toctree-l1 has-children"><a class="reference internal" href="maths/number-theory/prime-num-intro.html">Prime Numbers</a><details><summary><span class="toctree-toggle" role="presentation"><i class="fa-solid fa-chevron-down"></i></span></summary><ul>
<li class="toctree-l2"><a class="reference internal" href="maths/cheat-sheet.html">Symbol Cheat Sheet</a></li>
<li class="toctree-l2"><a class="reference internal" href="maths/number-theory/prime-numbers.html"><strong>Prime Numbers</strong></a></li>
<li class="toctree-l2"><a class="reference internal" href="maths/number-theory/fermats-little-theorem.html"><strong>Fermat’s Little Theorem</strong></a></li>
<li class="toctree-l2"><a class="reference internal" href="maths/number-theory/finding-coprimes.html"><strong>Finding Coprimes</strong></a></li>
<li class="toctree-l2"><a class="reference internal" href="maths/number-theory/prime-factorisation.html"><strong>Prime Factorisation</strong></a></li>
<li class="toctree-l2"><a class="reference internal" href="maths/number-theory/gcd-lcm.html"><strong>GCD and LCM</strong></a></li>
<li class="toctree-l2"><a class="reference internal" href="maths/number-theory/prim-introduction.html"><strong>Prime Numbers Complete</strong></a></li>
<li class="toctree-l2"><a class="reference internal" href="maths/number-theory/prime-introduction.html"><strong>Prime Numbers Complete</strong></a></li>

</ul>
</details></li>
Expand Down Expand Up @@ -263,18 +264,50 @@
<div class="article-header-buttons">


<a href="https://github.com/breezy-codes/cryptography-guide" target="_blank"
class="btn btn-sm btn-source-repository-button"



<div class="dropdown dropdown-source-buttons">
<button class="btn dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false" aria-label="Source repositories">
<i class="fab fa-github"></i>
</button>
<ul class="dropdown-menu">



<li><a href="https://github.com/breezy-codes/cryptography-guide" target="_blank"
class="btn btn-sm btn-source-repository-button dropdown-item"
title="Source repository"
data-bs-placement="bottom" data-bs-toggle="tooltip"
data-bs-placement="left" data-bs-toggle="tooltip"
>


<span class="btn__icon-container">
<i class="fab fa-github"></i>
</span>
<span class="btn__text-container">Repository</span>
</a>
</li>




<li><a href="https://github.com/breezy-codes/cryptography-guide/issues/new?title=Issue%20on%20page%20%2FREADME.html&body=Your%20issue%20content%20here." target="_blank"
class="btn btn-sm btn-source-issues-button dropdown-item"
title="Open an issue"
data-bs-placement="left" data-bs-toggle="tooltip"
>


<span class="btn__icon-container">
<i class="fas fa-lightbulb"></i>
</span>
<span class="btn__text-container">Open issue</span>
</a>
</li>

</ul>
</div>



Expand Down Expand Up @@ -407,6 +440,7 @@ <h2> Contents </h2>
<h1>Welcome to the World of Cryptography!<a class="headerlink" href="#welcome-to-the-world-of-cryptography" title="Link to this heading">#</a></h1>
<p>Welcome to my Cryptography Projects project! This is where I will be sharing all the cool stuff I’ve been working on in the world of cryptography. It’s an ongoing project that I will keep updating as I learn more and find the time to dive deeper. There’s no strict timeline here—it’s built around my learning journey and time availability as a full-time student.</p>
<p>My passion for cryptography started in my first semester of university in Discrete Mathematics, where I wrote a HD report on the RSA algorith, DHKE algorithm and ECC. This continued into my second semester in my Cryptography subject, where I wrote a HD report on Quantum Cryptography and the Shor’s algorithm. Both of these reports were featured in the <strong><a class="reference external" href="https://nla.gov.au/nla.obj-3336557334/view">Deakin Maths Yearbook 2023</a></strong>. I have since been exploring different cryptographic algorithms and concepts, and I’m excited to share my findings with you.</p>
<p>Access the handy maths symbol cheat sheet to help with covering these topics here: <a class="reference internal" href="maths/cheat-sheet.html"><span class="std std-doc">Cheat Sheet</span></a></p>
<section id="about-this-project">
<h2>About This Project<a class="headerlink" href="#about-this-project" title="Link to this heading">#</a></h2>
<p>This project is a collection of my work in cryptography, presented in the form of Jupyter notebooks. Each notebook explores different aspects of cryptography, from theoretical mathematical foundations to practical implementations in Python. You’ll find detailed explanations of the mathematics behind cryptographic algorithms, along with code snippets to illustrate how these concepts are applied.</p>
Expand All @@ -426,7 +460,7 @@ <h2>What you will find here<a class="headerlink" href="#what-you-will-find-here"
</section>
<section id="how-to-use-this-project">
<h2>How to Use This Project<a class="headerlink" href="#how-to-use-this-project" title="Link to this heading">#</a></h2>
<p>You can browse the project, or download the GitHub repository and run the Jupyter notebooks on your local machine. Each notebook is self-contained and can be read independently, but I recommend starting with the introductory notebooks if you are new to cryptography. Feel free to explore the topics that interest you the most, and don’t hesitate to reach out if you have any questions or feedback.</p>
<p>Each page on the website is it’s own notebook file, you can explore each on the website or download and run the notebooks on your local machine. Feel free to explore the topics that interest you the most, and don’t hesitate to reach out if you have any questions or feedback.</p>
<section id="to-download-the-github-repository">
<h3>To Download the github repository:<a class="headerlink" href="#to-download-the-github-repository" title="Link to this heading">#</a></h3>
<ol class="arabic simple">
Expand Down
Loading

0 comments on commit 8055878

Please sign in to comment.