100% found this document useful (1 vote)
304 views21 pages

Cryprotgraphy and Nertwork Security

Cryptography involves techniques for ensuring secrecy and authenticity of information. There are four main areas: symmetric encryption to conceal data blocks or streams, asymmetric encryption for small blocks like keys, data integrity algorithms to protect data from alteration, and authentication protocols to authenticate identities. Computer security aims to preserve integrity, availability, and confidentiality of systems. There are passive attacks like eavesdropping and traffic analysis, and active attacks like masquerading, replaying messages, and denial of service. Security services include authentication to verify identities, access control to limit system access, data confidentiality to protect transmitted data, data integrity to protect data from modification, non-repudiation to prevent denial of messages, and availability to ensure authorized access.

Uploaded by

Radhika Sridhar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
304 views21 pages

Cryprotgraphy and Nertwork Security

Cryptography involves techniques for ensuring secrecy and authenticity of information. There are four main areas: symmetric encryption to conceal data blocks or streams, asymmetric encryption for small blocks like keys, data integrity algorithms to protect data from alteration, and authentication protocols to authenticate identities. Computer security aims to preserve integrity, availability, and confidentiality of systems. There are passive attacks like eavesdropping and traffic analysis, and active attacks like masquerading, replaying messages, and denial of service. Security services include authentication to verify identities, access control to limit system access, data confidentiality to protect transmitted data, data integrity to protect data from modification, non-repudiation to prevent denial of messages, and availability to ensure authorized access.

Uploaded by

Radhika Sridhar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 21

INTRODUCTION TO CRYPTOGRAPHY :

Cryptology: This is the study of techniques for ensuring the secrecy and/or authenticity of
information. The two main branches of cryptology are cryptography, which is the study of the design
of such techniques; and cryptanalysis, which deals with the defeating such techniques, to recover
information, or forging information that will be accepted as authentic.
Cryptographic algorithms and protocols can be grouped into four main areas:
Symmetric encryption: Used to conceal the contents of blocks or streams of data of any size,
including messages, files, encryption keys, and passwords.
Asymmetric encryption: Used to conceal small blocks of data, such as encryption keys and hash
function values, which are used in digital signatures.
Data integrity algorithms: Used to protect blocks of data, such as messages,from alteration.
Authentication protocols: These are schemes based on the use of cryptographic algorithms
designed to authenticate the identity of entities.
The field of network and Internet security consists of measures to deter, prevent,detect, and
correct security violations that involve the transmission of information.
Computer Security
The protection afforded to an automated information system in order to attain the applicable objectives
of preserving the integrity, availability, and confidentiality of information system resources (includes
hardware, software, firmware, information /data, and telecommunications).
This definition introduces three key objectives that are at the heart of computer security:
Confidentiality: This term covers two related concepts:
Data confidentiality: Assures that private or confidential information is not made available or
disclosed to unauthorized individuals.
Privacy: Assures that individuals control or influence what information related to them may be
collected and stored and by whom and to whom that information may be disclosed.
Integrity: This term covers two related concepts:
Data integrity: Assures that information and programs are changed only in a specified and
authorized manner.
System integrity: Assures that a system performs its intended function in an unimpaired
manner, free from deliberate or inadvertent unauthorized manipulation of the system.
Availability: Assures that systems work promptly and service is not denied to authorized users.
Threat:
A potential for violation of security, which exists when there is a circumstance, capability, action, or
event that could breach security and cause harm.That is, a threat is a possible danger that might exploit a
vulnerability.
Attack
An assault on system security that derives from an intelligent threat; that is, an intelligent act that is a
deliberate attempt (especially in the sense of a method or technique) to evade security services and
violate the security policy of a system.

