Presentation is loading. Please wait.

Presentation is loading. Please wait.

第4章 有限體.

Similar presentations


Presentation on theme: "第4章 有限體."— Presentation transcript:

1 第4章 有限體

2 簡介 有限體在密碼學日漸益重要 許多密碼學演算法,都很依賴有限體的特性,尤其是進階加密標準(AES)和橢圓曲線密碼學
群(groups)、環(rings)、和體(fields)是抽象代數或現代代數的基本要素 在抽象代數中,我們關心的是哪些集合元素可以代數運算

3 群 「群」(有時表示成{G,‧})是內含二元運算的元素集合
請問{N, +}是群嗎? 「群」(有時表示成{G,‧})是內含二元運算的元素集合 對G裡的每組元素(a, b)來說,(a‧b)也是G裡的元素(即符合封閉性closure) 還必須遵守: 結合性:(a.b).c = a.(b.c) 單位元素: e: e.a = a.e = a 反元素: a.a’= e 若 a.b = b.a 即為交換群(abelian group)

4 循環群Cyclic Group 將群的重複運算定義為群的指數運算: a3 = a.a.a 此外也定義:e=a0 和 a-n = (a’)n
請舉出一個循環群和其生成子! 將群的重複運算定義為群的指數運算: a3 = a.a.a 此外也定義:e=a0 和 a-n = (a’)n 假如G裡的每個元素都是某固定元素a的指數(可以為負),G就是循環群 a: generator (產生器) 循環群必為交換群,而且可能是有限群或無限群 Define exponentiation in a group as the repeated use of the group operator. Note that we are most familiar with it being applied to multiplication, but it is more general than that. If the repeated use of the operator on some value a in the group results in every possible value being created, then the group is said to be cyclic, and a is a generator of (or generates) the group G.

5 環(ring) 含兩個二元運算(加法和乘法)的數值 加法交換群: 若滿足乘法交換性,即為交換環 整數域(integral domain)
{Z, +, }是否為ring? 環(ring) {Z, +, }是否為integral domain? 含兩個二元運算(加法和乘法)的數值 加法交換群: 乘法封閉性 乘法結合性 分配律:a(b+c) = ab + ac 若滿足乘法交換性,即為交換環 整數域(integral domain) 乘法單位元素 0不可為除數 Next describe a ring. In essence, a ring is a set in which we can do addition, subtraction [a – b = a + (–b)], and multiplication without leaving the set. We denote a Ring as {R,+,.} With respect to addition and multiplication, the set of all n-square matrices over the real numbers form a ring. The set of integers with addition & multiplication form an integral domain.

6 體Field 「體」(有時表示成{F, +, ×})是具有兩個二元運算的元素集合 「體」是可以計算加法、減法、乘法、除法的集合
除法規則的定義是a/b = a( b-1) 「體」常見的例子包括了有理數、實數、複數

7 群、環、體

8 模數運算 若a 為整數、n 為正整數 將a mod n 的值定義為a 除n 的餘數 整數n稱為模數
若(a mod n ) =( b mod n ) 整數a、b是n的同餘 寫成a ≡ b(mod n) 11 mod 7 = ? -11 mod 7 = ?

9 除數 若b ≠ 0而a 、b 、m 皆為整數,且某個數值m能讓 a = mb 例如1,2,3,4,6,8,12,24都可以整除24
通常以b|a表示b 能整除a 而b也就是a的因數(divisor) 例如1,2,3,4,6,8,12,24都可以整除24

10 模數算術 若n|(a - b),a ≡ b(mod n) 若a ≡ b(mod n),b ≡a(mod n)
若a ≡ b(mod n)且b ≡ c(mod n),a ≡ c(mod n)

11 模數算術 Zn是小於n的非負整數集合: Zn = {0, 1, … , n-1}
一般運算所沒有的兩項特性: 若(a+b)=(a+c) mod n,則b=c mod n 但a、n 互為質數,且若(a.b)=(a.c) mod n,則b=c mod n

12 模數為8的模數加法運算 + 1 2 3 4 5 6 7 請畫出8的模數乘法運算

