Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
25 views

Cryptography (Module 1) Notes

Cryptography is a technique used to secure communications and data by converting information into an unreadable format except by authorized parties. It uses mathematical algorithms and cryptographic keys to encrypt data. The main goals of cryptography are confidentiality, integrity, authentication, and non-repudiation. There are three main types of cryptography - symmetric which uses a shared key, asymmetric which uses public/private key pairs, and hashing which is used for passwords. Cryptography has many applications including computer passwords, digital currencies, secure web browsing, digital signatures, and end-to-end encrypted messaging. It provides advantages such as access control, secure communication, and protection against cyber attacks.

Uploaded by

Colossus Gaming
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views

Cryptography (Module 1) Notes

Cryptography is a technique used to secure communications and data by converting information into an unreadable format except by authorized parties. It uses mathematical algorithms and cryptographic keys to encrypt data. The main goals of cryptography are confidentiality, integrity, authentication, and non-repudiation. There are three main types of cryptography - symmetric which uses a shared key, asymmetric which uses public/private key pairs, and hashing which is used for passwords. Cryptography has many applications including computer passwords, digital currencies, secure web browsing, digital signatures, and end-to-end encrypted messaging. It provides advantages such as access control, secure communication, and protection against cyber attacks.

Uploaded by

Colossus Gaming
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 21

Cryptography is technique of securing information and communications through use

of codes so that only those person for whom the information is intended can
understand it and process it. Thus preventing unauthorized access to information.
The prefix “crypt” means “hidden” and suffix “graphy” means “writing”. In
Cryptography the techniques which are use to protect information are obtained from
mathematical concepts and a set of rule based calculations known as algorithms to
convert messages in ways that make it hard to decode it. These algorithms are used
for cryptographic key generation, digital signing, verification to protect data privacy,
web browsing on internet and to protect confidential transactions such as credit card
and debit card transactions.
Techniques used For Cryptography: In today’s age of computers cryptography is
often associated with the process where an ordinary plain text is converted to cipher
text which is the text made such that intended receiver of the text can only decode it
and hence this process is known as encryption. The process of conversion of cipher
text to plain text this is known as decryption.
Features Of Cryptography are as follows:
1. Confidentiality: Information can only be accessed by the person for
whom it is intended and no other person except him can access it.
2. Integrity: Information cannot be modified in storage or transition between
sender and intended receiver without any addition to information being
detected.
3. Non-repudiation: The creator/sender of information cannot deny his
intention to send information at later stage.
4. Authentication: The identities of sender and receiver are confirmed. As
well as destination/origin of information is confirmed.
Types Of Cryptography: In general there are three types Of cryptography:
1. Symmetric Key Cryptography: It is an encryption system where the
sender and receiver of message use a single common key to encrypt and
decrypt messages. Symmetric Key Systems are faster and simpler but the
problem is that sender and receiver have to somehow exchange key in a
secure manner. The most popular symmetric key cryptography system are
Data Encryption System(DES) and Advanced Encryption System(AES).
2. Hash Functions: There is no usage of any key in this algorithm. A hash
value with fixed length is calculated as per the plain text which makes it
impossible for contents of plain text to be recovered. Many operating
systems use hash functions to encrypt passwords.
3. Asymmetric Key Cryptography: Under this system a pair of keys is used
to encrypt and decrypt information. A receiver’s public key is used for
encryption and a receiver’s private key is used for decryption. Public key
and Private Key are different. Even if the public key is known by everyone
the intended receiver can only decode it because he alone know his private
key. The most popular asymmetric key cryptography algorithm is RSA
algorithm.
Applications Of Cryptography:
1. Computer passwords: Cryptography is widely utilized in computer
security, particularly when creating and maintaining passwords. When a
user logs in, their password is hashed and compared to the hash that was
previously stored. Passwords are hashed and encrypted before being
stored. In this technique, the passwords are encrypted so that even if a
hacker gains access to the password database, they cannot read the
passwords.
2. Digital Currencies: To safeguard transactions and prevent fraud, digital
currencies like Bitcoin also use cryptography. Complex algorithms and
cryptographic keys are used to safeguard transactions, making it nearly
hard to tamper with or forge the transactions.
3. Secure web browsing: Online browsing security is provided by the use of
cryptography, which shields users from eavesdropping and man-in-the-
middle assaults. Public key cryptography is used by the Secure Sockets
Layer (SSL) and Transport Layer Security (TLS) protocols to encrypt data
sent between the web server and the client, establishing a secure channel
for communication.
4. Electronic signatures: Electronic signatures serve as the digital
equivalent of a handwritten signature and are used to sign documents.
Digital signatures are created using cryptography and can be validated
using public key cryptography. In many nations, electronic signatures are
enforceable by law, and their use is expanding quickly.
5. Authentication: Cryptography is used for authentication in many
different situations, such as when accessing a bank account, logging into a
computer, or using a secure network. Cryptographic methods are
employed by authentication protocols to confirm the user’s identity and
confirm that they have the required access rights to the resource.
6. Cryptocurrencies: Cryptography is heavily used by cryptocurrencies like
Bitcoin and Ethereum to safeguard transactions, thwart fraud, and
maintain the network’s integrity. Complex algorithms and cryptographic
keys are used to safeguard transactions, making it nearly hard to tamper
with or forge the transactions.
7. End-to-End Encryption: End-to-end encryption is used to protect two-
way communications like video conversations, instant messages, and
email. Even if the message is encrypted, it assures that only the intended
receivers can read the message. End-to-end encryption is widely used in
communication apps like WhatsApp and Signal, and it provides a high
level of security and privacy for users.

