diff options
| author | J08nY | 2023-02-05 16:25:43 +0100 |
|---|---|---|
| committer | J08nY | 2023-02-05 16:25:43 +0100 |
| commit | a796a68e02521a1db2ee309c021671a904fe14df (patch) | |
| tree | 927edd15b15a04cb9e582b05d718e8943d6f757d /pyecsca/ec | |
| parent | 0f5c105c8e34b8443c0da168d7f05f6cd9a03a59 (diff) | |
| download | pyecsca-a796a68e02521a1db2ee309c021671a904fe14df.tar.gz pyecsca-a796a68e02521a1db2ee309c021671a904fe14df.tar.zst pyecsca-a796a68e02521a1db2ee309c021671a904fe14df.zip | |
Fix mypy issues.
Diffstat (limited to 'pyecsca/ec')
| -rw-r--r-- | pyecsca/ec/model.py | 6 | ||||
| -rw-r--r-- | pyecsca/ec/mult.py | 18 | ||||
| -rw-r--r-- | pyecsca/ec/signature.py | 6 |
3 files changed, 14 insertions, 16 deletions
diff --git a/pyecsca/ec/model.py b/pyecsca/ec/model.py index c6305a6..e714991 100644 --- a/pyecsca/ec/model.py +++ b/pyecsca/ec/model.py @@ -63,9 +63,8 @@ class EFDCurveModel(CurveModel): return parse(line.replace("^", "**"), mode=mode) with resource_stream(__name__, file_path) as f: - line = f.readline() - while line: - line = line.decode("ascii").rstrip() + for raw in f.readlines(): + line = raw.decode("ascii").rstrip() if line.startswith("name"): cls.name = line[5:] elif line.startswith("parameter"): @@ -90,7 +89,6 @@ class EFDCurveModel(CurveModel): cls.from_weierstrass.append(format_eq(line[16:])) else: cls.full_weierstrass.append(format_eq(line)) - line = f.readline() def __read_coordinate_dir(self, cls, dir_path, name): cls.coordinates[name] = EFDCoordinateModel(dir_path, name, self) diff --git a/pyecsca/ec/mult.py b/pyecsca/ec/mult.py index 47c36b1..dc89237 100644 --- a/pyecsca/ec/mult.py +++ b/pyecsca/ec/mult.py @@ -203,7 +203,7 @@ class LTRMultiplier(ScalarMultiplier): self, add: AdditionFormula, dbl: DoublingFormula, - scl: ScalingFormula = None, + scl: Optional[ScalingFormula] = None, always: bool = False, complete: bool = True, short_circuit: bool = True, @@ -254,7 +254,7 @@ class RTLMultiplier(ScalarMultiplier): self, add: AdditionFormula, dbl: DoublingFormula, - scl: ScalingFormula = None, + scl: Optional[ScalingFormula] = None, always: bool = False, short_circuit: bool = True, ): @@ -300,7 +300,7 @@ class CoronMultiplier(ScalarMultiplier): self, add: AdditionFormula, dbl: DoublingFormula, - scl: ScalingFormula = None, + scl: Optional[ScalingFormula] = None, short_circuit: bool = True, ): super().__init__(short_circuit=short_circuit, add=add, dbl=dbl, scl=scl) @@ -334,8 +334,8 @@ class LadderMultiplier(ScalarMultiplier): def __init__( self, ladd: LadderFormula, - dbl: DoublingFormula = None, - scl: ScalingFormula = None, + dbl: Optional[DoublingFormula] = None, + scl: Optional[ScalingFormula] = None, complete: bool = True, short_circuit: bool = True, ): @@ -381,7 +381,7 @@ class SimpleLadderMultiplier(ScalarMultiplier): self, add: AdditionFormula, dbl: DoublingFormula, - scl: ScalingFormula = None, + scl: Optional[ScalingFormula] = None, complete: bool = True, short_circuit: bool = True, ): @@ -424,7 +424,7 @@ class DifferentialLadderMultiplier(ScalarMultiplier): self, dadd: DifferentialAdditionFormula, dbl: DoublingFormula, - scl: ScalingFormula = None, + scl: Optional[ScalingFormula] = None, complete: bool = True, short_circuit: bool = True, ): @@ -469,7 +469,7 @@ class BinaryNAFMultiplier(ScalarMultiplier): add: AdditionFormula, dbl: DoublingFormula, neg: NegationFormula, - scl: ScalingFormula = None, + scl: Optional[ScalingFormula] = None, short_circuit: bool = True, ): super().__init__( @@ -517,7 +517,7 @@ class WindowNAFMultiplier(ScalarMultiplier): dbl: DoublingFormula, neg: NegationFormula, width: int, - scl: ScalingFormula = None, + scl: Optional[ScalingFormula] = None, precompute_negation: bool = False, short_circuit: bool = True, ): diff --git a/pyecsca/ec/signature.py b/pyecsca/ec/signature.py index 972af19..d9b49f7 100644 --- a/pyecsca/ec/signature.py +++ b/pyecsca/ec/signature.py @@ -64,7 +64,7 @@ class ECDSAAction(Action): self.msg = msg def __repr__(self): - return f"{self.__class__.__name__}({self.params}, {self.hash_algo}, {self.msg})" + return f"{self.__class__.__name__}({self.params}, {self.hash_algo}, {self.msg!r})" @public @@ -84,7 +84,7 @@ class ECDSASignAction(ECDSAAction): self.privkey = privkey def __repr__(self): - return f"{self.__class__.__name__}({self.params}, {self.hash_algo}, {self.msg}, {self.privkey})" + return f"{self.__class__.__name__}({self.params}, {self.hash_algo}, {self.msg!r}, {self.privkey})" @public @@ -107,7 +107,7 @@ class ECDSAVerifyAction(ECDSAAction): self.pubkey = pubkey def __repr__(self): - return f"{self.__class__.__name__}({self.params}, {self.hash_algo}, {self.msg}, {self.signature}, {self.pubkey})" + return f"{self.__class__.__name__}({self.params}, {self.hash_algo}, {self.msg!r}, {self.signature}, {self.pubkey})" @public |
