diff options
| author | J08nY | 2021-01-20 20:24:11 +0100 |
|---|---|---|
| committer | J08nY | 2021-01-20 20:24:11 +0100 |
| commit | 9ec68bdb56882777e5b3670380bf1e1ad7d0a7a3 (patch) | |
| tree | bb695e485808e4d0517d84053019e2f7ddb03679 /pyecsca/ec/key_generation.py | |
| parent | adc3cd52147f35e0a7cc9008ac96619dd89cda48 (diff) | |
| download | pyecsca-9ec68bdb56882777e5b3670380bf1e1ad7d0a7a3.tar.gz pyecsca-9ec68bdb56882777e5b3670380bf1e1ad7d0a7a3.tar.zst pyecsca-9ec68bdb56882777e5b3670380bf1e1ad7d0a7a3.zip | |
Diffstat (limited to 'pyecsca/ec/key_generation.py')
| -rw-r--r-- | pyecsca/ec/key_generation.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/pyecsca/ec/key_generation.py b/pyecsca/ec/key_generation.py index 6476cac..d506585 100644 --- a/pyecsca/ec/key_generation.py +++ b/pyecsca/ec/key_generation.py @@ -1,3 +1,6 @@ +""" +This module provides a key generator for elliptic curve keypairs. +""" from typing import Tuple from public import public @@ -30,12 +33,22 @@ class KeyGeneration(object): affine: bool def __init__(self, mult: ScalarMultiplier, params: DomainParameters, affine: bool = False): + """ + :param mult: The scalar multiplier to use during key generation. + :param params: The domain parameters over which to generate the keypair. + :param affine: Whether to transform the public key point to the affine form during key generation. + """ self.mult = mult self.params = params self.mult.init(self.params, self.params.generator) self.affine = affine def generate(self) -> Tuple[Mod, Point]: + """ + Generate a keypair. + + :return: The generated keypair, a `tuple` of the private key (scalar) and the public key (point). + """ with KeygenAction(self.params) as action: privkey = Mod.random(self.params.order) pubkey = self.mult.multiply(privkey.x) |