Advantages

1. Access Control: Cryptography can be used for access control to ensure


that only parties with the proper permissions have access to a resource.
Only those with the correct decryption key can access the resource thanks
to encryption.
2. Secure Communication: For secure online communication, cryptography
is crucial. It offers secure mechanisms for transmitting private information
like passwords, bank account numbers, and other sensitive data over the
internet.
3. Protection against attacks: Cryptography aids in the defence against
various types of assaults, including replay and man-in-the-middle attacks.
It offers strategies for spotting and stopping these assaults.
4. Compliance with legal requirements: Cryptography can assist firms in
meeting a variety of legal requirements, including data protection and
privacy legislation.

Type of Attacks
The main aim of any organisation is to protect their data from attackers.
In cryptography, attacks are of two types such as Passive attacks and
Active attacks.
Passive attacks are those that retrieve information from the system without
affecting the system resources while active attacks are those that retrieve
system information and make changes to the system resources and their
operations.

The Principles of Security can be classified as follows:

1. Confidentiality:
The degree of confidentiality determines the secrecy of the information.
The principle specifies that only the sender and receiver will be able to
access the information shared between them. Confidentiality compromises
if an unauthorized person is able to access a message.
For example, let us consider sender A wants to share some confidential
information with receiver B and the information gets intercepted by the
attacker C. Now the confidential information is in the hands of an intruder
C.

2. Authentication:
Authentication is the mechanism to identify the user or system or the
entity. It ensures the identity of the person trying to access the
information. The authentication is mostly secured by using username and
password. The authorized person whose identity is preregistered can prove
his/her identity and can access the sensitive information.

3. Integrity:
Integrity gives the assurance that the information received is exact and
accurate. If the content of the message is changed after the sender sends it
but before reaching the intended receiver, then it is said that the integrity
of the message is lost.
 System Integrity: System Integrity assures that a system performs its
intended function in an unimpaired manner, free from deliberate or
inadvertent unauthorized manipulation of the system.
 Data Integrity: Data Integrity assures that information (both stored and in
transmitted packets) and programs are changed only in a specified
and authorized manner.
4. Non-Repudiation:
Non-repudiation is a mechanism that prevents the denial of the message
content sent through a network. In some cases the sender sends the message and
later denies it. But the non-repudiation does not allow the sender to refuse the
receiver.