ATTACKS AND SERVICES :
The OSI security architecture focuses on security attacks, mechanisms, and services. These can be
defined briefly as
Security attack: Any action that compromises the security of information owned by an organization.
Security mechanism: A process (or a device incorporating such a process) that is designed to detect,
prevent, or recover from a security attack.
Security service: A processing or communication service that enhances the security of the data
processing systems and the information transfers of an organization. The services are intended to
counter security attacks, and they make use of one or more security mechanisms to provide the service.
SECURITY ATTACKS
Passive Attacks
Passive attacks are in the nature of eavesdropping on, or monitoring of, transmissions. The goal
of the opponent is to obtain information that is being transmitted. Two types of passive attacks are
The release of message contents: A telephone conversation, an electronic mail message,
and a transferred file may contain sensitive or confidential information. We would like to prevent an
opponent from learning the contents of these transmissions.
Traffic analysis: Suppose that we had a way of masking the contents of messages or
other information traffic so that opponents, even if they captured the message, could not extract the
information from the message. The common technique for masking contents is encryption. If we had
encryption protection in place, an
opponent might still be able to observe the pattern of these messages. The opponent could determine the
location and identity of communicating hosts and could observe the frequency and length of messages
being exchanged. This information might be useful in guessing the nature of the communication that
was taking place.
Active Attacks
Active attacks involve some modification of the data stream or the creation of a false stream and
can be subdivided into four categories:
Masquerade: takes place when one entity pretends to be a different entity. A masquerade
attack usually includes one of the other forms of active attack.
Replay involves the passive capture of a data unit and its subsequent retransmissionto
produce an unauthorized effect.
Modification of messages simply means that some portion of a legitimate message is
altered, or that messages are delayed or reordered, to produce an unauthorized effect.
The denial of service prevents or inhibits the normal use or management of
communications facilities
SECURITY SERVICES:
Authentication:
The authentication service is concerned with assuring that a communication is authentic. In the
case of a single message, such as a warning or alarm signal, the function of the authentication service is
to assure the recipient that the message is from the source that it claims to be from. In the case of an
ongoing interaction, such as the connection of a terminal to a host, two aspects are involved. First, at the
time of connection initiation, the service assures that the two entities are authentic, that is, that each is
the entity that it claims to be. Second, the service must assure that the connection is not interfered with
in such a way that a third party can masquerade as
one of the two legitimate parties for the purposes of unauthorized transmission or reception.
Two specific authentication services are defined:
Peer entity authentication: Provides for the corroboration of the identity of a peer entity in an
association.
Data origin authentication: Provides for the corroboration of the source of a data unit.
Access Control:
In the context of network security, access control is the ability to limit and control the access to
host systems and applications via communications links. To achieve this, each entity trying to gain
access must first be identified, or authenticated, so that access rights can be tailored to the individual.
Data Confidentiality:
Confidentiality is the protection of transmitted data from passive attacks. With respect to the
content of a data transmission, several levels of protection can be identified. The broadest service
protects all user data transmitted between two users over a period of time.
Data Integrity:
As with confidentiality, integrity can apply to a stream of messages, a single message, or selected
fields within a message. Again, the most useful and straightforward approach is total stream protection.
A connection-oriented integrity service, one that deals with a stream of messages, assures that messages
are received as sent with no duplication, insertion, modification, reordering, or replays. a connectionless
integrity service, one that deals with individual messages without regard to any larger context, generally
provides protection against message modification only.
Non- repudiation:
Non-repudiation prevents either sender or receiver from denying a transmitted message. Thus,
when a message is sent, the receiver can prove that the alleged sender in fact sent the message.
Similarly, when a message is received, the sender can prove that the alleged receiver in fact received the
message.
Availability Service:
The property of a system or a system resource being accessible and usable upon demand by an
authorized system entity, according to performance specifications for the system (i.e., a system is
available if it provides services according to the system design whenever users request them). A variety
of attacks can result in the loss of or reduction in availability.






CLASSICAL ENCRYPTION TECHNIQUES:

Symmetric encryption is a form of cryptosystem in which encryption and decryption are performed
using the same key. It is also known as conventional encryption. Symmetric encryption transforms
plaintext into ciphertext using a secret key and an encryption algorithm. Using the same key and a
decryption algorithm, the plaintext is recovered from the ciphertext.

The types of ciphers:
Substitution techniques maps plaintext elements(characters, bits) into ciphertext elements.
Transposition techniques systematically transpose the positions of plaintext elements.
Rotor machines are sophisticated pre-computer hardware devices that use substitution
techniques.
Steganography is a technique for hiding a secret message within a larger one in such a way that
others cannot discern the presence or contents of the hidden message.
SYMMETRIC CIPHER MODEL:
A symmetric encryption scheme has five ingredients
Plaintext: This is the original intelligible message or data that is fed into the algorithm as input.
Encryption algorithm: The encryption algorithm performs various substitutions and
transformations on the plaintext.
Secret key: The secret key is also input to the encryption algorithm. The key is a value
independent of the plaintext and of the algorithm. The algorithm will produce a different output
depending on the specific key being used at the time. The exact substitutions and transformations
performed by the algorithm depend on the key.
Ciphertext: This is the scrambled message produced as output. It depends on the plaintext and
the secret key. For a given message, two different keys will produce two different ciphertexts.
The ciphertext is an apparently random stream of data and, as it stands, is unintelligible.
Decryption algorithm: This is essentially the encryption algorithm run in reverse. It takes the
ciphertext and the secret key and produces the original plaintext.

