diff --git a/elgamal.py b/elgamal.py index dbd4d83e1f0f00e3b06a9cd00fe55219586051ef..192ff2cf6a17730901c62d494a00a9d9b29a5304 100644 --- a/elgamal.py +++ b/elgamal.py @@ -78,11 +78,8 @@ def sign(m: int, k: int, privkey: Privkey) -> Signature: a = privkey.a Y = pow(g, k, p) - inverse = xgcd(k, p)[1] % (p - 1) + inverse = xgcd(k, p-1)[1] % (p - 1) S = ((m - a * Y) * inverse) % (p - 1) - print( - f"Y = {Y}, S = {S}, p = {p}, g = {g} a = {a}, k = {k}, m = {m}, A = {pow(g,a,p)}" - ) return Signature(Y, S) diff --git a/fichier.signed.txt b/fichier.signed.txt index 9c454425b8de1c7a2c6df6da33f46b0a222d1eb8..572534ac6d3c33c88a2c09ed5a10ea7c1e609f4d 100644 --- a/fichier.signed.txt +++ b/fichier.signed.txt @@ -1,2 +1,2 @@ -3621 5011 +2353 2497 Il faut pas respirer la compote, ça fait tousser. \ No newline at end of file diff --git a/privkey.txt b/privkey.txt index 973946a06e5012c7f4aae4665d7537419e772991..8a7fb33ca9576350a2ced85e088b26d5918b043b 100644 --- a/privkey.txt +++ b/privkey.txt @@ -1 +1 @@ -7297 14 7057 \ No newline at end of file +6317 5416 5989 \ No newline at end of file diff --git a/pubkey.txt b/pubkey.txt index 844dee23fae160ca04325d31b59164ff82554f74..2d36684a0171f75b7fc1ab9a232e428a856e8792 100644 --- a/pubkey.txt +++ b/pubkey.txt @@ -1 +1 @@ -7297 14 1356 \ No newline at end of file +6317 5416 5265 \ No newline at end of file