5. Access control:
The principle of access control is determined by role management and rule
management. Role management determines who should access the data while rule
management determines up to what extent one can access the data. The information
displayed is dependent on the person who is accessing it.

6. Availability:
The principle of availability states that the resources will be available to
authorize party at all times. Information will not be useful if it is not available to be
accessed. Systems should have sufficient availability of information to satisfy the
user request.
There are various types of substitution ciphers which are as follows −

 Monoalphabetic Cipher − In monoalphabetic substitution cipher, a character in a


plaintext is always restored or changed to the similar character in the ciphertext
indifferent of its position in the text. Example Caesar Cipher
 Caesar Cipher (Shift Cipher) It is a mono-alphabetic cipher wherein each letter of the
plaintext is substituted by another letter to form the cipher text. It is a simplest form of
substitution cipher scheme.
For this type of scheme, both sender and receiver agree on a ‘secret shift number’ for
shifting the alphabet. This number which is between 0 and 25 becomes the key of
encryption. The name ‘Caesar Cipher’ is occasionally used to describe the Shift Cipher
when the ‘shift of three’ is used.

 Polyalphabetic cipher − In polyalphabetic substitution, each appearance of a character in


the plaintext can have a different substitution character in the ciphertext.
The relationship among a character in plaintext and a character in ciphertext is one to
many. For instance, letter ‘A’ can be restored by the letter ‘C’ and the similar letter ‘A’
can be restored by ‘N’ later in the ciphertext.
In polyalphabetic cipher, frequencies of plaintext letter are not reflected in the ciphertext.
Therefore, breaking of polyalphabetic cipher is complex than monoalphabetic cipher as
statistical analysis cannot be used on it.
The main feature of polyalphabetic substitution cipher are the following −
o It is needed a set of associated monoalphabetic substitution rules.
o It need a key that decides which rule is used for which transformation.

Example of Polyalphabetic cipher technique


1. One-Time Pad
2. Playfair Cipher
 One-Time Pad − The one-time pad cipher recommend that the key length must be as
long as the plain text to avoid the repetition of key. Along with that, the key must be used
only once to encrypt and decrypt the individual message after that the key must be
discarded.
A B C D E F G H I
0 1 2 3 4 5 6 7 8
J K L M N O P Q R
9 10 11 12 13 14 15 16 17
S T U V W X Y Z
18 19 20 21 22 23 24 25

Examples(Encryption):

Input: Message = HELLO


Key = MONEY
Output: Cipher =TSYPM
Explanation:

Plain text —
H E L L O
7 4 11 11 14

key—
M O N E Y
12 14 13 4 24

Plain text + Key


(7+12)Mod26 (4+14)Mod26 (11+13)Mod26 (11+4)Mod26 (14+24)Mod26
=19 =18 =24 =15 =12

Cipher Text
T (19) S(18) Y(24) P(15) M(12)
Examples(Decryption):

Cipher Text : TSYPM


Key: MONEY
Cipher text - Key
(19-12)Mod26=7 (H) (18-14)Mod26=4 (E) (24-13)Mod26=11 (L)
(15-4)Mod26=11 (L) (12-24)Mod26=14 (O)

 Playfair Cipher − The playfair cipher is also known as Playfair Square. It is a


cryptographic technique used for manual encryption of information .
Transposition Techniques

All the techniques examined so far involve the substitution of a cipher text 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.

Example of Transposition Techniques

1. Rail fence
2. Row Transposition Ciphers

Rail fence Transposition Techniques (zigzag cipher)

In a transposition cipher, the order of the alphabets is re-arranged to obtain the cipher-text.

 In the rail fence cipher, the plain-text is written downwards and diagonally on successive rails of
an imaginary fence.
 When we reach the bottom rail, we traverse upwards moving diagonally, after reaching the top
rail, the direction is changed again. Thus the alphabets of the message are written in a zig-zag
manner.
 After each alphabet has been written, the individual rows are combined to obtain the cipher-