Substitution Techniques:
A substitution technique is one in which the letters of plaintext are replaced by other letters or by
numbers or symbols. If the plaintext is viewed as a sequence of bits, then substitution involves replacing
plaintext bit patterns with ciphertext bit patterns.

Monoalphabetic Ciphers:
Caesar Cipher:
The Caesar cipher involves replacing each letter of the alphabet with the letter standing
three places further down the alphabet.
plain : a b c d e f g h i j k l m n o p q r s t u v w x y z
cipher: D E F G H I J K L M N O P Q R S T U V W X Y Z A B C
Example:
Plain : meet me after the toga party
Cipher: PHHW PH DIWHU WKH WRJD SDUWB
With only 25 possible keys, the Caesar cipher is far from secure. A dramatic increase in the key
space can be achieved by allowing an arbitrary substitution. Before proceeding, we define the term
permutation. A permutation of a finite set of elements is an ordered sequence of all the elements of S,
with each element appearing exactly once. For example, if S={a, b, c}, there are six permutations of S.
In general, there are n! permutations of a set of elements, because the first element can be chosen in one
of n ways, the second in (n-1) ways, the third in (n-2) ways, and so on.

Playfair Cipher:
The Playfair cipher was the first practical digraph substitution cipher. The 'key' for a playfair
cipher is generally a word, for the sake of example we will choose 'monarchy'. This is then used to
generate a 'key square', e.g.
M O N A R
C H Y B D
E F G I/J K
L P Q S T
U V W X Z
1. Remove any punctuation or characters that are not present in the key square (this may mean
spelling out numbers, punctuation etc.).
2. Identify any double letters in the plaintext and replace the second occurence with an 'x' e.g.
'hammer' -> 'hamxer'.
3. If the plaintext has an odd number of characters, append an 'x' to the end to make it even.
4. Break the plaintext into pairs of letters, e.g. 'hamxer' -> 'ha mx er'
5. The algorithm now works on each of the letter pairs.
6. Locate the letters in the key square, (the examples given are using the key square above)
a. If the letters are in different rows and columns, replace the pair with the letters on the same
row respectively but at the other pair of corners of the rectangle defined by the original pair.
The order is important the first encrypted letter of the pair is the one that lies on the same
row as the first plaintext letter. 'ha' -> 'bo', 'es' -> 'il'
b. If the letters appear on the same row of the table, replace them with the letters to their
immediate right respectively (wrapping around to the left side of the row if a letter in the
original pair was on the right side of the row). 'ma' -> 'or', 'lp' -> 'pq'
c. If the letters appear on the same column of the table, replace them with the letters immediately
below respectively (wrapping around to the top side of the column if a letter in the original
pair was on the bottom side of the column). 'rk' -> 'dt', 'pv' -> 'vo'
Plain : WE ARE DISCOVERED SAVE YOURSELF
Cipher: UGRMKCSXHMUFMKBTOXGCMVATLUI V

Affine Cipher:
The affine cipher is a type of monoalphabetic substitution cipher, wherein each letter in an alphabet is mapped to
its numeric equivalent, encrypted using a simple mathematical function, and converted back to a letter. The formula
used means that each letter encrypts to one other letter, and back again, meaning the cipher is essentially a standard
substitution cipher with a rule governing which letter goes to which. As such, it has the weaknesses of all substitution
ciphers. Each letter is enciphered with the function , where is the magnitude of the shift.
In the affine cipher the letters of an alphabet of size are first mapped to the integers in the
range . It then uses modular arithmetic to transform the integer that each plaintext letter
corresponds to into another integer that correspond to a ciphertext letter. The encryption function for a
single letter is

where modulus is the size of the alphabet and and are the key of the cipher. The value must be
chosen such that and are coprime. The decryption function is

where is the modular multiplicative inverse of modulo . I.e., it satisfies the equation


Example:
Encryption: Let a=5 ,b=8;


