Foundations of Security Week3 Lecture

1180 字
6 分钟
Foundations of Security Week3 Lecture

Fermat’s Theorem and Euler’s Theorem#

Lecture Outline#

  1. Introduction to Fermat’s Theorem
  2. Conditions for applying Fermat’s Theorem
  3. Examples of Fermat’s Theorem in modular arithmetic
  4. Introduction to Euler’s Totient Function and computing totient values
  5. Introduction to Euler’s Theorem
  6. Conditions for applying Euler’s Theorem

Learning Outcomes#

By the end of this lecture, students should be able to:

  1. Explain the concept of Fermat’s Theorem
  2. Identify the conditions required to apply Fermat’s Theorem
  3. Apply Fermat’s Theorem to simplify modular exponentiation
  4. Define Euler’s Totient Function & Calculate the totient value of a number
  5. Apply Euler’s Theorem to solve modular exponentiation problems

Fermat’s Theorem#

Before discussing what Fermat’s Theorem entails, consider the calculation of 213522mod523213^{522}\bmod523. This might seem difficult due to the size of the numbers, but with Fermat’s Theorem, we can find a simple solution.

The Magic of Fermat’s Theorem:
The result of 213522mod523\textcolor{blue}{213^{522}\bmod523} is 1.

Applying Fermat’s Theorem:
Fermat’s Theorem states that if p is a prime number and a is an integer not divisible by p, then ap11modp\textcolor{red}{a^{p-1} \equiv 1 \bmod p} Given 523 is a prime number, any number raised to 522 (which is 523-1) modulo 523 will result in 1, according to Fermat’s Theorem. a5221mod523\textcolor{blue}{a^{522}\equiv1\bmod523}

This property exemplifies the theorem’s practicality, showing that even without direct calculation, we can determine that 213522mod523=1\textcolor{blue}{213^{522} \bmod 523 = 1} because 213522\textcolor{blue}{213^{522}} is congruent to 1522mod523\textcolor{blue}{1^{522}}\bmod\textcolor{blue}{523}, which simplifies to 1.


Preconditions for Applying Fermat’s Theorem:

  • Check if p is a prime number: Fermat’s Theorem only applies if p is prime.
  • Ensure a is not divisible by p: a must be an integer that p does not divide for the theorem to hold.
    If these conditions are met, then ap11modp\textcolor{red}{a^{p-1} \equiv 1 \bmod p}

Example:
Let a=2 and p=3. Since p is prime and a is not divisible by p, we can apply Fermat’s Theorem.
Calculation:
Compute 231mod3\textcolor{blue}{2^{3-1}\bmod3}:
22=4\textcolor{blue}{2^2 = 4}
4mod3=1\textcolor{blue}{4\bmod3 = 1}
Result:
As expected, 231mod3=1\textcolor{blue}{2^{3-1}\bmod3 = 1}, proving the theorem’s validity in this case.


Example Application
Given: a = 2, p = 11
Objective: Verify the conditions and apply Fermat’s Theorem.
Conditions:
p should be a prime number.
a should not be divisible by p.
Solution: p = 11 is a prime number. a = 2 is not divisible by 11. These conditions allow us to apply Fermat’s Theorem, which states ap11modp\textcolor{red}{a^{p-1} \equiv 1 \bmod p}.


Example (confirming)
Compute: 2111mod11\textcolor{blue}{2^{11-1}\bmod11}
210mod11\textcolor{blue}{2^{10}\bmod11}
Calculating 210=1024\textcolor{blue}{2^{10} = 1024}
1024mod11=1\textcolor{blue}{1024\bmod11 = 1}
Result: 210mod11=1\mathbf{2^{10}\bmod11 = 1}, confirming the theorem.

Euler’s Totient Function#

Introduction:
Euler’s totient function, denoted as φ(n)\textcolor{blue}{\varphi(n)}, counts the number of integers between 1 and nn inclusive that are co-prime to nn. This means they share no common divisors with nn other than 1.

Formula: φ(n)={xN:1x<n and gcd(x,n)=1}\varphi(n) = \{x \in \mathbb{N} : 1 \le x < n \text{ and } \gcd(x,n) = 1\}

Example Calculation - φ(6)\mathbf{\varphi(6)}:

  • Consider the integers from 1 to 6: {1, 2, 3, 4, 5, 6}.
  • Determine which numbers are co-prime to 6 by checking if their gcd with 6 is 1:

