No known key found for this signature in database
GPG Key ID: 8A47E30339E13FFD
1 changed files with
8 additions and
9 deletions
-
TTM4135.ipynb
|
|
@ -252,7 +252,7 @@ |
|
|
|
"name": "stdout", |
|
|
|
"output_type": "stream", |
|
|
|
"text": [ |
|
|
|
"1105 is probable prime\n" |
|
|
|
"1105 is composite\n" |
|
|
|
] |
|
|
|
} |
|
|
|
], |
|
|
@ -265,7 +265,7 @@ |
|
|
|
"# times to test for primality\n", |
|
|
|
"from random import randint\n", |
|
|
|
"def fermat_prime(n, k):\n", |
|
|
|
" for x in range(k):\n", |
|
|
|
" for _ in range(k):\n", |
|
|
|
" a = randint(2,n-2)\n", |
|
|
|
" # Fermat’s theorem says that if a number p is prime then \n", |
|
|
|
" # a^p−1 mod p = 1 for all a with gcd(a,p) = 1.\n", |
|
|
@ -299,7 +299,7 @@ |
|
|
|
}, |
|
|
|
{ |
|
|
|
"cell_type": "code", |
|
|
|
"execution_count": 23, |
|
|
|
"execution_count": 8, |
|
|
|
"metadata": {}, |
|
|
|
"outputs": [ |
|
|
|
{ |
|
|
@ -382,7 +382,7 @@ |
|
|
|
}, |
|
|
|
{ |
|
|
|
"cell_type": "code", |
|
|
|
"execution_count": 8, |
|
|
|
"execution_count": 9, |
|
|
|
"metadata": {}, |
|
|
|
"outputs": [ |
|
|
|
{ |
|
|
@ -429,9 +429,8 @@ |
|
|
|
"source": [ |
|
|
|
"# Discrete logarithm problem\n", |
|
|
|
"Given a prime `p` and an integer `y` with `0 < y < p`, find `x` such that \n", |
|
|
|
"```\n", |
|
|
|
"y = g^x mod p\n", |
|
|
|
"```\n", |
|
|
|
"\n", |
|
|
|
"> $y = g^{x}\\mod{p}$\n", |
|
|
|
"\n", |
|
|
|
"No polynomial algorithims exists, but \"Baby-step giant-step\" is a reasonable one. \n", |
|
|
|
"\n", |
|
|
@ -443,7 +442,7 @@ |
|
|
|
}, |
|
|
|
{ |
|
|
|
"cell_type": "code", |
|
|
|
"execution_count": 35, |
|
|
|
"execution_count": 10, |
|
|
|
"metadata": {}, |
|
|
|
"outputs": [ |
|
|
|
{ |
|
|
@ -520,7 +519,7 @@ |
|
|
|
}, |
|
|
|
{ |
|
|
|
"cell_type": "code", |
|
|
|
"execution_count": 10, |
|
|
|
"execution_count": 11, |
|
|
|
"metadata": {}, |
|
|
|
"outputs": [ |
|
|
|
{ |
|
|
|