plaintext: A F F I N E C I P H E R
x: 0 5 5 8 13 4 2 8 15 7 4 17

8 33 33 48 73 28 18 48 83 43 28 93

8 7 7 22 21 2 18 22 5 17 2 15
ciphertext: I H H W V C S W F R C P

Decryption:
, where is calculated to be 21, is 8, and is 26.

21*5=105
105 mod 26 =1
ciphertext: I H H W V C S W F R C P
y: 8 7 7 22 21 2 18 22 5 17 2 15
21(y-8): 0
-
21
-21 294 273 -126 210 294 -63 189 -126 147
(21(y-8)) mod 26: 0 5 5 8 13 4 2 8 15 7 4 17
plaintext: A F F I N E C I P H E R

Polyalphabetic Cipher:
Hill Cipher :
Invented by Lester S. Hill in 1929, the Hill cipher is a polygraphic substitution cipher based on
linear algebra. Hill used matrices and matrix multiplication to mix up the plaintext.
Example
This example will rely on some linear algebra and some number theory. The key for a hill cipher is a
matrix e.g.

In the above case, we have taken the size to be 33, however it can be any size (as long as it is square).
Assume we want to encipher the message ATTACK AT DAWN. To encipher this, we need to break the
message into chunks of 3. We now take the first 3 characters from our plaintext, ATT and create a
vector that corresponds to the letters (replace A with 0, B with 1 ... Z with 25 etc.) to get: [0 19
19] (this is ['A' 'T' 'T']).
To get our ciphertext we perform a matrix multiplication (you may need to revise matrix
multiplication if this doesn't make sense):

This process is performed for all 3 letter blocks in the plaintext. The plaintext may have to be padded
with some extra letters to make sure that there is a whole number of blocks.
Now for the tricky part, the decryption. We need to find an inverse matrix modulo 26 to use as our
'decryption key'. i.e. we want something that will take 'PFO' back to 'ATT'. If our 3 by 3 key matrix is
calledK, our decryption key will be the 3 by 3 matrix K
-1
, which is the inverse of K.

To find K
-1
we have to use a bit of maths. It turns out that K
-1
above can be calculated from our key. A
lengthy discussion will not be included here, but we will give a short example. The important things to
know are inverses (mod m), determinants of matrices, and matrix adjugates.
Let K be the key matrix. Let d be the determinant of K. We wish to find K
-1
(the inverse of K), such
that K K
-1
= I (mod 26), where I is the identity matrix. The following formula tells us how to find K
-
1
given K:

where d d
-1
= 1(mod 26), and adj(K) is the adjugate matrix of K.
d (the determinant) is calculated normally for K (for the example above, it is 489 = 21 (mod 26)). The
inverse, d
-1
, is found by finding a number such that d d
-1
= 1 (mod 26) (this is 5 for the example above
since 5*21 = 105 = 1 (mod 26)). The simplest way of doing this is to loop through the numbers 1..25
and find the one such that the equation is satisfied. There is no solution (i.e. choose a different key)
if gcd(d,26) 1 (this means d and 26 share factors, if this is the case K can not be inverted, this means
the key you have chosen will not work, so choose another one).
That is it. Once K
-1
is found, decryption can be performed.
VIGNERE CIPHER:
The Vigenre cipher is a method of encrypting alphabetic text by using a series of
different Caesar ciphers based on the letters of a keyword. It is a simple form of polyalphabetic
substitution.
The 'key' for a vigenere cipher is a key word. e.g. 'FORTIFICATION'
The Vigenere Cipher uses the following tableau (the 'tabula recta') to encipher the plaintext:
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
---------------------------------------------------
A A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
B B C D E F G H I J K L M N O P Q R S T U V W X Y Z A
C C D E F G H I J K L M N O P Q R S T U V W X Y Z A B
D D E F G H I J K L M N O P Q R S T U V W X Y Z A B C
E E F G H I J K L M N O P Q R S T U V W X Y Z A B C D
F F G H I J K L M N O P Q R S T U V W X Y Z A B C D E
G G H I J K L M N O P Q R S T U V W X Y Z A B C D E F
H H I J K L M N O P Q R S T U V W X Y Z A B C D E F G
I I J K L M N O P Q R S T U V W X Y Z A B C D E F G H
J J K L M N O P Q R S T U V W X Y Z A B C D E F G H I
K K L M N O P Q R S T U V W X Y Z A B C D E F G H I J
L L M N O P Q R S T U V W X Y Z A B C D E F G H I J K
M M N O P Q R S T U V W X Y Z A B C D E F G H I J K L
N N O P Q R S T U V W X Y Z A B C D E F G H I J K L M
O O P Q R S T U V W X Y Z A B C D E F G H I J K L M N
P P Q R S T U V W X Y Z A B C D E F G H I J K L M N O
Q Q R S T U V W X Y Z A B C D E F G H I J K L M N O P
R R S T U V W X Y Z A B C D E F G H I J K L M N O P Q
S S T U V W X Y Z A B C D E F G H I J K L M N O P Q R
T T U V W X Y Z A B C D E F G H I J K L M N O P Q R S
U U V W X Y Z A B C D E F G H I J K L M N O P Q R S T
V V W X Y Z A B C D E F G H I J K L M N O P Q R S T U
W W X Y Z A B C D E F G H I J K L M N O P Q R S T U V
X X Y Z A B C D E F G H I J K L M N O P Q R S T U V W
Y Y Z A B C D E F G H I J K L M N O P Q R S T U V W X
Z Z A B C D E F G H I J K L M N O P Q R S T U V W X Y
To encipher a message, repeat the keyword above the plaintext:
FORTIFICATIONFORTIFICATIONFO
DEFENDTHEEASTWALLOFTHECASTLE
Now we take the letter we will be encoding, 'D', and find it on the first column on the tableau. Then, we
move along the 'D' row of the tableau until we come to the column with the 'F' at the top (The 'F' is the
keyword letter for the first 'D'), the intersection is our ciphertext character, 'I'.So, the ciphertext for the
above plaintext is:
FORTIFICATIONFORTIFICATIONFO
DEFENDTHEEASTWALLOFTHECASTLE
ISWXVIBJEXIGGBOCEWKBJEVIGGQS
ADFGVX Cipher:
In cryptography, the ADFGVX cipher was a field cipher used by the German Army during
World War I. ADFGVX was in fact an extension of an earlier cipher called ADFGX.
Suppose we need to send the plaintext message, "Attack at 12:00am". First, a secret mixed alphabet is
filled into a 5 5 Polybius square, like so:
A D F G V X
A N A 1 C 3 H
D 8 T B 2 O M
F E 5 W R P D
G 4 F 6 G 7 I
V 9 J 0 K L Q
X S U V X Y Z
The text 'attack at 1200am' will translate to this:
A T T A C K A T 1 2 0 0 A M
AD DD DD AD AG VG AD DD AF DG VF VF AD DX
Then, a new table is created with a key as a heading. Let's use 'PRIVACY' as a key. Usually much
longer keys or even phrases were used.
P R I V A C Y
A D D D D D A
D A G V G A D
D D A F D G V
F V F A D D X
The columns are sorted alphabetically based on the keyword and the table changes to this:
A C I P R V Y
D D D A D D A
G A G D A V D
D G A D D F V
D D F F V A X
Then, appending the columns to each other results in the following cipher text:
DGDD DAGD DGAF ADDF DADV DVFA ADVX
Having the keyword, the columns can be reconstructed and placed in the correct order. When using the
original table containing the secret alphabet, the text can be deciphered.

One-Time Pad:
The one-time pad is a long sequence of random letters. These letters are combined with the plaintext
message to produce the ciphertext. To decipher the message, a person must have a copy of the one-time
pad to reverse the process. A one-time pad should be used only once (hence the name) and then
destroyed. This is the first and only encryption algorithm that has been proven to be unbreakable.
To encipher a message, you take the first letter in the plaintext message and add it to the first random
letter from the one-time pad. For example, suppose you are enciphering the letter S (the 19th letter of the
alphabet) and the one-time pad gives you C (3rd letter of the alphabet). You add the two letters and
subtract 1. When you add S and C and subtract 1, you get 21 which is U. Each letter is enciphered in this
method, with the alphabet wrapping around to the begining if the addition results in a number beyond 26
(Z).To decipher a message, you take the first letter of the ciphertext and subtract the first random letter
from the one-time pad. If the number is negative you wrap around to the end of the alphabet.
Example

plaintext : SECRETMESSAGE
one-time pad: CIJTHUUHMLFRU
ciphertext : UMLKLNGLEDFXY

TRANSPOSITION TECHNIQUES:
All the techniques examined so far involve the substitution of a ciphertext symbol for a plaintext
symbol. A very different kind of mapping is achieved by performing some sort of permutation on the
plaintext letters. This technique is referred to as a transposition cipher.

Rail Fence
The simplest such cipher is the rail fence technique, in which the plaintext is written down as a
sequence of diagonals and then read off as a sequence of rows. For example, to encipher the message
meet me after the toga party with a rail fence of depth 2, we write the following:
m e m a t r h t g p r y
e t e f e t e o a a t
The encrypted message is
MEMATRHTGPRYETEFETEOAAT
Columnar Transposition
A more complex scheme is to write the message in a rectangle, row by row, and read the
message off, column by column, but permute the order of the columns. The order of the columns then
becomes the key to the algorithm. For example,

Key: 4 3 1 2 5 6 7
Plaintext: a t t a c k p
o s t p o n e
d u n t i l t
w o a m x y z
Ciphertext: TTNAAPTMTSUOAODWCOIXKNLYPETZ
Thus, in this example, the key is 4312567.To encrypt, start with the column that is labeled 1, in this case
column 3.Write down all the letters in that column. Proceed to column 4, which is labeled 2, then
column 2, then column 1, then columns 5, 6, and 7.

ROTOR MACHINES
Multiple stages of encryption can produce an algorithm that is significantly more difficult to
cryptanalyze. This is as true of substitution ciphers as it is of transposition ciphers. Before the
introduction of DES, the most important application of the principle of multiple stages of encryption was
a class of systems known as rotor machines.
The machine consists of a set of independently rotating cylinders through which electrical pulses
can flow. Each cylinder has 26 input pins and 26 output pins, with internal wiring that connects each
input pin to a unique output pin. For simplicity, only three of the internal connections in each cylinder
are shown. If we associate each input and output pin with a letter of the alphabet, then a single cylinder
defines a monoalphabetic substitution.
Consider a machine with a single cylinder.After each input key is depressed, the cylinder rotates
one position, so that the internal connections are shifted accordingly. Thus, a different monoalphabetic
substitution cipher is defined. With multiple cylinders, the one closest to the operator input rotates one
pin position with each keystroke

STEGANOGRAPHY:
A plaintext message may be hidden in one of two ways. The methods of steganography conceal
the existence of the message, whereas the methods of cryptography render the message unintelligible to
outsiders by various transformations of the text. A simple form of steganography, but one that is time-
consuming to construct,
is one in which an arrangement of words or letters within an apparently innocuous text spells out the real
message. For example, the sequence of first letters of each word of the overall message spells out the
hidden message.

BASIC NUMBER SYSTEM :

Divisibility
We say that a nonzero b divides a if a=mb for some m , where a, b and m are integers.
That is, b divides a if there is no remainder on division. The notation b|a is commonly used to
mean b divides a. Also, if b | a, we say that b is a divisor of a.
GREATEST COMMON DIVISOR:
The notation gcd (a, b) to mean the greatest common divisor of a and b. The greatest
common divisor of a and b is the largest integer that divides both and .We also define gcd (0, 0)
= 0. Two integers are relatively prime if their only common positive integer factor or their GCD
is 1.

Ex: gcd(60, 24) =12;
Gcd(8,15) =1 since 8 and 15 are relatively prime that is the positive divisors of 8 are 1, 2, 4,
and 8, and the positive divisors of 15 are 1, 3, 5, and 15. So 1 is the only integer on both lists.

Euclidean Algorithm:
Theorem: Let a and b be positive integers. Then there is an algorithm that finds (a, b).
Lemma: If a, b, q, r are integers and a = bq + r, then (a, b) = (b, r).
Proof: We have (a, b) = (bq + r, b) = (b, r).
Proof of the Theorem:The idea is to keep repeating the division algorithm.
We have:
a = bq1 + r1, (a, b) = (b, r1)
b = r1q2 + r2, (b, r1) = (r1, r2)
r1 = r2q3 + r3, (r1, r2) = (r2, r3)
r2 = r3q4 + r4, (r2, r3) = (r3, r4)
. . .
rn2 = rn1qn + rn, (rn2, rn1) = (rn1, rn)
rn1 = rnqn+1, (rn1, rn) = rn,
therefore
(a, b) = (b, r1) = (r1, r2) = (r2, r3) = (r3, r4) = . . . = (rn2, rn1) = (rn1, rn) = rn.
Examples:






Extended Euclidean Algorithm:
The extended Euclidean algorithm is particularly useful
when a and b are coprime, since x is the modular multiplicative inverse of a modulo b,
and y is the modular multiplicative inverse of b modulo a.
Examples:




CONGRUENCES:

One of the most basic and useful notions in number theory is modular arithmetic, or congruences.

Definition: Let a, b, n be integers with n # 0. We say that a=b (mod n) {read: a is congruent to b mod
n) if a-b is a multiple (positive or negative) of n.
Another formulation is that a = b (mod n) if a and b differ by a multiple of n. This can be rewritten as
a=b + nk for some integer k (positive or negative).

