diff options
| author | J08nY | 2021-04-11 14:16:57 +0200 |
|---|---|---|
| committer | J08nY | 2021-04-11 14:16:57 +0200 |
| commit | 942c0fb9d6fcbff7c91c553211cc81c7e0939e4e (patch) | |
| tree | 1df80da6030019ef2a7490d2b2050a7d4b9a83ec /pyecsca/ec/signature.py | |
| parent | a2e01e037fcde3e63571633e94156e324a4f2299 (diff) | |
| download | pyecsca-942c0fb9d6fcbff7c91c553211cc81c7e0939e4e.tar.gz pyecsca-942c0fb9d6fcbff7c91c553211cc81c7e0939e4e.tar.zst pyecsca-942c0fb9d6fcbff7c91c553211cc81c7e0939e4e.zip | |
Diffstat (limited to 'pyecsca/ec/signature.py')
| -rw-r--r-- | pyecsca/ec/signature.py | 27 |
1 files changed, 7 insertions, 20 deletions
diff --git a/pyecsca/ec/signature.py b/pyecsca/ec/signature.py index 0e6f546..d85d58f 100644 --- a/pyecsca/ec/signature.py +++ b/pyecsca/ec/signature.py @@ -1,6 +1,4 @@ -""" -This module provides an implementation of ECDSA (Elliptic Curve Digital Signature Algorithm). -""" +"""This module provides an implementation of ECDSA (Elliptic Curve Digital Signature Algorithm).""" import hashlib from typing import Optional, Any @@ -17,21 +15,12 @@ from .point import Point @public class SignatureResult(object): - """An ECDSA signature result (r, s).""" + """ECDSA signature result (r, s).""" r: int s: int - def __init__( - self, - r: int, - s: int, - data: Optional[bytes] = None, - digest: Optional[bytes] = None, - nonce: Optional[int] = None, - privkey: Optional[Mod] = None, - pubkey: Optional[Point] = None, - ): + def __init__(self, r: int, s: int): self.r = r self.s = s @@ -80,7 +69,7 @@ class ECDSAAction(Action): @public class ECDSASignAction(ECDSAAction): - """An ECDSA signing.""" + """ECDSA signing.""" privkey: Mod @@ -100,7 +89,7 @@ class ECDSASignAction(ECDSAAction): @public class ECDSAVerifyAction(ECDSAAction): - """An ECDSA verification.""" + """ECDSA verification.""" signature: SignatureResult pubkey: Point @@ -123,7 +112,7 @@ class ECDSAVerifyAction(ECDSAAction): @public class Signature(object): - """An EC based signature primitive. (ECDSA)""" + """EC based signature primitive (ECDSA).""" mult: ScalarMultiplier params: DomainParameters @@ -180,9 +169,7 @@ class Signature(object): affine_point = point.to_affine() r = Mod(int(affine_point.x), self.params.order) s = nonce.inverse() * (Mod(z, self.params.order) + r * self.privkey) - return SignatureResult( - int(r), int(s), digest=digest, nonce=int(nonce), privkey=self.privkey - ) + return SignatureResult(int(r), int(s)) def sign_hash(self, digest: bytes, nonce: Optional[int] = None) -> SignatureResult: """Sign already hashed data.""" |
