From 82d6dd458d50c8108fc356d181530b23cd4f0d0b Mon Sep 17 00:00:00 2001 From: Arian Ubuntu <ariandervishaj@icloud.com> Date: Tue, 30 Apr 2024 16:47:54 +0200 Subject: [PATCH] Correction inverse --- elgamal.py | 5 +---- fichier.signed.txt | 2 +- privkey.txt | 2 +- pubkey.txt | 2 +- 4 files changed, 4 insertions(+), 7 deletions(-) diff --git a/elgamal.py b/elgamal.py index dbd4d83..192ff2c 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 9c45442..572534a 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 973946a..8a7fb33 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 844dee2..2d36684 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 -- GitLab