Examples.
(i) 32 = 7 (mod 5),
(ii) -12 = 37 (mod 7),
(iii) 17 = 17 (mod 13).
(iv) Here is an example of how we can do algebra mod n. Consider the following problem:
Solve x + 7 = 3 (mod 17).
Solution: x3- 7 -4 13 (mod 17).
Working with fractions
In our usual arithmetic on rational numbers (i.e. fractions), the inverse of a fraction n is just q =
1/n, which is still a fraction. In other words, it is the fraction q such nq = 1. In Zm, an inverse of a
number n is a number q such that nq 1 (mod m). But this no longer means that q = 1/n, since 1/n is
not allowed in our set {0, 1, 2, . . . , m 1}!

Examples:
Suppose were working in Z5. Zero has no inverse, because there is no number
q such that 0 q 1 (remember this would mean 1 0q = 1 is divisible by 5, which is never
true). The inverse of 1 is clearly 1, since 1 1 1. The inverse of 2 is 3, since 2 3 1. The
inverse of 3 is 2, the inverse of 4 is 4, and so weve worked out the inverses of all numbers in Z5,
apart from 0 which has no inverse. Lets now try Z6. Zero has no inverse again, and the inverse
of 1 is 1. What about 2? Well we can try all numbers in {0, 1, 2, 3, 4, 5}, and none of them
satisfies the definition of the inverse. So we say that 2 has no inverse. Similarly, 3 and 4 have no
inverse. Now 5 has an inverse, namely 5, since 5 5 = 25 and 25 1.

