You are on page 1of 4

Aritmètica David Buchaca - Prats Pràctica 6 Tardor 2010

Problema 1. Esbrina el significat de les funcions seguents i de Fold.

F old[f, x, {a, b, c}] −→ f [f [f [x, a], b], c]

F old[#1 ∗ 10 + #2&, 0, {a, b, c}] −→ 10(10a + b) + c


(10a + b) ∗ 10 + c −→ 10(10a + b) + c

F old[#1 ∗ 10 + #2&, 0, {2, 0, 0, 6, 1, 1, 2, 4}] −→ 20 061 124


((((((2 ∗ 10 + 0) ∗ 10 + 0) ∗ 10 + 6) ∗ 10 + 1) ∗ 10 + 1) ∗ 10 + 2) ∗ 10 + 4 −→ 20 061 124

La funció Fold dona l’ultim element de ”Foldlist”. Foldlist aplicat a [f,x,a,b,...] retorna
{x,f[x,a], f [ f [ x,a],b ] , ....}
Problema 2. Esbrina el significat de les funcions:
IntegerDigits[75] −→ {7, 5}
IntegerDigits[n] retorna una llista dels digits decimals de n.
IntegerDigits[75, 2] −→ {1, 0, 0, 1, 0, 1, 1}
IntegerDigits[n, b] retorna una llista en base b del digits de n.

Transformem la llista {9,8,7,6,5,4,3,2,1} ien un nombre en base 95 i recuperem els seus


digits:

nom95 = F old[#1 ∗ 95 + #2&, 0, {9, 8, 7, 6, 5, 4, 3, 2, 1}] −→ 60 271 701 133 691 141
IntegerDigits[nom95, 95] −→ {9, 8, 7, 6, 5, 4, 3, 2, 1}

Problema 3.
mT = ”Directory of banks in crisis” −→ ”Directory of banks in crisis”

P Q = 11293220177790248609 −→ 11 293 220 177 790 248 609

e = 5 −→ 5

mA = T oCharacterCode[mT ] −→ {68, 105, 114, 101, 99, 116, 111, 114, 121, 32,
111, 102, 32, 98, 97, 110, 107, 115, 32, 105,
110, 32, 99, 114, 105, 115, 105, 115}

m95 = mA − 32 −→ {36, 73, 82, 69, 67, 84, 79, 82, 89, 0, 79, 70, 0, 66,
65, 78, 75, 83, 0, 73, 78, 0, 67, 82, 73, 83, 73, 83}

m10 = F old[#1 ∗ 95 + #2&, 0, m95] −→ 9 207 051 850 104 644 053 042 785 497 201 395
967 665 369 426 326 461 343

mP Q = IntegerDigits[m10, P Q] −→ {72 191 322 528 455 203,


6 844 883 447 154 901 843,
9 041 503 343 959 039 113}

1
Aritmètica David Buchaca - Prats Pràctica 6 Tardor 2010

mP QX = F unction[x, P owerM od[x, e, P Q]]/@mP Q −→ {4 922 073 027 081 664 063,
601 032 330 774 944 602,
1 306 048 600 200 164 626}
or
mP QX = P owerM od[mP Q, e, P Q] −→ {4 922 073 027 081 664 063,
601 032 330 774 944 602,
1 306 048 600 200 164 626}

mX95 = IntegerDigits[mP QX, 95] −→ {{7, 76, 87, 70, 82, 71, 44, 29, 23, 28},
{90, 56, 58, 79, 87, 62, 78, 9, 47},
{2, 6, 82, 24, 70, 63, 72, 53, 36, 6}}

mXT = F romCharacterCode[mX95 + 32] −→ {”0 lwf rgL = 7 < ”, ”zXZown )O


”, ”\”&r8fh U D&”}

2
Aritmètica David Buchaca - Prats Pràctica 6 Tardor 2010

Problema 4. Trenca la clau de l’exercici anterior per desencriptar el missatge:

F actorInteger[P Q] −→ {{2 541 158 777, 1},


{4 444 122 217, 1}}
EulerP hi[P Q] −→ 11 293 220 170 804 967 616

ExtendedGCD[5, EulerP hi[P Q]] −→ {1, {−2 258 644 034 160 993 523, 1}}
d = %[[2]][[1]] −→ −2 258 644 034 160 993 523
mXT −→ {”0 lwf rgL = 7 < ”, ”zXZown )O”, ”&r8f hU D&”}

mXA = T oCharacterCode[mXT ] −→ {{39, 108, 119, 102, 114, 103, 76, 61, 55, 60},
{122, 88, 90, 111, 119, 94, 110, 41, 79},
{34, 38, 114, 56, 102, 95, 104, 85, 68, 38}}

mX95 = mXA − 32 −→ {{7, 76, 87, 70, 82, 71, 44, 29, 23, 28},
{90, 56, 58, 79, 87, 62, 78, 9, 47},
{2, 6, 82, 24, 70, 63, 72, 53, 36, 6}}

mXP Q = T able[F old[#1 ∗ 95 + #2&, −→ {4 922 073 027 081 664 063,
0, mX95[[k]]], {k, 1, Length[mX95]}] 601 032 330 774 944 602,
1 306 048 600 200 164 626}
mXP QY = F unction[x, P owerM od[x, d, P Q]] −→ {72 191 322 528 455 203,
/@mXP Q 6 844 883 447 154 901 843,
9 041 503 343 959 039 113}

mXY 10 = F old[#1 ∗ P Q + #2&, 0, mXP QY ] −→


9 207 051 850 104 644 053 042 785 497 201 395 967 665 369 426 326 461 343
mXY A = IntegerDigits[mXY 10, 95] + 32 −→ {68, 105, 114, 101, 99, 116, 111, 114, 121,
32, 111, 102, 32, 98, 97, 110, 107, 115, 32,
105, 110, 32, 99, 114, 105, 115, 105, 115}

mXY T = F romCharacterCode[mXY A] −→ ”Directory of banks in crisis”

3
Aritmètica David Buchaca - Prats Pràctica 6 Tardor 2010

Problema 5. Crea una clau (P Q, e, d) pel sistema RSA :

(a) Triem una parella de primersP, Q.

P = P rime[6 570 730 109 871] −→ 209 896 172 349 301
Q = P rime[4 098 790 438 721] −→ 128 932 511 751 271

(b) Considerem el modul P Qd onat pel seu prodecte.Calculem la funcio d’Euler ϕ (P Q)


.
P ∗ Q −→ 27 062 440 707 973 054 321 842 711 571
EulerP hi[P ∗ Q] −→ 27 062 440 707 972 715 493 158 611 000

(c) triem un nombre natural e coprimer amb P hi(P Q).

e = P rime[123 456] −→ 1 632 899


If [GCD[EulerP hi[P ∗ Q], e] == 1, P rint[e]] −→ 1 632 899

(d) Calculalem un nombre solucio de (mod P hi(P Q)).

P owerM od[e, −1, EulerP hi[P ∗ Q]] −→ 20 366 400 884 370 586 811 253 365 099

(e) Fem publica la clau (P Q, e).

(P Q, e) −→ (27 062 440 707 973 054 321 842 711 571, 1 632 899)

(f) La clau privada serà (P, Q, e).

(P, Q, e) −→ (209 896 172 349 301, 128 932 511 751 27, 1 632 899)

(*g) per trencar la clau farem F actorInteger[P Q].

F actorInteger[P Q] −→ {{128 932 511 751 271, 1},


{209 896 172 349 301, 1}}

Observem que M athematica necessita un temps molt llarg per calcular els primers
P i Q . El calcul de F actorInteger[P Q] encanvi es immediat.

You might also like