Literacy 2 Mathematica Mathematica 3 Hiroshi Toyoizumi Univ. of Aizu REFERENCES [1] C.P Williams [2] [3] 1 Literacy 2 Mathematica Ma

Similar documents
25 II :30 16:00 (1),. Do not open this problem booklet until the start of the examination is announced. (2) 3.. Answer the following 3 proble

「プログラミング言語」 SICP 第4章 ~超言語的抽象~ その6

AtCoder Regular Contest 073 Editorial Kohei Morita(yosupo) A: Shiritori if python3 a, b, c = input().split() if a[len(a)-1] == b[0] and b[len(

n 2 n (Dynamic Programming : DP) (Genetic Algorithm : GA) 2 i

セアラの暗号

2011 Future University Hakodate 2011 System Information Science Practice Group Report Project Name Visualization of Code-Breaking RSA Group Name RSA C

Page 1 of 6 B (The World of Mathematics) November 20, 2006 Final Exam 2006 Division: ID#: Name: 1. p, q, r (Let p, q, r are propositions. ) (10pts) (a

1 # include < stdio.h> 2 # include < string.h> 3 4 int main (){ 5 char str [222]; 6 scanf ("%s", str ); 7 int n= strlen ( str ); 8 for ( int i=n -2; i

インターネット概論 第07回(2004/11/12) 「SFC-CNSの現状」

h23w1.dvi

:00-16:10


浜松医科大学紀要

LC304_manual.ai

_念3)医療2009_夏.indd

Level 3 Japanese (90570) 2011

L3 Japanese (90570) 2008

0801391,繊維学会ファイバ12月号/報文-01-西川

21 Key Exchange method for portable terminal with direct input by user

.N..

Pari-gp /7/5 1 Pari-gp 3 pq

(Requirements in communication) (efficiently) (Information Theory) (certainly) (Coding Theory) (safely) (Cryptography) I 1

JOURNAL OF THE JAPANESE ASSOCIATION FOR PETROLEUM TECHNOLOGY VOL. 66, NO. 6 (Nov., 2001) (Received August 10, 2001; accepted November 9, 2001) Alterna

Read the following text messages. Study the names carefully. 次のメッセージを読みましょう 名前をしっかり覚えましょう Dear Jenny, Iʼm Kim Garcia. Iʼm your new classmate. These ar

mahoro/2011autumn/crypto/

Block cipher

Hospitality-mae.indd

x p v p (x) x p p-adic valuation of x v 2 (8) = 3, v 3 (12) = 1, v 5 (10000) = 4, x 8 = 2 3, 12 = 2 2 3, = 10 4 = n a, b a

Microsoft PowerPoint - IntroAlgDs-05-5.ppt

elemmay09.pub

udc-2.dvi

⑥中村 哲也(他).indd

取説_KX-PW101CL_PW102CW

Visual Evaluation of Polka-dot Patterns Yoojin LEE and Nobuko NARUSE * Granduate School of Bunka Women's University, and * Faculty of Fashion Science,

25 Removal of the fricative sounds that occur in the electronic stethoscope

untitled

2 3

FC741E2_091201

Tabulation of the clasp number of prime knots with up to 10 crossings

C H H H C H H H C C CUTION:These telephones are for use in Japan only. They cannot be used in other countries because of differences in voltages, tele

Introduction Purpose This training course demonstrates the use of the High-performance Embedded Workshop (HEW), a key tool for developing software for

soturon.dvi

206“ƒŁ\”ƒ-fl_“H„¤‰ZŁñ

取説_VE-PV11L(応用編)

8-1.indb

kut-paper-template.dvi

取扱説明書_KX-PW100CL


alternating current component and two transient components. Both transient components are direct currents at starting of the motor and are sinusoidal

取説_KX-PW38CL_PW48CL

202

,,.,,.,..,.,,,.,, Aldous,.,,.,,.,,, NPO,,.,,,,,,.,,,,.,,,,..,,,,.,

Vol92.indd

Web Web Web Web Web, i


,,,,., C Java,,.,,.,., ,,.,, i

Microsoft Word - j201drills27.doc

Introduction Purpose This training course describes the configuration and session features of the High-performance Embedded Workshop (HEW), a key tool

LCM,GCD LCM GCD..,.. 1 LCM GCD a b a b. a divides b. a b. a, b :, CD(a, b) = {d a, b }, CM(a, b) = {m a, b }... CM(a, b). q > 0, m 1, m 2 CM

Journal of Geography 116 (6) Configuration of Rapid Digital Mapping System Using Tablet PC and its Application to Obtaining Ground Truth


先端社会研究 ★5★号/4.山崎

2

Chapter

西川町広報誌NETWORKにしかわ2011年1月号


_’¼Œì



ron.dvi


早稲田大学現代政治経済研究所 ダブルトラック オークションの実験研究 宇都伸之早稲田大学上條良夫高知工科大学船木由喜彦早稲田大学 No.J1401 Working Paper Series Institute for Research in Contemporary Political and Ec

AERA_English_CP_Sample_org.pdf


2

2

2

S1Šû‘KŒâ‚è


Microsoft Word - j201drills27.doc

p _08森.qxd

1..FEM FEM 3. 4.

2

橡

MIDI_IO.book

1 UTF Youtube ( ) / 30


Table 1. Assumed performance of a water electrol ysis plant. Fig. 1. Structure of a proposed power generation system utilizing waste heat from factori

9_89.pdf

2 1 ( ) 2 ( ) i


1 Fig. 1 Extraction of motion,.,,, 4,,, 3., 1, 2. 2.,. CHLAC,. 2.1,. (256 ).,., CHLAC. CHLAC, HLAC. 2.3 (HLAC ) r,.,. HLAC. N. 2 HLAC Fig. 2


Bull. of Nippon Sport Sci. Univ. 47 (1) Devising musical expression in teaching methods for elementary music An attempt at shared teaching


2 except for a female subordinate in work. Using personal name with SAN/KUN will make the distance with speech partner closer than using titles. Last

Google Social Influences and Legal Issues of Google Street View Hiroshi Takada

How to read the marks and remarks used in this parts book. Section 1 : Explanation of Code Use In MRK Column OO : Interchangeable between the new part

評論・社会科学 89号(よこ)(P)/4.徐

How to read the marks and remarks used in this parts book. Section 1 : Explanation of Code Use In MRK Column OO : Interchangeable between the new part

Transcription:

Mathematica 3 Hiroshi Toyoizumi Univ. of Aizu toyo@u-aizu.ac.jp REFERENCES [1] C.P Williams [2] [3] 1 Mathematica Mathematica 2 1

PKIPublic Key Infrustructure 3 4 2

5 6 3

RSA 3Ronald RivestAdi ShamirLeonald AdlemanRSA 20009 DSA Diffie-Hellman Whitfield DiffieMartin E. Hellman Diffie1976 Hellman New Directions in CryptographyRSA3 RSA 7 Mathematica Mod GCD FactorInteger Divisors Prime PrimeQ ExtendGCD EulerPhi 8 4

CharacterCode ToCharacterCode["string"] gives a list of the integer codes corresponding to the characters in a string. In[1]:= ToCharacterCode["Everything is an expression."] Out[1]={69,118,101,114,121,116,104,105,110,103,32,105, 115,32,97,110,32,101,120,112,114,101,115,115,105,1 11,110,46} In[2]:= FromCharacterCode[%] Out[2]= Everything is an expression. 9 Mod Mod[m, n] gives the remainder on division of m by n. 10 5

GCD GCD gives the greatest common divisor of the integers 11 FactorInteger[n] FactorInteger [n] gives a list of the prime factors of the integer n, together with their exponents. 12 6

Divisors[n] Divisors[n] gives a list of the integers that divide n. 13 Prime Prime[n] gives the n- th prime number. 14 7

PrimeQ[expr] PrimeQ[ex pr] yields True if expr is a prime number, and yields False otherwise.n 15 ExtendedGCD The first element in the output from ExtendedGCD[n, m] is the greatest common divisor of the integers n and m. In[1]:={g,{r,s}}=ExtendedGCD[n=45,m=36] Out[1]= {9,{1,-1}} In[2]:= GCD[45,36] Out[2]= 9 The second element is a pair of integers. The linear combination of n and m with these as coefficients gives the gcd. In[3]:= nr+ms Out[3]= 9 16 8

These two numbers are relatively prime. In[4]:= {g, {r, s}} = ExtendedGCD[2^100 + 3, 3^50 + 8]) Out[4]={1,{62013782892351778750374, -109502757290992473821761130785}} Therefore this linear combination gives 1. In[5]:= (2^100 + 3) r + (3^50 + 8) s Out[5]= 1 17 EulerPhi[n] EulerPhi[n] gives the Euler totient function φ(n). EulerPhi[n] gives the number of positive integers less than or equal to n which are relatively prime to n. Up to 10 there are four numbers relatively prime to 10. In[1]:= EulerPhi[10] Out[1]= 4 In[2]:= Select[Range[10],GCD[#1,10]==1&] Out[2]= {1,3,7,9} 18 9

Euler a GCD(a,n)=1 aφ(n) = 1 mod n 19 Euler In[1]:=GCD[5, 17] Out[1]=1 In[2]:=EulerPhi[17] Out[2]=16 In[3]:=Mod[5^EulerPhi[17], 17] Out[3]=1 In[5]:=Mod[10^EulerPhi[17], 17] Out[5]=1 20 10

RSA 21 22 11

e: p=5, q=17 In[2]:=PrimeQ[5] Out[2]=True In[3]:=PrimeQ[17] Out[3]=True p n = p q = 85 φ(n)=(p-1)(q-1) (p-1)(q-1) = 64 (p-1)(q-1)e e = 3 23 : e d = 1 mod (p-1)(q-1) d d=43 e d = 3*43 = 129 = 64 *2 +1 = 1 mod 64 24 12

e d = 1 mod (p-1)(q-1) e d = 1- k (p-1)(q-1) e d +k (p-1)(q-1) = 1 ExtendedGCD {1,{d,k}}=ExtendedGCD[e, (p-1)(q-1)] d(p-1)(q-1) (p-1)(q-1)α 25 e = 3, (p-1)(q-1)=64 In[7]:=g, {d, k}} = ExtendedGCD[3, 64] Out[7]={1,{-21,1}} In[8]:=d + 64 Out[8]=43 26 13

Bob(e,n) AliceBob 27 Alice M Bobe,n)C C = M^e mod n (e,n) = (3, 85), M=77 In[1]:=Mod[77^3, 85] Out[1]=83 C 28 14

