Documente Academic
Documente Profesional
Documente Cultură
Ashutosh Bhatia
BITS Pilani
ashutosh.bhatia@pilani.bits-pilani.ac.in
Set of Integers and CRYPTO
The set of integers, denoted by Z, contains all integral numbers (with
no fraction) from negative infinity to positive infinity
𝑍 = . . . , −2, −1, 0, 1, 2, . . .
Is subtraction closed on 𝒁+ ?
Binary Operation Properties
Commutativity
∀ 𝑎, 𝑏 ∈ 𝑆, 𝑎 ∘ 𝑏 = 𝑏 ∘ 𝑎
Associativity
∀ 𝑎, 𝑏, 𝑐 ∈ 𝑆, 𝑎 ∘ 𝑏 ∘ 𝑐 = (𝑎 ∘ 𝑏) ∘ 𝑐
Example:
O∶ 𝑍 ×𝑍 →𝑍
𝑎 ∘ 𝑏 = 𝑎 + 𝑏 − 3𝑎𝑏
Constants
Identity element: 𝑥 ∘ 1 = 1 ∘ 𝑥 = 𝑥 (right and left identities)
Example
Identity for < 𝑁, 𝑚𝑎𝑥 > =
Zero for < 𝑁, 𝑚𝑖𝑛 > =
Zero for < 𝑍 + , 𝑚𝑖𝑛 > =
∘ a b c
Homework: Find out left identity and
a a b b
right zero for the given relation b a b c
c a b a
Semigroups, Monoids and Groups
Semigroup: < 𝑆,∘>
∀a, b, c ∈ S a ∘ b ∘ c = a ∘ b ∘ c
Ex: Set of strings of length at least one, over string concatenation
∀a, b, c ∈ S a + b + c = a + b + c
∀𝑎 ∈ 𝑆 𝑎 + 0 = 0 + 𝑎 = 𝑎
∀𝑎 ∈ 𝑆, ∃ 𝑎−1 ∈ 𝑆 𝑎 + 𝑎−1 = 𝑎−1 + 𝑎 = 0
∀𝑎, 𝑏 ∈ 𝑆, 𝑎 + 𝑏 = 𝑏 + 𝑎
∀𝑎, 𝑏, 𝑐 ∈ 𝑆, 𝑎 . 𝑏 . 𝑐 = 𝑎 . 𝑏. 𝑐
∀𝑎, 𝑏, 𝑐 ∈ 𝑆 𝑎 . 𝑏 + 𝑐 = 𝑎. 𝑏 + 𝑎. 𝑐
Fields
Field: < 𝑆, +, . 0, 1 >
All properties of rings
∀𝑎, 𝑏 ∈ 𝑆 𝑎 . 𝑏 = 𝑏. 𝑎
∀𝑎, ∈ 𝑆 𝑎 . 1 = 1. 𝑎 = 𝑎
∀𝑎 ∈ 𝑆, ∃ 𝑎−1 ∈ 𝑆 𝑎 . 𝑎−1 = 𝑎−1 . 𝑎 = 1
Alternate Definition:
<S, +> is an additive abelian group
<S – {0}, . > is a multiplicative abelian group
∀𝑎, 𝑏, 𝑐 ∈ 𝑆 𝑎 . 𝑏 + 𝑐 = 𝑎. 𝑏 + 𝑎. 𝑐
Ex: Let us define a GF(22) field in which the set has four 2-bit words:
{00, 01, 10, 11}. We can redefine addition and multiplication for this
field in such a way that all properties of these operations are satisfied.
Divisors
An integer 𝑏 ≠ 0 is a divisor of 𝑎 if 𝑎 = 𝑚𝑏, where 𝑎, 𝑏 and 𝑚 are integers.
Notation: 𝑏|𝑎 is used to define that b is a divisor of s or b divides a.
Properties:
If 𝑎|1, then 𝑎 = ±1
If 𝑎|𝑏 and 𝑏|𝑎 then 𝑏 = ±𝑎
Any 𝑏 ≠ 0 divides 0
For any integer 𝑎, 1/a
If 𝑟| 𝑎 + 𝑏 and 𝑟|𝑎 then 𝑟|𝑏 (prove it !)
If 𝑏|𝑔 and 𝑏|h then 𝑏|(𝑚𝑔 + 𝑛ℎ) for arbitrary integers m and n (prove it !)
Quotients and Remainders
Given any positive integer 𝑛 and an integer 𝑎, we get a quotient and remainder 𝑟 such
that 𝑎 = 𝑞𝑛 + 𝑟, 0 ≤ 𝑟 ≤ 𝑛 and q = 𝑎/𝑛 , where 𝑥 is the largest integer less than
or equal to x.
Exercise: a = -5 and n=2
For any integer 𝑎 and 𝑛 ≥ 1, 𝑟 and 𝑞 are unique.
Remainder 𝑟 is also known as residue and defined to be a mod n.
𝑎 = 𝑞𝑛 + 𝑟 can be rewritten as 𝑎 = 𝑎/𝑛 𝑛 + 𝑎 𝑚𝑜𝑑 𝑛
Greatest Common Divisor (GCD)
Greatest Common Divisor (GCD) of two integers 𝑎 and 𝑏 denoted as gcd(𝑎, 𝑏) is defined as
positive integer that satisfies gcd 𝑎, 𝑏 = max{𝑘: 𝑘 𝑎 & 𝑘 𝑏}
GCD Theorem: Let 𝑎; 𝑏 be nonzero integers. Let 𝑔 = gcd(a,b). Then there exist integers 𝑠
and 𝑡 and such that 𝑔 = 𝑎𝑠 + 𝑏𝑡 (Homework)
Euclidean Algorithm : gcd (a, 0) = a; gcd (a, b) = gcd (b, r), where r is the remainder of
dividing a by b
The extended Euclidean algorithm can calculate the gcd (a, b) and at the same time
calculate the value of s and t.
Euclidean Algorithm
• an efficient way to find the GCD(a,b)
EUCLID(a,b)
1. A = a; B = b
2. if B = 0 return A = gcd(a, b)
3. R = A mod B
4. A = B
5. B = R
6. goto 2
Example GCD(1970,1066)
1970 = 1 x 1066 + 904 gcd(1066, 904)
1066 = 1 x 904 + 162 gcd(904, 162)
904 = 5 x 162 + 94 gcd(162, 94)
162 = 1 x 94 + 68 gcd(94, 68)
94 = 1 x 68 + 26 gcd(68, 26)
68 = 2 x 26 + 16 gcd(26, 16)
26 = 1 x 16 + 10 gcd(16, 10)
16 = 1 x 10 + 6 gcd(10, 6)
10 = 1 x 6 + 4 gcd(6, 4)
6 = 1 x 4 + 2 gcd(4, 2)
4 = 2 x 2 + 0 ?????????
GCD
Modular Arithmetic
If 𝑎 = 𝑞𝑛 + 𝑟, then 𝑎 𝑚𝑜𝑑 𝑛 = ?
𝑎 𝑚𝑜𝑑 𝑛 is always an integer 𝑘 such that 0 ≤ 𝑘 ≤ 𝑛 − 1.
Hence, we can have arithmetic in the set of integers 0,1,2, … … 𝑛 − 1 in
which all arithmetic operators are modulo 𝑛.
Therefore, the result will always be in the set 0,1,2, … … 𝑛 − 1 .
The set 0,1,2, … … 𝑛 − 1 is referred as residue modulo 𝑛 and it is denoted
by 𝑍𝑛 .
Modular Arithmetic: Properties
1. a + b mod n = a mod n + b mod n mod n
2. a − b mod n = a mod n − b mod n mod n
3. ab mod n = a mod n ) (b mod n mod n (𝐻𝑜𝑚𝑒𝑤𝑜𝑟𝑘)
4. Commutative, Associate, Distributive
5. Identities
1. 0 + 𝑎 𝑚𝑜𝑑 𝑛 = 𝑎 𝑚𝑜𝑑 𝑛
2. 1 ∗ 𝑎 𝑚𝑜𝑑 𝑛 = 𝑎 𝑚𝑜𝑑 𝑛
Congruent Modulo Operator (≡)
An integer 𝑎 is congruent to and integer 𝑏 modulo 𝑛, denoted by
Additive Inverse:
𝑎, 𝑏 ∈ 𝑍𝑛, , then 𝑏 would be the additive inverse of 𝑎 if 𝑎 + 𝑏 𝑚𝑜𝑑 𝑛 = 0.
denoted as −𝑎
𝑎 + 𝑏 ≡ 0 𝑚𝑜𝑑 𝑛
In modular arithmetic ∀𝑎 ∈ 𝑍𝑛 , ∃ − 𝑎 ∈ 𝑍𝑛 𝑠. 𝑡. 𝑎 + 𝑏 𝑚𝑜𝑑 𝑛 = 0.
Find all additive inverse pairs in 𝑍8 .
Multiplicative Inverse:
𝑎, 𝑏 ∈ 𝑍𝑛, , then 𝑏 would be the multiplicative inverse of 𝑎 if 𝑎 ∗ 𝑏 𝑚𝑜𝑑 𝑛 = 1.
denoted as −𝑎
𝑎 ∗ 𝑏 ≡ 1 𝑚𝑜𝑑 𝑛
In modular arithmetic ~∀ 𝑎 ∈ 𝑍𝑛 , ∃ − 𝑎 ∈ 𝑍𝑛 𝑠. 𝑡. 𝑎 ∗ 𝑏 𝑚𝑜𝑑 𝑛 = 1.
Find all multiplicative inverse pairs in 𝑍8 .
Example: Addition Modulo 8
0 1 2 3 4 5 6 7
+
0 0 1 2 3 4 5 6 7
1 1 2 3 4 5 6 7 0
2 2 3 4 5 6 7 0 1
3 3 4 5 6 7 0 1 2
4 4 5 6 7 0 1 2 3
5 5 6 7 0 1 2 3 4
6 6 7 0 1 2 3 4 5
7 7 0 1 2 3 4 5 6