text.
For example, if the message is “GeeksforGeeks” and the number of rails = 3 then cipher is prepared
as:

Its encryption will be done row wise i.e. GSGSEKFREKEOE


What Is Steganography?

A steganography technique involves hiding sensitive information within an ordinary,


non-secret file or message, so that it will not be detected. The sensitive information
will then be extracted from the ordinary file or message at its destination, thus
avoiding detection. Steganography is an additional step that can be used in
conjunction with encryption in order to conceal or protect data.

Steganography is a means of concealing secret information within (or even on top of)
an otherwise mundane, non-secret document or other media to avoid detection. It
comes from the Greek words steganos, which means “covered” or “hidden,” and
graph, which means “to write.” Hence, “hidden writing.”

You can use steganography to hide text, video, images, or even audio data. It’s a
helpful bit of knowledge, limited only by the type of medium and the author’s
imagination.

Different Types of Steganography

1. Text Steganography − There is steganography in text files, which entails secretly


storing information. In this method, the hidden data is encoded into the letter of each
word.

2. Image Steganography − The second type of steganography is image


steganography, which entails concealing data by using an image of a different object
as a cover. Pixel intensities are the key to data concealment in image
steganography.

Since the computer description of an image contains multiple bits, images are
frequently used as a cover source in digital steganography.

The various terms used to describe image steganography include:

 Cover-Image - Unique picture that can conceal data.

 Message - Real data that you can mask within pictures. The message may be in the form
of standard text or an image.

 Stego-Image − A stego image is an image with a hidden message.

 Stego-Key - Messages can be embedded in cover images and stego-images with the
help of a key, or the messages can be derived from the photos themselves.

3. Audio Steganography − It is the science of hiding data in sound. Used digitally, it


protects against unauthorized reproduction. Watermarking is a technique that
encrypts one piece of data (the message) within another (the "carrier"). Its typical
uses involve media playback, primarily audio clips.
4. Video Steganography − Video steganography is a method of secretly embedding
data or other files within a video file on a computer. Video (a collection of still
images) can function as the "carrier" in this scheme. Discrete cosine transform
(DCT) is commonly used to insert values that can be used to hide the data in each
image in the video, which is undetectable to the naked eye. Video steganography
typically employs the following file formats: H.264, MP4, MPEG, and AVI.

5. Network or Protocol Steganography − It involves concealing data by using a


network protocol like TCP, UDP, ICMP, IP, etc., as a cover object. Steganography
can be used in the case of covert channels, which occur in the OSI layer network
model.

Steganography Examples Include

 Writing with invisible ink

 Embedding text in a picture (like an artist hiding their initials in a painting they’ve done)

 Concealing information in either metadata or within a file header

 Hiding an image in a video, viewable only if the video is played at a particular frame rate

 Embedding a secret message in either the green, blue, or red channels of an RRB image
Types Of Cryptography: In general there are three types Of cryptography:

1. Symmetric Key Cryptography: It is an encryption system where the sender and


receiver of message use a single common key to encrypt and decrypt messages.
Symmetric Key Systems are faster and simpler but the problem is that sender and
receiver have to somehow exchange key in a secure manner. The most popular
symmetric key cryptography system are Data Encryption System(DES) and
Advanced Encryption System(AES).
2. Hash Functions: There is no usage of any key in this algorithm. A hash value
with fixed length is calculated as per the plain text which makes it impossible for
contents of plain text to be recovered. Many operating systems use hash
functions to encrypt passwords.
3. Asymmetric Key Cryptography: Under this system a pair of keys is used to
encrypt and decrypt information. A receiver’s public key is used for encryption
and a receiver’s private key is used for decryption. Public key and Private Key
are different. Even if the public key is known by everyone the intended receiver
can only decode it because he alone know his private key. The most popular
asymmetric key cryptography algorithm is RSA algorithm.

Applications Of Cryptography:

1. Computer passwords: Cryptography is widely utilized in computer security,


