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 ECConfig[source]

Bases: object

Configuration for the pyecsca.ec package.

property no_inverse_action: str[source]

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

One of:

property non_residue_action: str[source]

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[source]

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[source]

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[source]

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

One of:

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

  • "flint": Requires the flint library and python-flint package.

  • "python": Doesn’t require anything.

  • "symbolic": Requires sympy.

class LoggingConfig[source]

Bases: object

Logging configuration.

enabled: bool = True[source]

Whether logging is enabled.

class Config[source]

Bases: object

Runtime configuration for the library.

ec: ECConfig[source]

Configuration for the pyecsca.ec package.

log: LoggingConfig[source]

Logging configuration.

getconfig()[source]

Get the current config.

Return type:

Config

Returns:

The current config.

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.

resetconfig(token)[source]

Reset the config to the previous one.

Parameters:

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

Return type:

None

class 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][source]