pyecsca.misc.cfg module

Provides functions for runtime configuration of the toolkit.

This includes how errors are handled, or which Mod implementation is used.

class pyecsca.misc.cfg.ECConfig[source]

Bases: object

Configuration for the pyecsca.ec package.

property no_inverse_action: str

Return or set the action to take when a non-invertible element is to be inverted.

One of:

property non_residue_action: str

Return or set the action to take when a the square-root of a non-residue is to be computed.

One of:

property unsatisfied_formula_assumption_action: str

Return or set the action to take when a formula assumption is unsatisfied during execution.

This works for assumption that can be ignored without a fatal error, which are those that are not used to compute a value of an undefined parameter. For example, things of the form Z1 = 1. One of:

property unsatisfied_coordinate_assumption_action: str

Return or set the action to take when a coordinate assumption is unsatisfied during curve creation.

This works for assumption that can be ignored without a fatal error, which are those that are not used to compute a value of an undefined parameter. For example, things of the form a = -1. One of:

property mod_implementation: str

Return or set the selected pyecsca.ec.mod.Mod implementation.

One of:

  • "gmp": Requires the GMP library and gmpy2 package.

  • "python": Doesn’t require anything.

  • "symbolic": Requires sympy.

class pyecsca.misc.cfg.LoggingConfig[source]

Bases: object

Logging configuration.

enabled: bool = True

Whether logging is enabled.

class pyecsca.misc.cfg.Config[source]

Bases: object

Runtime configuration for the library.

ec: ECConfig

Configuration for the pyecsca.ec package.

log: LoggingConfig

Logging configuration.

pyecsca.misc.cfg.getconfig()[source]

Get the current config.

Return type:

Config

Returns:

The current config.

pyecsca.misc.cfg.setconfig(cfg)[source]

Set the current config.

Parameters:

cfg (Config) – The config to set.

Return type:

Token

Returns:

A token that can be used to reset the config to the previous one.

pyecsca.misc.cfg.resetconfig(token)[source]

Reset the config to the previous one.

Parameters:

token (Token) – A token from setconfig().

Return type:

None

class pyecsca.misc.cfg.TemporaryConfig[source]

Bases: object

Temporary config context manager.

Can be entered as follows:

with TemporaryConfig() as cfg:
    cfg.some_property = some_value
    ...
token: Optional[Token]