Below you will find pages that utilize the taxonomy term “Number Theory”

# Prepare To Implement The RSA Algorithm

# Prerequisites

- Familiarity with binary arithmetic. Know what are MSB and LSB.
- Bitwise operations. Logical shift.
- Primality Testing

# Introduction

Continuing with the series of posts on number theory and cryptograpy, let us take a look at the RSA algorithm.

Before writing the RSA program, let’s prepare some useful functions.

## GCD

Here’s a simple recurisve function to computed the GCD of two integers.

```
def gcd(a, b):
while b != 0:
a, b = b, a % b
return a
```

read more

# The RSA Algorithm

# Introduction

Continuing with the series of posts on number theory and cryptograpy, let us take a look at the RSA algorithm.

RSA is an algorithm to perform encryption and decryption of data.

## The Basic Idea

RSA uses two keys to encrypt and decrypt messages:

**Public Key**: Anyone can see this key. It’s used to encrypt the message.**Private Key**: Only you should know this key. It’s used to decrypt the message.

When someone wants to send you a secret message, they use your public key to encrypt the message. Once it’s encrypted, only your private key can decrypt it.

# Eulers Totient Function

# Introduction

Continuing with the series of posts on number theory and cryptograpy, let us take a look at the Euler’s Totient Function.

Euler’s Totient Function, denoted as ϕ(n), is a function that counts the number of positive integers less than or equal to n that are relatively prime to n. Two numbers are relatively prime (or coprime) if their greatest common divisor (GCD) is 1.

# Prerequisites

- Familarity with the Inclusion-Exclusion principle
- Familarity with the modular arithmetic

### Definition

For any positive integer n, the Euler’s Totient Function ϕ(n) is defined as:

# Chinese Remainder Theorem

# Introduction

Continuing with the series of posts on number theory and cryptograpy, let us take a look at the Chinese Remainder Theorem.

### Prereseqisites

- Modular arithmetic, especially modular inverses
- The Extended Euclidean Algorithm

# The Chinese Remainder Theorem

The Chinese Remainder Theorem (CRT) provides a solution to a system of simultaneous congruences with different moduli. Here’s a step-by-step explanation:

## Problem Setup

Suppose you have a system of congruences like this:

# Extended Euclidean Algorithm

## Introduction

In this series of articles about number theory and cryptography, we have discussed

- The Euclidean algorithm to compute the GCD for two integers
`a`

and`b`

- The Bezout’s Identity: ax + bc = GCD(a,b)

This article will introduce the reader to the Extended Euclidean algorithm to compute the coefficients of the Bezout’s Identity.

Bézout’s identity states that for any two integers `a`

and `b`

, their greatest common divisor (GCD) can be expressed as:

# Bezouts Identity

## Introduction

In this series of articles on number theory, today we talk about the Bézout’s Identity.

Let `a`

and `b`

be integers with greatest common divisor `d`

. Then there exist integers `x`

and `y`

such that `ax + by = d`

. The integers of the form `az + bt`

are exactly the multiples of `d`

.

The integers `x`

and `y`

are called Bézout coefficients for `(a, b)`

; they are not unique

# Euclidean Algorithm To Compute GCD

This is a long-form post about the Euclidean algorithm to compute the greatest common divisors of two integers. The article starts from the fundamentals and explains why it works better than the naive algorithm. The author also explains the computational complexity and the mathematics of the algorithm.

### Prereseqisites

- Fundamental arithmetic and an understanding of the greatest common divisor(GCD).
- Introductory concepts in algebra and logarithms, including mathematical induction.
- Overview of modular arithmetic.
- Familiarity with the Fibonacci series. An excellent video tutorial of the Fibonacci series on Youtube.
- An introduction to the big O notation.
- Basics Python programming skills.
- Curiosity.
- Patience to read long articles. It is okay to read it in more than one sitting. Taking notes will be benefitial for the learner. Re-reading the article a few times is encouraged.

# Introduction

### What Is GCD?

GCD, the greatest common divisor is the largest number that divides the given two integers.