Giter Club home page Giter Club logo

cryptography's Introduction

cryptography

a mathmatical implementation of rsa encryption

the basic theory behind rsa encryption, one of the oldest and most widely used encryption schemes. first we'll look at a technique to 'scramble' and 'unscramble' some integers and then notice that because numbers can encode whatever data you like, this scrambling and uncrambling can be used to encrypt data. the 'scrambling' will be easy and anyone with a public key can do it. the unscrambling requires knowledge of how to factor a particular number.

scramble stage (usually called the encrption stage):

take two primes $p$ and $q$ (in practice, these are very large primes). set $n = pq$ and pick some $e$ that is relatively prime to $(p - 1)(q - 1)$. the pair $(n, e)$ is the encryption key. you can give this to anyone and they can encrypt data as follows:

take any integer $0 \leq m < n$. the encryption value of $m$ is

$$m^{e} \bmod n$$

  1. encrypt the following numbers with the key $(43 \cdot 59, 13)$ using the modular exponentation technique from last week (note: we're using small primes for examples here.

$$1819$$

$$1415$$

unscramble stage (usually called the decryption stage)

so, anyone can encrypt. to decrypt though, it seems like we need special knowledge of what the primes $p$ and $q$ are so that we can find an inverse of $e \bmod (p - 1)(q - 1)$. let's suppose that we know an inverse of $e$, call it $d$. we will prove here that $(m^{e})^{d} \equiv m \bmod n$, that is exponentiation by $d$ unscrambles exponentiation by $e$.

we know that $ed \equiv 1 \bmod (p - 1)(q - 1)$, this means that $ed = 1 + k(p - 1)(q - 1)$ for some integer $k$

  1. use the above point to prove that

$$(m^{e})^{d} \equiv m \b{mod} n$$

by analyzing three cases by applying fermat's little theorem along with the chinese remainder theorem:

  • assume that $m$ is not divisible by $p$ or $q$
  • assume that $m$ is equal to $0$
  • assume that $m$ is divisible by exactly one of $p$ or $q$, but not both

why are these case adequate?

  1. find an inverse of $13 \text{ modulo } (42)(58)$ and check that decryption works for the two numbers you encrypted earlier

  2. decrypt,

$$0981$$

$$0461$$

1. encoding data

there are many ways to encode data as a sequence of integers. a simple way to encode text as a string of integers is to find the greatest number of consecutive $25$'s that are less than the product of our two primes. in our concrete example, we can only fit two consecutive $25$'s, which means that we can only encrypt two letters at a time.

  1. encode the word MATH as two integers between $0$ and $43 \cdot 59$. encrypt your message using the RSA scheme.

  2. what words have we been encoding from our earlier examples?

encryption stage

  1. take 2 primes $p$ & $q$

  2. set $n = qp$

  3. pick some $e \bot (p - 1)(q - 1)$

  4. the pair (n, e) is the encryption key you can give this to anyone and they can encrypt data as follows:

1.1 take any integer $0 \leq m < n$ the encyrption value on $m$ is $m^{e} \bmod n$

1.2. encrypt the following numbers with the key $(43 \cdot 59, 13)$ using modular exponentation technique from last week

$$1819$$

$$1415$$

rsa encryption

$$m \coloneqq message \overset{(n, e) \ \coloneqq \ key}\implies c \coloneqq encryption \ \ stage$$

$$n : n = p' \cdot q', \text{ such that } p' \cdot q' \text{ are prime }$$

cryptography's People

Contributors

morganbergen avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.