The Chinese Remainder Theorem

Theorem:
Suppose that m
1
, m
2
, ..., m
r
are pair wise relatively prime positive integers, and let
a
1
, a
2
, ..., a
r
be integers. Then the system of congruencies, x a
i
(mod m
i
) for 1 i r, has a
unique solution modulo M = m
1
m
2
... m
r
, which is given by:
X a
1
M
1
y
1
+a
2
M
2
y
2
+... +a
r
M
r
y
r
(mod M),
where M
i
= M/m
i
and y
i
(M
i
)
-1
(mod m
i
) for 1 i r.
Proof:
Given that gcd(M
i
, m
i
) = 1 for 1 i r. Therefore, the y
i
all exist (y
i
is inverse of M
i
).
Since M
i
y
i
1 (mod m
i
), we have a
i
M
i
y
i
a
i
mod m
i
for 1 i r. On the other hand, a
i
M
i
y
i
0 (mod m
j
)
if j i (since m
j
| M
i
in this case). Thus, we see that x a
i
(mod m
i
) for 1 i r. If x
0
and x
1
were
solutions, then we would have x
0
- x
1
0 (mod m
i
) or all i, so x
0
- x
1
0 (mod M), i.e., they are the same
modulo M.

Example 1 :
An old woman goes to market and a horse steps on her basket and crushes the eggs. The rider
offers to pay for the damages and asks her how many eggs she had brought. She does not remember the
exact number, but when she had taken them out two at a time, there was one egg left. The same
happened when she picked them out three, four, five, and six at a time, but when she took them
seven at a time they came out even. What is the smallest number of eggs she could have had?
Solution:
The number of broken eggs, x, must satisfy:
x 1 mod 2,
x 1 mod 3,
x 1 mod 4,
x 1 mod 5,
x 1 mod 6 and
x 0 mod 7.

