From 424c6ec3a59eb099feb9c5e4f49196fa3e8fa22b Mon Sep 17 00:00:00 2001 From: Mitch Lindgren Date: Thu, 12 Sep 2024 15:48:37 -0700 Subject: [PATCH] Fix to_bytes in fips204.py --- fips204.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fips204.py b/fips204.py index 7c890ff..a95309a 100644 --- a/fips204.py +++ b/fips204.py @@ -174,7 +174,7 @@ def keygen_internal(self, xi, param=None): self.__init__(param) # print('# keygen_internal()', param) # print('# seed:', xi.hex()) - se = self.h(xi + self.k.to_bytes() + self.ell.to_bytes(), 128) + se = self.h(xi + self.integer_to_bytes(self.k, 1) + self.integer_to_bytes(self.ell, 1), 128) rho = se[0:32] rhop = se[32:96] kk = se[96:128] @@ -659,7 +659,7 @@ def expand_a(self, rho): a = [ [None]*self.ell for _ in range(self.k) ] for r in range(self.k): for s in range(self.ell): - rhop = rho + s.to_bytes() + r.to_bytes() + rhop = rho + self.integer_to_bytes(s, 1) + self.integer_to_bytes(r, 1) a[r][s] = self.rej_ntt_poly(rhop) return a