From 880cf888a878b0a0b50a38460911e83b49431caf Mon Sep 17 00:00:00 2001 From: leirn Date: Tue, 16 Apr 2024 10:08:36 +0200 Subject: [PATCH] recover_secret truncates the first char of the secret Removes [1:] to preserve the secret first char --- sslib/shamir/shamir.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sslib/shamir/shamir.py b/sslib/shamir/shamir.py index 712f6dc..1517ed2 100644 --- a/sslib/shamir/shamir.py +++ b/sslib/shamir/shamir.py @@ -113,7 +113,7 @@ def recover_secret(data): if not isinstance(y, bytes): raise TypeError("the second entry of each a share must be an array of bytes") points.append((x, util.int_from_bytes(y))) - return util.int_to_bytes(lagrange_interpolation(0, points, prime_mod))[1:] + return util.int_to_bytes(lagrange_interpolation(0, points, prime_mod)) def to_base64(data): encode_share = lambda xy: str(xy[0]) + "-" + base64.b64encode(xy[1]).decode('ascii')