The first congruence says that x is odd, so we shall keep this in mind and ignore this congruence.
To use our theorem, we will also omit the congruence x 1 mod 6 so that the moduli of the
remaining congruences (3, 4, 5 and 7) are relatively prime or coprime in pairs.

The Chinese Remainder theorem indicates that there is a unique solution modulo 420 (3457),
which is calculated by:






X a
3
M
3
y
3+
a
4
M
4
y
4
+a
5
M
5
y
5
+a
7
M
7
y
7
(mod M)

So, X 1(140)(2) + 1(105)(1) + 1(84)(4) + (60)(2) = 280 + 105 + 336 = 721 mod 420
= 301.
As this value of X is odd and satisfies x 1 mod 6, it is the smallest solution of the broken eggs
problem.
M
3
= 420/3 = 140 y
3
(140)
-1
mod 3 = 2
M
4
= 420/4 = 105 y
4
(105)
-1
mod 4 = 1
M
5
= 420/5 = 4 y
5
(84)
-1
mod 5 = 4
M
7
= 420/7 = 60 y
7
(60)
-1
mod 7 = 2
Example 2:

MODULAR EXPONENTIATION:
A "modular exponentiation" calculates the remainder when a positive integer x (the base) raised
to the a-th power (the exponent), x
a
, is divided by a positive integer n, called the modulus. In symbols,
given base x, exponent a, and modulus n, the modular exponentiation c is:
x
a
(mod n).
Example 1:
Calculate the value of: 23
20
mod 29.
Solution:
23
2
mod 29 = 7,
23
4
= (23
2
23
2
) = 77 mod 29 = 49 mod 29 = 20
23
8
= (23
4
23
4
) = 2020 mod 29 = 400 mod 29 = 23
23
16
= (23
8
23
8
) = 2323 mod 29 = 529 mod 29 = 7
23
20
= (23
4
23
16
) = 207 mod 29 = 140 mod 29 = 24
Example 2:
Calculate the value of 31
397
mod 55
Solution:
31
4
=676 mod 55 = 16
31
397
= 31
256
. 31
128
.31
8
.31
4
.31 [397 = 256 + 128 + 8 + 4 + 1]
= 3136361631
= (1116 mod 55)361631
= 16361631
= (576 mod 55) 1631
= 261631
= (416 mod 55)31
= 3131
= 961 mod 55
= 26.
FERMAT'S LITTLE THEOREM

