07.07.2023 Views

Implementing-cryptography-using-python

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

106 Chapter 4 ■ Cryptographic Math and Frequency Analysis

while not is_prime(p, 128):

p = generate_prime_candidate(length)

return p

print('Generate the value of n using two prime numbers p and q:')

print('\n')

print(generate_prime_number())

print('\n')

Figure 4.2: Generate_large_primes.py

Basic Group Theory

In abstract algebra and other fields of mathematics, group theory studies the

algebraic structures known as groups. The concept of a group is central to abstract

algebra: other familiar algebraic structures, such as vector spaces, rings, and fields,

can all perform as groups endowed with additional operations and axioms. Group

theory comes into play as you explore the Diffie-Hellman and RSA encryption

systems in Chapter 8. For now, consider the idea that elements in groups (e.g.,

integers) have orders (i.e., cycle lengths), and this lets you use modular arithmetic

to speed up significant computations. Group theory is exploited to build cryptographic

schemes and the associated cryptanalysis.

To start your exploration into the basics of group theory, we define a group

as a set, G, together with a binary operation * (called the group law of G) that

combines any two elements to form another element. The operation may be multiplication,

addition, rotation, composition, or any other action that consumes

two elements and returns one.

To be eligible as a group, the set and operation (G, *) requires four properties,

known as the group axioms.

■■

Closure: a, b ∈ G implies a * b ∈ G

■■

Identity: There exists e ∈ G such that a * e = e * a = a for all a ∈ G

■■

Inverse: For each a ∈ G, there exists a −1 ∈ G such that a * a −1 = a −1 * a = e

■■

Associativity: a, b, c ∈ G implies (a * b) * c = a* (b * c)

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!