Skip to content

Commit

Permalink
🚑 fix old python run
Browse files Browse the repository at this point in the history
  • Loading branch information
colinxu2020 committed Jul 8, 2024
1 parent b1a2b15 commit 7567e9e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
16 changes: 8 additions & 8 deletions slhdsa/lowlevel/addresses.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class Address:
typ: int

def to_bytes(self) -> bytes:
return self.layer.to_bytes(4) + self.tree.to_bytes(12) + self.typ.to_bytes(4)
return self.layer.to_bytes(4, "big") + self.tree.to_bytes(12, "big") + self.typ.to_bytes(4, "big")

def with_type(self, typ: type[T]) -> T:
return typ(self.layer, self.tree, typ.typ)
Expand All @@ -25,7 +25,7 @@ class WOTSHashAddress(Address):
hash: int = 0

def to_bytes(self) -> bytes:
return super().to_bytes() + self.keypair.to_bytes(4) + self.chain.to_bytes(4) + self.hash.to_bytes(4)
return super().to_bytes() + self.keypair.to_bytes(4, "big") + self.chain.to_bytes(4, "big") + self.hash.to_bytes(4, "big")


@dataclass
Expand All @@ -34,7 +34,7 @@ class WOTSPKAddress(Address):
keypair: int = 0

def to_bytes(self) -> bytes:
return super().to_bytes() + self.keypair.to_bytes(4) + b'\x00' * 8
return super().to_bytes() + self.keypair.to_bytes(4, "big") + b'\x00' * 8


@dataclass
Expand All @@ -44,7 +44,7 @@ class TreeAddress(Address):
index: int = 0

def to_bytes(self) -> bytes:
return super().to_bytes() + b'\x00' * 4 + self.height.to_bytes(4) + self.index.to_bytes(4)
return super().to_bytes() + b'\x00' * 4 + self.height.to_bytes(4, "big") + self.index.to_bytes(4, "big")


@dataclass
Expand All @@ -55,7 +55,7 @@ class FORSTreeAddress(Address):
index: int = 0

def to_bytes(self) -> bytes:
return super().to_bytes() + self.keypair.to_bytes(4) + self.height.to_bytes(4) + self.index.to_bytes(4)
return super().to_bytes() + self.keypair.to_bytes(4, "big") + self.height.to_bytes(4, "big") + self.index.to_bytes(4, "big")


@dataclass
Expand All @@ -64,7 +64,7 @@ class FORSRootsAddress(Address):
keypair: int = 0

def to_bytes(self) -> bytes:
return super().to_bytes() + self.keypair.to_bytes(4) + b'\x00' * 8
return super().to_bytes() + self.keypair.to_bytes(4, "big") + b'\x00' * 8


@dataclass
Expand All @@ -75,7 +75,7 @@ class WOTSPrfAddress(Address):
hash: int = 0

def to_bytes(self) -> bytes:
return super().to_bytes() + self.keypair.to_bytes(4) + self.chain.to_bytes(4) + self.hash.to_bytes(4)
return super().to_bytes() + self.keypair.to_bytes(4, "big") + self.chain.to_bytes(4, "big") + self.hash.to_bytes(4, "big")


@dataclass
Expand All @@ -86,4 +86,4 @@ class FORSPrfAddress(Address):
index: int = 0

def to_bytes(self) -> bytes:
return super().to_bytes() + self.keypair.to_bytes(4) + self.height.to_bytes(4) + self.index.to_bytes(4)
return super().to_bytes() + self.keypair.to_bytes(4, "big") + self.height.to_bytes(4, "big") + self.index.to_bytes(4, "big")
2 changes: 1 addition & 1 deletion slhdsa/lowlevel/wots.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def _format_message(self, msg_: bytes) -> list[int]:
for i in range(self.wots_parameter.len1):
csum = csum + self.wots_parameter.w - 1 - msg[i]
csum = csum << ((8 | -((self.wots_parameter.len2 * self.parameter.lgw) % 8)) % 8)
msg = msg + base2b(csum.to_bytes(ceil_div(self.wots_parameter.len2 * self.parameter.lgw, 8)),
msg = msg + base2b(csum.to_bytes(ceil_div(self.wots_parameter.len2 * self.parameter.lgw, 8), "big"),
self.parameter.lgw, self.wots_parameter.len2)
return msg

Expand Down

0 comments on commit 7567e9e

Please sign in to comment.