particularly when creating and maintaining passwords. When a user logs in, their
password is hashed and compared to the hash that was previously stored.
Passwords are hashed and encrypted before being stored. In this technique, the
passwords are encrypted so that even if a hacker gains access to the password
database, they cannot read the passwords.
2. Digital Currencies: To safeguard transactions and prevent fraud, digital
currencies like Bitcoin also use cryptography. Complex algorithms and
cryptographic keys are used to safeguard transactions, making it nearly hard to
tamper with or forge the transactions.
3. Secure web browsing: Online browsing security is provided by the use of
cryptography, which shields users from eavesdropping and man-in-the-middle
assaults. Public key cryptography is used by the Secure Sockets Layer (SSL) and
Transport Layer Security (TLS) protocols to encrypt data sent between the web
server and the client, establishing a secure channel for communication.
4. Electronic signatures: Electronic signatures serve as the digital equivalent of a
handwritten signature and are used to sign documents. Digital signatures are
created using cryptography and can be validated using public key cryptography.
In many nations, electronic signatures are enforceable by law, and their use is
expanding quickly.
5. Authentication: Cryptography is used for authentication in many different
situations, such as when accessing a bank account, logging into a computer, or
using a secure network. Cryptographic methods are employed by authentication
protocols to confirm the user’s identity and confirm that they have the required
access rights to the resource.
6. Cryptocurrencies: Cryptography is heavily used by cryptocurrencies like
Bitcoin and Ethereum to safeguard transactions, thwart fraud, and maintain the
network’s integrity. Complex algorithms and cryptographic keys are used to
safeguard transactions, making it nearly hard to tamper with or forge the
transactions.
7. End-to-End Encryption: End-to-end encryption is used to protect two-way
communications like video conversations, instant messages, and email. Even if
the message is encrypted, it assures that only the intended receivers can read the
message. End-to-end encryption is widely used in communication apps like
WhatsApp and Signal, and it provides a high level of security and privacy for
users.

Advantages of Cryptography

1. Access Control: Cryptography can be used for access control to ensure that only
parties with the proper permissions have access to a resource. Only those with
the correct decryption key can access the resource thanks to encryption.
2. Secure Communication: For secure online communication, cryptography is
crucial. It offers secure mechanisms for transmitting private information like
passwords, bank account numbers, and other sensitive data over the internet.
3. Protection against attacks: Cryptography aids in the defence against various
types of assaults, including replay and man-in-the-middle attacks. It offers
strategies for spotting and stopping these assaults.
4. Compliance with legal requirements: Cryptography can assist firms in meeting
a variety of legal requirements, including data protection and privacy legislation.
Block Cipher Design Principles
Block ciphers are built in the Feistel cipher structure. Block cipher has a specific
number of rounds and keys for generating ciphertext.Block cipher is a type of
encryption algorithm that processes fixed-size blocks of data, usually 64 or 128 bits,
to produce ciphertext. The design of a block cipher involves several important
principles to ensure the security and efficiency of the algorithm. Some of these
principles are:
1. Number of Rounds – The number of Rounds is regularly considered in design
criteria, it just reflects the number of rounds to be suitable for an algorithm to
make it more complex, in DES we have 16 rounds ensuring it to be more secure
while in AES we have 10 rounds which makes it more secure.
2. Design of function F – The core part of the Feistel Block cipher structure is the
Round Function. The complexity of cryptanalysis can be derived from the Round
function i.e. the increasing level of complexity for the round function would be
greatly contributing to an increase in complexity. To increase the complexity of
the round function, the avalanche effect is also included in the round function, as
the change of a single bit in plain text would produce a mischievous output due
to the presence of avalanche effect.
3. Confusion and Diffusion: The cipher should provide confusion and diffusion to
make it difficult for an attacker to determine the relationship between the
plaintext and ciphertext. Confusion means that the ciphertext should be a
complex function of the key and plaintext, making it difficult to guess the key.
Diffusion means that a small change in the plaintext should cause a significant
change in the ciphertext, which makes it difficult to analyse the encryption
pattern.
4. Key Size: The key size should be large enough to prevent brute-force attacks. A
larger key size means that there are more possible keys, making it harder for an
attacker to guess the correct one. A key size of 128 bits is considered to be secure
for most applications.

