密码学数学基础第九讲 环
- 格式:ppt
- 大小:161.50 KB
- 文档页数:18
第二章密码学的数学基础•数论-素数-模运算•代数结构•安全性基础-信息论-复杂性理论1为何讲素数?•为何讲数?-加(解)密:数字变换-信息:离散事件-例:A(0),B(1),…,Z(25)•为何讲素数?-素数是数的基础2素数与合数•定义:整数p是一个素数,如果它只能被+p, -p,+1,-1整除.-例:2,3,5,7,11,13,17,…,101,…•全体素数的集合记为P.•定义:如果整数n不是素数,则它是一个合数.-例:4,9,187,900,…4•Theorem:(Fundamental Theorem of Arithmetic)∀n∈N n= p1e1p2e2…pke k ( or Πp i∈Pp e i)where e p is the exponent of the prime factor p•Note:the result of factorization is unique •Example:84=22×3×7数的因子分解56素数•Theorem:There are infinitely many primes •Proof:(by contradiction)Assume , build a number N is There N is a new prime.maxP 1...max 21+=P P P N8Finding GCD•Theorem:•Example:•Complexity∏∏∏=⇒=∧=i b a ib i i a i i i i i i p b a p b p a ),min(),gcd(637*3),gcd(11*7*5*334657*3*28822322==⇒====b a b a )()()(n o c o n T band a the factoring Need =••10Euclidean Algorithm),gcd(:300...:2,:1111123221211010b a r step r and r until r r q r r r q r r r q r step br a r step n n n nn n n =≠=+=+=+===−−−−−16Congruence Relation (同余关系)•同余关系是一个等价关系-自反性-对称性-传递性•等价关系划分⇒ca cb b a ab b a aa ≡⇒≡∧≡≡⇒≡≡Modular Arithmetic(模运算)•We can define the modular arithmetic in the set of integers: Z n={0, 1, 2, …, n-1}•Under normal arithmetic (+,×)–[(a mod n) +(b mod n)] mod n = (a+b) mod n•Proof:Let a=q1n+r1, b=q2n+r2•(a+b) mod n = (q1n+r1+q2n+r2) mod n = (r1+r2) mod n–[(a mod n) ×(b mod n)] mod n = (a×b) mod n •(+, ×)→(-,÷) ?1819模运算:举例1•(Z 8={0, 1, 2, …, 7}, +)What?模运算说明•Additive Inverse Always Exists–(a+(-a)) = 0 mod n ⇒-a = n-a–if (a+b) ≡(a+c) mod n then b≡c mod n•((-a)+a+b) ≡((-a)+a+c) mod n•Multiplicative Inverse NOT Always Exists –Example:6 in Z8–When?21模运算中的乘法逆•Definition:a-1mod n is the multiplicative inverse of a∈{1,2,…,n-1} when ax≡1mod n•Theorem: If and only if gcd(a,n)=1, then the a-1 mod n exists•Lemma:If gcd(a,n)=1, then a⋅i≠a⋅j mod n for all 0≤i<j<n (i ≠j)–Proof:assume a⋅i≡a⋅j mod n⇒n|a(i-j) ⇒n|i-j⇒i-j=022乘法逆定理•Proof:•⇒–gcd(a,n)=1 ⇒a·{1,…,n-1} mod n is the permutationof {1,…,n-1}–So there exists only an i that a⋅i≡1 mod n–Therefore i is a-1mod n•⇐–Suppose a-1exists, call it x–ax ≡1 (mod n) and ax + yn= 1 for some integer y–gcd(a, n)=1 (gcd(a,n)|ax+yn→gcd(a,n)|1)23如何找到a-1mod n?•在{1,…,n-1} 中寻找,直到找到一个a-1,使得a·a-1≡1 (mod n)–T(n)=O(n)•计算a-1= aϕ(n)-1mod n–寻找ϕ(n) ⇔分解n–T(n)=O(n a)•用Extended Euclidean Algorithm–T(n)=O(log a n)2426求a-1mod ngcd(n,a)•n=aq 1+r 1 r 1=n-aq 1= s 0n+t 0a •a= r 1q 2+r 2 r 2= a-r 1q 2 =s 1n+t 1a ……•r k-1 =s k-1n+t k-1a•r k-1=gcd(n, a)•若gcd(n, a) =1,则s k-1n+t k-1a =1 ⇒t k-1a ≡1 mod n ⇒t k-1≡a -1mod nGCD(1970,1066)1970=1*1066+904 gcd(1066,904)1066=1*904+162 gcd(904,162)904=5*162+94 gcd(162,94)162=1*94+68 gcd(94,68)94=1*68+26 gcd(68,26)68=2*26+16 gcd(26,16)26=1*16+10 gcd(16,10)16=1*10+6 gcd(10,6)10=1*6+4 gcd(6,4)6=1*4+2 gcd(4,2)4=2*2+0 gcd(2,0)如何找到t k-1 ?28Step 1:r 0 =n and r 1 =aStep 2:r 0 =q 1r 1+r 2 Ær 2 =r 0 -q 1r 1 =-q 1r 1 mod nlet x 2= -q 1then r 2 =x 2r 1 mod nr 1 =q 2r 2+r 3 Ær 3 =r 1 –q 2r 2 =(1-x 2q 2)r 1 mod nlet x 3= 1-x 2q 2then r 3 =x 3r 1 mod n ……r n-3 = q n-2r n-2+r n-1 Ær n-1 =r n-3 –q n-2r n-2 mod nlet x n-1= x n-3-x n-2q n-2then r n-1 =x n-1r 1 mod n Now r n-1=1Step 3:Result is x n-2 =a -1mod nExtended Euclidean Algorithm29例:求7-1mod 26r 4 = r 2 -2r 3= r 2-2(r 1-r 2)= -2r 1+3r 2= -2r 1+3(r 0-3r 1)= 3r 0-11r 1⇒t 4= -11⇒7-1mod 26 = 15r 0 q 1 r 1r 226=3*7+5r 1 q 2 r 2r 37 =1*5+2r 2 q 3 r 3r 45 =2*2+1例:求3-1mod 26=930Euler phi Function•是在比n 小的正整数中与n 互素的数的个数.•例如:•若n 是素数,则显然有φ(n)=n-1。