gcd(1,6)=1\gcd(1,6) = 1
gcd(2,6)=2\gcd(2,6) = 2 (not co-prime)
gcd(3,6)=3\gcd(3,6) = 3 (not co-prime)
gcd(4,6)=2\gcd(4,6) = 2 (not co-prime)
gcd(5,6)=1\gcd(5,6) = 1
gcd(6,6)=6\gcd(6,6) = 6 (not co-prime)

Result:

  • Only 1 and 5 are co-prime to 6.
  • Therefore, φ(6)=2\textcolor{red}{\varphi(6) = 2}.

Exercise:

  • Find the value of φ(9)\mathbf{\varphi(9)}.
  • Find the value of φ(12)\mathbf{\varphi(12)}.

Properties of Euler’s Totient Function:

  • Prime Numbers: If pp is a prime number, gcd(p,q)=1\gcd(p,q) = 1 for all 1q<p1 \le q < p. Thus, φ(p)=p1\textcolor{blue}{\varphi(p) = p-1}.
  • Power of Primes: For a prime number pp and any integer k1\textcolor{blue}{k \ge 1}, exactly pk1\mathbf{ p^{k-1} } numbers between 1 and pk\mathbf{p^k} are divisible by p\mathbf{p}. This results in: φ(pk)=pkpk1\textcolor{blue}{ \varphi(p^k)= p^k - p^{k-1} }.
  • Product of Co-prime Numbers: If a\textcolor{blue}{a} and b\textcolor{blue}{b} are relatively prime, then φ(ab)=φ(a)φ(b)\textcolor{blue}{\varphi(ab) = \varphi(a) \cdot \varphi(b)}

First Property of Euler’s Totient Function:

  • Prime Numbers: If pp is a prime number, gcd(p,q)=1\gcd(p,q)=1 for all 1q<p1 \le q < p. Thus, φ(p)=p1\textcolor{blue}{\varphi(p) = p-1}. Example: Understanding φ(5)\mathbf{\varphi(5)} through simple computation:
  • The set {1,2,3,4,5} includes integers less than 5.
  • gcd(1,5)=gcd(2,5)=gcd(3,5)=gcd(4,5)=1\mathbf{\gcd(1,5) = \gcd(2,5) = \gcd(3,5) = \gcd(4,5) = 1}; gcd(5,5)=5\gcd(5,5)=5.
  • Thus, four numbers are co-prime with 5, resulting in φ(5)=4\mathbf{\varphi(5)=4}.

Clarification using φ(23)\mathbf{\varphi(23)}:

  • For prime number 23, every number from 1 to 22 is co-prime with 23.
  • Thus, φ(23)=231=22\mathbf{\varphi(23)= 23 - 1 = 22}.

Second Property of Euler’s Totient Function:

  • Power of Primes: For a prime number p\textcolor{blue}{p} and any integer k1\textcolor{blue}{k \ge 1}, exactly pk1p^{k-1} numbers between 1 and pk\mathbf{p^k} are divisible by p\mathbf{p}. This results in: φ(pk)=pkpk1\textcolor{blue}{ \varphi(p^k)= p^k - p^{k-1} }.

Example: Calculate φ(23)\mathbf{\varphi(2^3)}:

  • Theorem: From φ(pk)=pkpk1\textcolor{blue}{ \varphi(p^k)= p^k - p^{k-1} }, for p=2\mathbf{p=2} and k=3\mathbf{k=3}, we have:
    φ(23)=23231=84=4\mathbf{\varphi(2^3) = 2^3 - 2^{3-1} = 8 - 4 = 4}
  • Verification: Considering the set {1, 2, 3, 4, 5, 6, 7, 8}, the numbers co-prime with 8 are 1, 3, 5, 7.
  • The gcd\gcd of 1, 3, 5, 7 with 8 is 1, confirming that φ(8)=4\textcolor{red}{\varphi(8) = 4}.

Third Property of Euler’s Totient Function:

  • Product of Co-prime Numbers: If a\textcolor{blue}{a} and b\textcolor{blue}{b} are relatively prime, then φ(ab)=φ(a)φ(b)\textcolor{blue}{\varphi(ab) = \varphi(a) \cdot \varphi(b)}.
  • Example: Calculate φ(15)\mathbf{\varphi(15)} where a=3\mathbf{a = 3} and b=5\mathbf{b = 5} (since gcd(3,5)=1\gcd(3,5)=1, 3 and 5 are relatively prime):
  • Calculation: From the properties, φ(15)=φ(3)φ(5)=(31)(51)=24=8\mathbf{\varphi(15) = \varphi(3) \cdot \varphi(5) = (3-1) \cdot (5-1) = 2 \cdot 4 = 8}