Data encryption standard (DES)

DES is a block cipher and encrypts data in blocks of size of 64 bits each, which
means 64 bits of plain text go as the input to DES, which produces 64 bits of
ciphertext. The same algorithm and key are used for encryption and decryption, with
minor differences. The key length is 56 bits.

We have mentioned that DES uses a 56-bit key. Actually, The initial key consists of
64 bits. However, before the DES process even starts, every 8th bit of the key is
discarded to produce a 56-bit key. That is bit positions 8, 16, 24, 32, 40, 48, 56, and
64 are discarded.

DES is based on the two fundamental attributes of cryptography: substitution (also


called confusion) and transposition (also called diffusion). DES consists of 16 steps,
each of which is called a round. Each round performs the steps of substitution and
transposition. Let us now discuss the broad-level steps in DES.
 In the first step, the 64-bit plain text block is handed over to an initial
Permutation (IP) function.
 The initial permutation is performed on plain text.
 Next, the initial permutation (IP) produces two halves of the permuted block;
saying Left Plain Text (LPT) and Right Plain Text (RPT).
 Now each LPT and RPT go through 16 rounds of the encryption process.
 In the end, LPT and RPT are rejoined and a Final Permutation (FP) is performed
on the combined block
 The result of this process produces 64-bit ciphertext.
Initial Permutation (IP):
As we have noted, the initial permutation (IP) happens only once and it happens
before the first round. It suggests how the transposition in IP should proceed, as
shown in the figure. For example, it says that the IP replaces the first bit of the
original plain text block with the 58th bit of the original plain text, the second bit
with the 50th bit of the original plain text block, and so on.
This is nothing but jugglery of bit positions of the original plain text block. the same
rule applies to all the other bit positions shown in the figure.

As we have noted after IP is done, the resulting 64-bit permuted text block is divided
into two half blocks. Each half-block consists of 32 bits, and each of the 16 rounds,
in turn, consists of the broad-level steps outlined in the figure.
Step-1: Key transformation:
We have noted initial 64-bit key is transformed into a 56-bit key by discarding every
8th bit of the initial key. Thus, for each a 56-bit key is available. From this 56-bit
key, a different 48-bit Sub Key is generated during each round using a process called
key transformation. For this, the 56-bit key is divided into two halves, each of 28
bits. These halves are circularly shifted left by one or two positions, depending on
the round.
For example: if the round numbers 1, 2, 9, or 16 the shift is done by only one
position for other rounds, the circular shift is done by two positions. The number of
key bits shifted per round is shown in the figure.

After an appropriate shift, 48 of the 56 bits are selected.From the 48 we might obtain
64 or 56 bits based on requirement which helps us to recognize that this model is
very versatile and can handle any range of requirements needed or provided. for
selecting 48 of the 56 bits the table is shown in the figure given below. For instance,
after the shift, bit number 14 moves to the first position, bit number 17 moves to the
second position, and so on. If we observe the table , we will realize that it contains
only 48-bit positions. Bit number 18 is discarded (we will not find it in the table),
like 7 others, to reduce a 56-bit key to a 48-bit key. Since the key transformation
process involves permutation as well as a selection of a 48-bit subset of the original
56-bit key it is called Compression Permutation.

Because of this compression permutation technique, a different subset of key bits is


used in each round. That makes DES not easy to crack.
Step-2: Expansion Permutation:
Recall that after the initial permutation, we had two 32-bit plain text areas called
Left Plain Text(LPT) and Right Plain Text(RPT). During the expansion permutation,
the RPT is expanded from 32 bits to 48 bits. Bits are permuted as well hence called
expansion permutation. This happens as the 32-bit RPT is divided into 8 blocks,
with each block consisting of 4 bits. Then, each 4-bit block of the previous step is
then expanded to a corresponding 6-bit block, i.e., per 4-bit block, 2 more bits are
added.