Bob AliceC d C^d = M^(ed) mod n = M^(1+k (p-1)(q-1))mod pq = M*{M^k}^(p-1)(q-1) mod pq MpqEuler = M mod pq MM=jp = j {j^k(p-1)}^q mod q Euler = j mod q = M mod pq M C^d=M mod n 29 (,n) = (43, 85), C=83 In[1]:=Mod[83^43, 85] Out[1]=77 M 30 15

Bob(e,n) p,q,qe Alice(d,n) 31 (e,n)=(3,85) C=83 n In[4]:=Divisors[85] Out[4]={1,5,17,85} ExtendedGCDd In[9]:=g, {d, k}} = ExtendedGCD[3, (5-1)(17-1)] Out[9]={1,{-21,1}} In[8]:=d + 64 Out[8]=43 C In[1]:=Mod[83^43, 85] Out[1]=77 d 32 16

Exercise 1. Check Euler s Theorem by Mathematica. Make a list of the function f(m)=mod[a^(m),n] from m= to the Euler number of n, where a is an arbitrary number, n is a prime number. Check when does f(m)=1 hold for different values of a and n? 33 Exercise 2. Encrypt your message Set a particular phrase as your message. Convert your message into a sequence of integers M. Choose a pair of 2-digit prime numbers (p,q) and derive the keys (d,e,n). Encrypt M into C by the key (e,n). Check if C can be decrypted by the key (d,n). Option: Ask your neighbors to decrypt C by disclosing your public key (e,n). 34 17

