aboutsummaryrefslogtreecommitdiff
path: root/pyecsca/ec/key_generation.py
diff options
context:
space:
mode:
Diffstat (limited to 'pyecsca/ec/key_generation.py')
-rw-r--r--pyecsca/ec/key_generation.py13
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)