Important Note: a\textcolor{blue}{a} and b\textcolor{blue}{b} must be distinct and co-prime for this property to apply.
For instance, φ(49)\mathbf{\varphi(49)}, which is 72\mathbf{7^2}, should be calculated using the property for prime powers, not as φ(7)φ(7)\mathbf{\varphi(7) \cdot \varphi(7)}:

  • Correct Approach: Using the second property, φ(49)=φ(72)=72721=497=42\mathbf{ \varphi (49) = \varphi(7^2) = 7^2 - 7^{2-1} = 49 - 7 = \textcolor{red}{42} }

  • Product of Co-prime Numbers: If a\textcolor{blue}{a} and b\textcolor{blue}{b} are relatively prime, then φ(ab)=φ(a)φ(b)\textcolor{blue}{\varphi(ab) = \varphi(a) \cdot \varphi(b)}.

Another Example: Calculate φ(6)\varphi(6), where 6=2×36=2\times3:
Calculation: Since 2 and 3 are co-prime, φ(6)=φ(2)φ(3)=12=2\mathbf{ \varphi(6)= \varphi(2) \cdot \varphi(3) = 1 \cdot 2 = \textcolor{red}{2} }


Assignment: Complete these exercise and submit during seminar class

  • Calculate the Euler’s Totient Function φ(n)\varphi(n) for the given numbers:
  1. φ(20)\varphi(20)
  2. φ(21)\varphi(21)
  3. φ(19)\varphi(19)
  4. φ(95)\varphi(95)
  5. φ(55)\varphi(55)
  6. φ(29)\varphi(29)
  7. φ(101)\varphi(101)
  8. φ(47)\varphi(47)

Show how you computed your answers.
Only handwritten solutions.
No copy-paste will be accepted.

Euler’s Theorem#

  • It states that if a\textcolor{blue}{a} and m\textcolor{blue}{m} are co-prime (i.e., gcd(a,m)=1\mathbf{\gcd(a,m)=1}), then aa raised to the power of Euler’s totient function φ(m)\mathbf{\varphi(m)} is congruent to 1 modulo mm: aφ(m)1modm\textcolor{red}{a^{\varphi(m)} \equiv 1 \bmod m} For the given example where a=3\mathbf{a=3} and m=10\mathbf{m=10}:
  • Checking if co-prime:
    • The gcd of 3 and 10 is 1, which confirms that 3 and 10 are co-prime.
  • Apply Euler’s Theorem:
    • We first calculate φ(10)\mathbf{\varphi(10)}, where 10=2×5\mathbf{10 = 2 \times 5}, and using the formula for Euler’s Totient function,
    • Calculation of φ(10)\varphi(10): Since 10 is the product of two distinct prime numbers, φ(10)\varphi(10) is calculated as:
      φ(ab)=φ(a)φ(b)\mathbf{\varphi(ab) = \varphi(a) \cdot \varphi(b)}
      φ(10)=φ(2)φ(5)=(21)(51)=1×4=4\mathbf{\varphi(10) = \varphi(2) \cdot \varphi(5) = (2-1) \cdot (5-1) = 1 \times 4 = 4}
    • Now from aφ(m)1modm\textcolor{red}{a^{\varphi(m)} \equiv 1 \bmod m} we show that 341mod10\textcolor{red}{3^4 \equiv 1 \bmod 10}
      34mod10=81mod10=1mod103^4\bmod10 = 81\bmod10 = 1\bmod10 This confirms that 341mod10\mathbf{3^4\equiv1\bmod10}, thus validating Euler’s Theorem.

Assignment#

Complete this exercise and submit during seminar class
Find a number between 0 and 16 congruent to 5234mod17\textcolor{red}{5^{234}\bmod17} using Fermat’s Little Theorem and Modular Exponentiation.

支持与分享

如果这篇文章对你有帮助,欢迎分享给更多人或赞助支持!

赞助
Foundations of Security Week3 Lecture
https://firefly.anka2.top/posts/obu/level5/semester2/fos/week3/lecture/
作者
🐦‍🔥不死鸟Anka
发布于
2026-03-24
许可协议
CC BY-NC-SA 4.0

评论区

Profile Image of the Author
A-n-k-a
Over the Frontier / Into the Front
看这里~
合作翻译官绝赞招募中!
音乐
封面

音乐

暂未播放

0:00 0:00
暂无歌词
分类
标签
站点统计
文章
59
分类
6
标签
20
总字数
550,118
运行时长
0
最后活动
0 天前

目录