Exercise 3.Crack my message Crack me! Public key: (e,n) = (937, 46127) Encryptedmessage:{14942, 16840, 39519, 6259, 6259, 12812, 33935, 2736, 6259, 30900, 39211, 32709, 4943, 39211, 34710, 4943, 45747, 6259, 19266, 19461, 25615, 27469, 6259, 6259, 14942, 1494, 39519, 6259, 7357, 12408, 39211, 6259, 40186, 2736, 10334, 6259, 45747, 4943, 44980, 15131, 40186, 19991, 34710, 6259, 34710, 33935, 30900, 37515, 6259, 42569, 4943, 37515, 37515, 12408, 41505, 4943, 6259, 22680, 30900, 34710, 33935, 2736, 10334, 34710, 6259, 10334, 37515, 30900, 39211, 41505, 6259, 34710, 33935, 4943, 6259, 24879, 4943, 40186, 37515, 27469} Guess my original message and my secret key. Option: Answer my questions in the original message. 35 Exercise 4 (Option). Performance Evaluation of Cracking Use Timing[ ] function and estimate the CPU time required to crack RSA with given n. Draw the graph (log-log plot?) of CPU time with different n. Discuss the possibility of cracking when n is large. 36 18

Timing Timing[expr] evaluates expr, and returns a list of time used, together with the result obtained. Timing gives the CPU time in seconds, multiplied by the symbol Second. Example:Here is the CPU time needed to compute a large factorial number. In[11]:=Timing[10^10!] Out[11]={5.8 Second,Null} 37 19