This process results in expansion as well as a permutation of the input bit while
creating output. The key transformation process compresses the 56-bit key to 48 bits.
Then the expansion permutation process expands the 32-bit RPT to 48-bits. Now
the 48-bit key is XOR with 48-bit RPT and the resulting output is given to the next
step, which is the S-Box substitution.

Triple DES:
Triple DES is a encryption technique which uses three instance of DES on same
plain text. It uses there different types of key choosing technique in first all used
keys are different and in second two keys are same and one is different and in third
all keys are same.

Group
A group (G) is indicated by {G,∙}. It is a group of elements with a binary
operation ′ ∙ ′ that satisfies four properties. The properties of Group are as
follows −

 Closure − If a and b are elements of G, therefore c = a ∙ b is also an element of set G.


This can define that the result of using the operations on any two elements in the set is
another element in the set.
 Associativity − If a, b, and c are element of G, therefore (a ∙ b) ∙ c = a ∙ (b ∙ c), means it
does not substance in which order it can use the operations on higher than two elements.
 Identity − For all a in G, there occur an element e in G including e ∙ a = a ∙ e = a.
 Inverse − For each a in G, there occur an element a’ known as the inverse of a such that a
∙ a′ = a′ ∙ a = e.
 A group is an abelian group if it satisfies the following four properties
more one additional property of commutativity.
 Commutativity − For all a and b in G, we have a ∙ b = b ∙ a.

Ring − A ring R is indicated by {R, +, x}. It is a set of elements with two


binary operations, known as addition and multiplication including for all a, b,
c in R the following axioms are kept −

 (R,+) is an abelian group


 (R,×) Closure under multiplication −
 (R,×) Associative
 (R,+,×): Distributive Laws −
a× (b+c)=a×b + a×c for all a, b, c in R
(a+b) ×c=a×c+b×c for all a, b, c in R

Commutative Ring a×b=b×a for all a, b in R.

Field − A field F is indicated by {F, +, x}.


If a Commutative ring have multiplicative inverse of all its elements except 0
then it is called a field.

Euclid's GCD Algorithm


• an efficient way to find the GCD(a,b)
• uses theorem that: – GCD(a,b) = GCD(b, a mod b)

• Euclid's Algorithm to compute GCD(a,b): – A=a, B=b – while B>0

• R = A mod B
• A = B, B = R
• return A
 Example GCD(1970,1066)

GCD(1970,1066) = 2

Modular Arithmetic

Modular Addition:
Rule for modular addition is:
(a + b) mod m = ((a mod m) + (b mod m)) mod m
Example:
(15 + 17) % 7
= ((15 % 7) + (17 % 7)) % 7
= (1 + 3) % 7
= 4 % 7
= 4

Modular Multiplication:
The Rule for modular multiplication is:
(a x b) mod m = ((a mod m) x (b mod m)) mod m
Example:
(12 x 13) % 5
= ((12 % 5) x (13 % 5)) % 5
= (2 x 3) % 5
= 6 % 5
= 1
Modular Inverse:
The modular inverse of a mod m exists only if a and m are relatively prime i.e.
gcd(a, m) = 1. Hence, for finding the inverse of an under modulo m, if (a x b) mod m
= 1 then b is the modular inverse of a.
Example: a = 5, m = 7 (5 x 3) % 7 = 1 hence, 3 is modulo inverse of 5 under 7.

Modulus of Negative Numbers


Problem: What is -7 mod 5?
Solution: To find -7 mod 5, we firstly find the largest number that is less than or
equal to -7 and divisible by 5. That number is -10. Now, in order to get remainder
subtract -10 from -7, which gives 3 that is the remainder. Thus the least positive
integer that should be subtracted from -7 to make it divisible by 5 is 3.
Hence the remainder comes out to be 3.

You might also like