Showing posts with label Euclidean Algorithm. Show all posts
Showing posts with label Euclidean Algorithm. Show all posts

Monday, May 29, 2017

Cryptography: Galois Field GF(p)

How Do We Know That GF(23) Is A Finite Field?
•We do know that GF (23) is an abelian group because of the operation of polynomial addition satisfies all of the requirements on a group operator and because polynomial addition is commutative.

•GF (23) is also a commutative ring because polynomial multiplication distributes over polynomial addition

–polynomial multiplication meets all the other stipulations on the ring operator: closedness, associativity, commutativity

•

•GF (23) is an integral domain because of the fact that the set contains the multiplicative identity element 1 and because if for a ∈ GF(23) and b ∈ GF(23) we have

  a×b = 0 mod(x3+x+1)

•Then either a = 0 or b = 0.

•We now argue that GF (23) is a finite field because it is a finite set and because it contains a unique multiplicative inverse for every non-zero element.

•GF (23) contains a unique multiplicative inverse for every non- zero element for the same reason that Z7 contains a unique multiplicative inverse for every non-zero integer in the set.

–For a counter example, recall that Z8 does not possess multiplicative inverses for 2, 4, and 6.

–Stated formally, we say that for every non-zero element a ∈ GF(23) there is always a unique element b∈GF(23) such that a×b = 1.


•The above conclusion follows from the fact if you multiply a non-zero element a with each of the eight elements of GF(23), the result will be the eight distinct elements of GF(23).

–Obviously, the results of such multiplications must equal 1 for exactly one of the non-zero element of GF(23).

–So if a×b = 1, then b must be the multiplicative inverse for a.

•

•The same thing happens in Z7. If you multiply a non-zero element a of this set with each of the seven elements of Z7, you will get seven distinct answers.

–The answer must therefore equal 1 for at least one such multiplication. When the answer is 1, you have your multiplicative inverse for a.

•For a counter example, this is not what happens in Z8. When you multiply 2 with every element of Z8, you do not get eight distinct answers.

–Multiplying 2 with every element of Z8 yields {0, 2, 4, 6, 0, 2, 4, 6} that has only four distinct elements


 

•For a more formal proof (by contradiction) of the fact that if you multiply a non-zero element a of GF(23) with every element of the same set, no two answers will be the same, let’s assume that this assertion is false. That is, we assume the existence of two distinct b and c in the set such that

a × b ≡ a × c mod (x3 + x + 1)

That implies

a×(b−c) ≡ 0 mod (x3+x+1)

•That implies that either a is 0 or that b equals c. In either case, we have a contradiction.

•The upshot is that GF (23) is a finite field.
GF(2n) Is A Finite Field For Every N 

•GF(2n) is a finite field for every n.

•To find all the polynomials in GF (2n), we obviously need an irreducible polynomial of degree n.

•AES arithmetic is based on GF (28). It uses the following irreducible polynomial

x8 +x4 +x3 +x+1


•In general, GF(pn) is a finite field for any prime p.

–The elements of GF(pn) are polynomials over GF(p)

–which is the same as the set of residues Zp

Finding the Multiplicative Inverse  

•Just as the Euclidean algorithm can be adapted to find the greatest common divisor of two polynomials, the extended Euclidean algorithm can be adapted to find the multiplicative inverse of a polynomial.

•

•Specifically, the algorithm will find the multiplicative inverse of b(x) modulo a(x) if the degree of b(x) is less than the degree of a(x) and gcd[a(x), b(x)] = 1.

•

•If a(x) is an irreducible polynomial, then it has no factor other than itself or 1, so that gcd[a(x), b(x)] = 1.

•Given polynomials a(x) and b(x) with the degree of a(x) greater than the degree of b(x), we solve the following equation for the values v(x), w(x), and d(x), where d(x) = gcd[a(x), b(x)]:

  a(x)v(x) + b(x)w(x) = d(x)

•If d(x) = 1, then w(x) is the multiplicative inverse of b(x) modulo a(x).

•The calculations are as follows.


 

Saturday, May 27, 2017

Cryptography: The Euclidean Algorithm

The Euclidean Algorithm finds the greatest common divisor of two integers a and b.

For example,
If we want to find gcd(287, 91), we divide 287 by 91:

                            287 = 91*3 + 14

We know that for integers a, b and c, if a | b and a | c, then a | (b + c).

Therefore, any divisor of 287 and 91 must also be a divisor of 287 - 91*3 = 14.

Consequently, gcd(287, 91) = gcd(14, 91).

In the next step, we divide 91 by 14:

91 = 14*6 + 7

This means that gcd(14, 91) = gcd(14, 7).

So we divide 14 by 7:

14 = 7*2 + 0
We find that 7 | 14, and thus gcd(14, 7) = 7.

Therefore, gcd(287, 91) = 7.

So, what is gcd( 70, 38 )?

------------------------------------------------------------------------------------------------------------------------
The Euclidean algorithm can be based on the following theorem: For any nonnegative integer a and any positive integer b,
            gcd(a, b) = gcd(b, a mod b)
        gcd(55, 22) = gcd(22, 55 mod 22) = gcd(22, 11) = 11

Wednesday, March 22, 2017

Cryptography: Number Theory - Euclidean Algorithm


Euclidean Algorithm 
•One of the basic techniques of number theory is the Euclidean algorithm, which is a simple procedure for determining the greatest common divisor of two positive integers.

•Relative Prime

•Two integers are relatively prime if their only common positive integer factor is 1.
Relatively Prime Integers 
Definition:
Two integers a and b are relatively prime if gcd(a, b) = 1.

Examples:
•Are 15 and 28 relatively prime?
–Yes, gcd(15, 28) = 1.
•Are 55 and 28 relatively prime?
–Yes, gcd(55, 28) = 1.
•Are 35 and 28 relatively prime?
–No, gcd(35, 28) = 7.
 
Coursera AH Purple Design 2 Coursera General Design 2 Green Coursera Data Science

Greatest Common Divisor  


•Let a and b be integers, not both zero.
•The largest integer d such that d | a and d | b is called the greatest common divisor of a and b.
•The greatest common divisor of a and b is denoted by gcd(a, b).
•
•Example 1: What is gcd(48, 72) ?
–The positive common divisors of 48 and 72 are
1, 2, 3, 4, 6, 8, 12, 16, and 24, so
gcd(48, 72) = 24.
•Example 2: What is gcd(19, 72) ?
–The only positive common divisor of 19 and 72 is
1, so
gcd(19, 72) = 1.