13 最大公因數(GCD) 數論的共同問題 若a、b、m為整數,對m來說,如果a = mb,非零的b就是a的因數
GCD(a, b)表示a和b的最大公因數;正整數c若符合以下兩點,就是a、b的最大公因數: c是a、b的因數 a、b的任何因數也是c的因數 例如GCD(60,24) = 12 若兩整數a、b只有正公因數1,則a、b互為質數 以等式表示即為 GCD(a, b) = 1 例如 GCD(8,15) = 1(8、15互為質數)

14 歐幾里德演算法 找出最大公因數的有效方法 對任何非負整數a和任何正整數b而言: 歐幾里德演算法計算最大公因數的方式:
GCD(a,b) = GCD(b, a mod 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

15 範例:GCD(1970,1066) 1970 = 1 x gcd(1066, 904) 1066 = 1 x gcd(904, 162) 904 = 5 x gcd(162, 94) 162 = 1 x gcd(94, 68) 94 = 1 x gcd(68, 26) 68 = 2 x gcd(26, 16) 26 = 1 x gcd(16, 10) 16 = 1 x gcd(10, 6) 10 = 1 x gcd(6, 4) 6 = 1 x gcd(4, 2) 4 = 2 x gcd(2, 0)

16 有限體(Finite Fields,Galois Fields)
有限體是加密的關鍵角色 我們可以證明有限體的級數(元素數目)必須是質數的乘冪,也就是pn(n為正整數) 級數Pn的有限體通常以GF(Pn)表示 經常使用: GF(p) GF(2n)

17 GF(p) 對質數p而言,級數p的有限體GF(p)定義成整數集合Zp {0, 1, …, p-1},以及算術運算模數p,會形成有限體
因為每個0以外的元素都含有乘法反元素! w 與p 互為質數,所以若將Zp的所有元素乘上w ,產生的餘數將會是所有Zp元素的重排,因此其中某個餘數必為1 Zp 裡的某些整數乘上w 之後的餘數為1。這種整數是w 的乘法反元素,稱為w-1,因此Zp 實際上就是有限體

18 GF(7) 乘法範例 1 2 3 4 5 6

19 找出乘法反元素 EXTENDED EUCLID(m, b) 1. (A1, A2, A3)=(1, 0, m);
(B1, B2, B3)=(0, 1, b) 2. if B3 = 0 return A3 = gcd(m, b); no inverse 3. if B3 = 1 return B3 = gcd(m, b); B2 = b–1 mod m 4. Q = A3 div B3 5. (T1, T2, T3)=(A1 – Q B1, A2 – Q B2, A3 – Q B3) 6. (A1, A2, A3)=(B1, B2, B3) 7. (B1, B2, B3)=(T1, T2, T3) 8. goto 2

20 GF(1759)裡的550乘法反元素 Q A1 A2 A3 B1 B2 B3 — 1 1759 550 3 –3 109 5 –5 16
1759 550 3 –3 109 5 –5 16 21 106 –339 4 –111 355

21 多項式運算 n 階多項式(polynomial)可表示為(整數n ≧ 0): 多項式運算分成三種不同類型:
f(x) = anxn + an-1xn-1 + … + a1x + a0 = ∑ aixi 多項式運算分成三種不同類型: 使用代數基本規則的一般多項式運算 將係數取p 同餘的多項式運算 係數是在GF(p)裡、而且定義成多項式m(x)同餘的多項式運算(m(x)的最高次方為整數n) Next introduce the interesting subject of polynomial arithmetic, using polynomials in a single variable x, with several variants as listed above. Note we are usually not interested in evaluating a polynomial for any particular value of x, which is thus referred to as the indeterminate.

22 一般多項式運算 這類多項式是以係數集合定義 多項式的加法和減法是以係數處理
例如 f(x) = x3 + x2 + 2且 g(x) = x2 – x + 1,那麼: f(x) + g(x) = x3 + 2x2 – x + 3 f(x) – g(x) = x3 + x + 1 f(x) x g(x) = x5 + 3x2 – 2x + 2 Polynomial arithmetic includes the operations of addition, subtraction, and multiplication, defined in the usual way, ie add or subtract corresponding coefficients, or multiply all terms by each other. The examples are from the text, with working in Stallings Figure 4.3.

23 係數在Zp的多項式運算 係數可以是「體」F的元素 這種情況的多項式所形成的集合會是環,因此稱為多項式環 (將每個多項式視為元素)
大多對 mod 2 最感興趣 也就是所有係數皆為0或1 例如 f(x) = x3 + x2 且 g(x) = x2 + x + 1,那麼: f(x) + g(x) = x3 + x + 1 f(x) x g(x) = x5 + x2 其加法單位元素為何?

24 多項式除法 任何多項數可寫成: 如果沒有餘數 如果g(x)除了1和本身以外,沒有其他的因數多項式,稱為不可分解或質數多項式
GF(2)中的x4+1可分解嗎? 任何多項數可寫成: f(x) = q(x) g(x) + r(x) 可解釋 r(x) 是為餘數 r(x) = f(x) mod g(x) 如果沒有餘數 就表示g( x)整除f( x ) 可以表示成g( x ) / f( x ) 如果g(x)除了1和本身以外,沒有其他的因數多項式,稱為不可分解或質數多項式 GF(2)中的x3+x+1可分解嗎?

25 找出最大公因數 可以改寫歐幾里德演算法來計算: 找出多項式的最大公因數c(x) = GCD(a(x), b(x))
c( x )能整除a( x )和b( x ) a( x )和b( x )的任何因數也是c( x )的因數 可以改寫歐幾里德演算法來計算: EUCLID[a(x), b(x)] 1. A(x) = a(x); B(x) = b(x) 2. if B(x) = 0 return A(x) = gcd[a(x), b(x)] 3. R(x) = A(x) mod B(x) 4. A(x) = B(x) 5. B(x) = R(x) 6. goto 2

26 建立GF(2n) 模數多項式算術 由此種算術形成有限體 係數為取 2同餘
維度大於n之多項式取m(x)之同餘多項式,其中m(x)為某一最高維度為n之質數多項式 在GF(23)中, m(x) = x3+x2+1 OR m(x) = x3+x+1 由此種算術形成有限體 每個元素有在其乘法反元素 Consider now the case of polynomial arithmetic with coordinates mod 2 and polynomials mod an irreducible polynomial m(x). That is Modular Polynomial Arithmetic uses the set S of all polynomials of degree n-1 or less over the field Zp. With the appropriate definition of arithmetic operations, each such set S is a finite field. The definition consists of the following elements: Arithmetic follows the ordinary rules of polynomial arithmetic using the basic rules of algebra, with the following two refinements. 2. Arithmetic on the coefficients is performed modulo p. 3. If multiplication results in a polynomial of degree greater than n-1, then the polynomial is reduced modulo some irreducible polynomial m(x) of degree n. That is, we divide by m(x) and keep the remainder. This forms a finite field. And 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.

27 範例 GF(23)的 (x2+1) 是 1012,(x2+x+1) 是 1112 加法運算 乘法運算 (get q(x) & r(x))
(x2+1) + (x2+x+1) = x 101 XOR 111 = 0102 乘法運算 (x+1).(x2+1) = x.(x2+1) + 1.(x2+1) = x3+x+x2+1 = x3+x2+x+1 = (101)<<1 XOR (101)<<0 = 1010 XOR 101 = 11112 (get q(x) & r(x)) (x3+x2+x+1 ) mod (x3+x+1) = 1.(x3+x+1) + (x2) = x2 1111 mod 1011 = 1111 XOR 1011 = 01002

28 範例 GF(23)

29 找出乘法反元素的演算法

30 求x7+x+1在 GF(28)之乘法反元素範例

31 使用產生器 利用相同的不可分解多項式,也能定義GF(2n)有限體
級數為q的有限體F產生器g是一個元素,這個元素的第一個q – 1次方能產生F所有非零元素 也就是說,這個F的元素是由0, g0, g1, …, gq-2組成 如果f(b) = 0,F裡的元素b就稱為根 不可分解多項式的根g,就是定義在此多項式的有限體的產生器

32 GF(23)之generator m(x): x3+x+1 f(g) = g3 + g + 1 = 0  g3 = g + 1
g4 = g(g3) = g(g + 1) = g2 + g g5 = g(g4) = g(g2 + g) = g3 + g2 = g2 + g + 1 ….

33

34 總結 群、環、體 整數模數算術 歐幾里德演算法 GF(p)有限體 GF(2n)多項式運算


Download ppt "第4章 有限體."

Similar presentations


Ads by Google