Theorem: lf p is a prime and p does not divide a, then a
p-1
= 1 (mod p).
Proof:
Start by listing the first p-1 positive multiples of a:
a, 2a, 3a, ... (p -1)a
Suppose that ra and sa are the same modulo p, then we have r = s (mod p), so the p-1
multiples of a above are distinct and nonzero; that is, they must be congruent to 1, 2, 3, ..., p-1 in
some order.
Multiply all these congruences together and we find
a
.
2a
.
3a
.
...
.
(p-1)a = 1
.
2
.
3
.
...
.
(p-1) (mod p)
a
(p-1)
(p-1)! = (p-1)! (mod p).
Divide both side by (p-1)! to complete the proof: a
(p-1)
=1 (mod p)
Example 1: Calculate 2
345
mod 11 efficiently using Fermats Little Theorem.
Solution: The number 2 is not divisible by the prime 11, so
2
10
1 (mod 11) [Fermats Little Theorem]
345 = 34 10 + 5 [Division Algorithm]
2
345
= ( 2
34
)
10
+5
= (2
10
)34. 2
5
,
2
345
1
34
2
5
1 32
10 (mod 11).
Thus, 2
345
mod 11 =10.
Example 2:What is the remainder after dividing 3
50
by 7?
Solution: By Fermats Little theorem we have
3
6
1 mod 7, [7 is prime]
3
50
=3
6

8
.3
2

1
8
.9
9
2 mod 7.
Thus the remainder is 2.

EULER'S THEOREM:

Theorem: If gcd(a, n) = 1, then at a
(n)
= 1 (mod n).
Proof: Let S be the set of integers 1 < x < n with gcd(x, n) = l.
Let :S S be defined by (x) = ax (mod n).
The numbers (x) for x S are the numbers inS written in some order.
Therefore,

xS
x =
xS
(x) a
(n)

xS
x.
Dividing out the factors x E S, we are left with
1 = a
(n)
(mod n).

Example: Compute 2
43210
(mod 101).
Solution: 101 is prime, hence

2
100
1 (mod 101) [using a
p-1
= 1 (mod )]
2
43210
((2
100
)
432
). 2
10
[100*432+210]




1
432
.2
10
[2
100
1 (mod 101)]
1024 (mod 101) [2
10
=1024]
14

You might also like