pyecsca.ec.configuration module

Provides a way to work with and enumerate implementation configurations.

class EnumDefine(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: Enum

classmethod names()[source]
classmethod values()[source]
class Multiplication(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: EnumDefine

Base multiplication algorithm to use.

TOOM_COOK = 'MUL_TOOM_COOK'[source]
KARATSUBA = 'MUL_KARATSUBA'[source]
COMBA = 'MUL_COMBA'[source]
BASE = 'MUL_BASE'[source]
classmethod names()[source]
classmethod values()[source]
class Squaring(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: EnumDefine

Base squaring algorithm to use.

TOOM_COOK = 'SQR_TOOM_COOK'[source]
KARATSUBA = 'SQR_KARATSUBA'[source]
COMBA = 'SQR_COMBA'[source]
BASE = 'SQR_BASE'[source]
classmethod names()[source]
classmethod values()[source]
class Reduction(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: EnumDefine

Modular reduction method used.

BARRETT = 'RED_BARRETT'[source]
MONTGOMERY = 'RED_MONTGOMERY'[source]
BASE = 'RED_BASE'[source]
classmethod names()[source]
classmethod values()[source]
class Inversion(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: EnumDefine

Inversion algorithm used.

GCD = 'INV_GCD'[source]
EULER = 'INV_EULER'[source]
classmethod names()[source]
classmethod values()[source]
class HashType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: EnumDefine

Hash algorithm used in ECDH and ECDSA.

NONE = 'HASH_NONE'[source]
SHA1 = 'HASH_SHA1'[source]
SHA224 = 'HASH_SHA224'[source]
SHA256 = 'HASH_SHA256'[source]
SHA384 = 'HASH_SHA384'[source]
SHA512 = 'HASH_SHA512'[source]
classmethod names()[source]
classmethod values()[source]
class RandomMod(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: EnumDefine

Method of sampling a uniform integer modulo order.

SAMPLE = 'MOD_RAND_SAMPLE'[source]
REDUCE = 'MOD_RAND_REDUCE'[source]
classmethod names()[source]
classmethod values()[source]
class Configuration(model, coords, formulas, scalarmult, hash_type, mod_rand, mult, sqr, red, inv)[source]

Bases: object

An ECC implementation configuration.

model: CurveModel[source]
coords: CoordinateModel[source]
formulas: FrozenSet[Formula][source]
scalarmult: ScalarMultiplier[source]
hash_type: HashType[source]
mod_rand: RandomMod[source]
mult: Multiplication[source]
sqr: Squaring[source]
red: Reduction[source]
inv: Inversion[source]
all_configurations(**kwargs)[source]

Get all implementation configurations that match the given kwargs.

The keys in kwargs should be some of the attributes in the Configuration, and the values limit the returned configurations to configuration matching them.

Note

The formulas attribute is unsupported and formulas should be provided using the scalarmult attribute, which is either a subclass of the ScalarMultiplier class or an instance of it or a dictionary giving arguments to a constructor of some ScalarMultiplier subclass.

Warning

The returned number of configurations might be quite large and take up significant memory space. Use this generator and do not store the results.

Parameters:

kwargs – The configuration parameters to match.

Return type:

Generator[Configuration, None, None]

Returns:

A generator of the configurations.