Skip to content

Commit

Permalink
Merge pull request #1 from mlindgren/mitchl/fix_fips204_to_bytes
Browse files Browse the repository at this point in the history
Fix to_bytes in fips204.py (compatibility with Python < 3.11)
  • Loading branch information
mjosaarinen authored Sep 13, 2024
2 parents 9eddd2e + 424c6ec commit 0382529
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions fips204.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 0382529

Please sign in to comment.