Skip to content

Commit 1bf6386

Browse files
authored
Update curves.py
Change to different syntax for performance reasons
1 parent 9a4bb11 commit 1bf6386

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/ecpy/curves.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ def encode_point(self, P, compressed=False):
356356
Returns
357357
bytes : encoded point [04 | x | y] or [02 | x | sign]
358358
"""
359-
size = self.size>>3 + bool(self.size % 8)
359+
size = self.size>>3 + (1 if self.size % 8 else 0)
360360
x = bytearray(P.x.to_bytes(size,'big'))
361361
y = bytearray(P.y.to_bytes(size,'big'))
362362
if compressed:
@@ -377,7 +377,7 @@ def decode_point(self, eP):
377377
Returns
378378
Point : decoded point
379379
"""
380-
size = self.size>>3 + bool(self.size % 8)
380+
size = self.size>>3 + (1 if self.size % 8 else 0)
381381
xy = bytearray(eP)
382382
if xy[0] == 2:
383383
x = xy[1:1+size]
@@ -713,7 +713,7 @@ def encode_point(self, P):
713713
Returns
714714
bytes : encoded point
715715
"""
716-
size = self.size>>3 + bool(self.size % 8)
716+
size = self.size>>3 + (1 if self.size % 8 else 0)
717717
x = bytearray(P.x.to_bytes(size,'little'))
718718
return bytes(x)
719719

0 commit comments

Comments
 (0)