pyecsca.ec.formula.base module

Provides an abstract base class of a formula.

class OpResult(name, value, op, *parents)[source]

Bases: object

Result of an operation.

parents: Tuple[source]
name: str[source]
value: Mod[source]
op: OpType[source]
class FormulaAction(formula, *points, **inputs)[source]

Bases: ResultAction

Execution of a formula, on some input points and parameters, with some outputs.

formula: Formula[source]

The formula that was executed.

inputs: MutableMapping[str, Mod][source]

The input variables (point coordinates and parameters).

intermediates: MutableMapping[str, List[OpResult]][source]

Intermediates computed during execution.

op_results: List[OpResult][source]

The intermediates but ordered as they were computed.

outputs: MutableMapping[str, OpResult][source]

The output variables.

input_points: List[Any][source]

The input points.

output_points: List[Any][source]

The output points.

add_operation(op, value)[source]
add_result(point, **outputs)[source]
exit(result)[source]
property result: Any[source]

The result of the action.

inside: bool[source]
class Formula[source]

Bases: ABC

Formula operating on points.

name: str[source]

Name of the formula.

shortname: ClassVar[str][source]

A shortname for the type of the formula.

coordinate_model: Any[source]

Coordinate model of the formula.

meta: MutableMapping[str, Any][source]

Meta information about the formula, such as its source.

parameters: List[str][source]

Formula parameters (i.e. new parameters introduced by the formula, like half = 1/2).

assumptions: List[Expression][source]

Assumptions of the formula (e.g. Z1 == 1 or 2*half == 1).

code: List[CodeOp][source]

The collection of ops that constitute the code of the formula.

num_inputs: ClassVar[int][source]

Number of inputs (points) of the formula.

num_outputs: ClassVar[int][source]

Number of outputs (points) of the formula.

unified: bool[source]

Whether the formula specifies that it is unified.

property assumptions_str[source]
property input_index[source]

Return the starting index where this formula reads its inputs.

property output_index[source]

Return the starting index where this formula stores its outputs.

property inputs[source]

Return the input variables of the formula.

property outputs[source]

Return the output variables of the formula.

property num_operations: int[source]

Return the number of operations.

property num_multiplications: int[source]

Return the number of multiplications.

property num_divisions: int[source]

Return the number of divisions.

property num_inversions: int[source]

Return the number of inversions.

property num_powers: int[source]

Return the number of powers.

property num_squarings: int[source]

Return the number of squarings.

property num_addsubs: int[source]

Return the number of additions and subtractions.

class AdditionFormula[source]

Bases: Formula, ABC

Formula that adds two points.

property assumptions_str[source]
property input_index[source]

Return the starting index where this formula reads its inputs.

property inputs[source]

Return the input variables of the formula.

property num_addsubs: int[source]

Return the number of additions and subtractions.

property num_divisions: int[source]

Return the number of divisions.

property num_inversions: int[source]

Return the number of inversions.

property num_multiplications: int[source]

Return the number of multiplications.

property num_operations: int[source]

Return the number of operations.

property num_powers: int[source]

Return the number of powers.

property num_squarings: int[source]

Return the number of squarings.

property output_index[source]

Return the starting index where this formula stores its outputs.

property outputs[source]

Return the output variables of the formula.

name: str[source]

Name of the formula.

coordinate_model: Any[source]

Coordinate model of the formula.

meta: MutableMapping[str, Any][source]

Meta information about the formula, such as its source.

parameters: List[str][source]

Formula parameters (i.e. new parameters introduced by the formula, like half = 1/2).

assumptions: List[Expression][source]

Assumptions of the formula (e.g. Z1 == 1 or 2*half == 1).

code: List[CodeOp][source]

The collection of ops that constitute the code of the formula.

unified: bool[source]

Whether the formula specifies that it is unified.

shortname: ClassVar[str] = 'add'[source]

A shortname for the type of the formula.

num_inputs: ClassVar[int] = 2[source]

Number of inputs (points) of the formula.

num_outputs: ClassVar[int] = 1[source]

Number of outputs (points) of the formula.

class DoublingFormula[source]

Bases: Formula, ABC

Formula that doubles a point.

property assumptions_str[source]
property input_index[source]

Return the starting index where this formula reads its inputs.

property inputs[source]

Return the input variables of the formula.

property num_addsubs: int[source]

Return the number of additions and subtractions.

property num_divisions: int[source]

Return the number of divisions.

property num_inversions: int[source]

Return the number of inversions.

property num_multiplications: int[source]

Return the number of multiplications.

property num_operations: int[source]

Return the number of operations.

property num_powers: int[source]

Return the number of powers.

property num_squarings: int[source]

Return the number of squarings.

property output_index[source]

Return the starting index where this formula stores its outputs.

property outputs[source]

Return the output variables of the formula.

name: str[source]

Name of the formula.

coordinate_model: Any[source]

Coordinate model of the formula.

meta: MutableMapping[str, Any][source]

Meta information about the formula, such as its source.

parameters: List[str][source]

Formula parameters (i.e. new parameters introduced by the formula, like half = 1/2).

assumptions: List[Expression][source]

Assumptions of the formula (e.g. Z1 == 1 or 2*half == 1).

code: List[CodeOp][source]

The collection of ops that constitute the code of the formula.

unified: bool[source]

Whether the formula specifies that it is unified.

shortname: ClassVar[str] = 'dbl'[source]

A shortname for the type of the formula.

num_inputs: ClassVar[int] = 1[source]

Number of inputs (points) of the formula.

num_outputs: ClassVar[int] = 1[source]

Number of outputs (points) of the formula.

class TriplingFormula[source]

Bases: Formula, ABC

Formula that triples a point.

property assumptions_str[source]
property input_index[source]

Return the starting index where this formula reads its inputs.

property inputs[source]

Return the input variables of the formula.

property num_addsubs: int[source]

Return the number of additions and subtractions.

property num_divisions: int[source]

Return the number of divisions.

property num_inversions: int[source]

Return the number of inversions.

property num_multiplications: int[source]

Return the number of multiplications.

property num_operations: int[source]

Return the number of operations.

property num_powers: int[source]

Return the number of powers.

property num_squarings: int[source]

Return the number of squarings.

property output_index[source]

Return the starting index where this formula stores its outputs.

property outputs[source]

Return the output variables of the formula.

name: str[source]

Name of the formula.

coordinate_model: Any[source]

Coordinate model of the formula.

meta: MutableMapping[str, Any][source]

Meta information about the formula, such as its source.

parameters: List[str][source]

Formula parameters (i.e. new parameters introduced by the formula, like half = 1/2).

assumptions: List[Expression][source]

Assumptions of the formula (e.g. Z1 == 1 or 2*half == 1).

code: List[CodeOp][source]

The collection of ops that constitute the code of the formula.

unified: bool[source]

Whether the formula specifies that it is unified.

shortname: ClassVar[str] = 'tpl'[source]

A shortname for the type of the formula.

num_inputs: ClassVar[int] = 1[source]

Number of inputs (points) of the formula.

num_outputs: ClassVar[int] = 1[source]

Number of outputs (points) of the formula.

class NegationFormula[source]

Bases: Formula, ABC

Formula that negates a point.

property assumptions_str[source]
property input_index[source]

Return the starting index where this formula reads its inputs.

property inputs[source]

Return the input variables of the formula.

property num_addsubs: int[source]

Return the number of additions and subtractions.

property num_divisions: int[source]

Return the number of divisions.

property num_inversions: int[source]

Return the number of inversions.

property num_multiplications: int[source]

Return the number of multiplications.

property num_operations: int[source]

Return the number of operations.

property num_powers: int[source]

Return the number of powers.

property num_squarings: int[source]

Return the number of squarings.

property output_index[source]

Return the starting index where this formula stores its outputs.

property outputs[source]

Return the output variables of the formula.

name: str[source]

Name of the formula.

coordinate_model: Any[source]

Coordinate model of the formula.

meta: MutableMapping[str, Any][source]

Meta information about the formula, such as its source.

parameters: List[str][source]

Formula parameters (i.e. new parameters introduced by the formula, like half = 1/2).

assumptions: List[Expression][source]

Assumptions of the formula (e.g. Z1 == 1 or 2*half == 1).

code: List[CodeOp][source]

The collection of ops that constitute the code of the formula.

unified: bool[source]

Whether the formula specifies that it is unified.

shortname: ClassVar[str] = 'neg'[source]

A shortname for the type of the formula.

num_inputs: ClassVar[int] = 1[source]

Number of inputs (points) of the formula.

num_outputs: ClassVar[int] = 1[source]

Number of outputs (points) of the formula.

class ScalingFormula[source]

Bases: Formula, ABC

Formula that somehow scales the point (to a given representative of a projective class).

property assumptions_str[source]
property input_index[source]

Return the starting index where this formula reads its inputs.

property inputs[source]

Return the input variables of the formula.

property num_addsubs: int[source]

Return the number of additions and subtractions.

property num_divisions: int[source]

Return the number of divisions.

property num_inversions: int[source]

Return the number of inversions.

property num_multiplications: int[source]

Return the number of multiplications.

property num_operations: int[source]

Return the number of operations.

property num_powers: int[source]

Return the number of powers.

property num_squarings: int[source]

Return the number of squarings.

property output_index[source]

Return the starting index where this formula stores its outputs.

property outputs[source]

Return the output variables of the formula.

name: str[source]

Name of the formula.

coordinate_model: Any[source]

Coordinate model of the formula.

meta: MutableMapping[str, Any][source]

Meta information about the formula, such as its source.

parameters: List[str][source]

Formula parameters (i.e. new parameters introduced by the formula, like half = 1/2).

assumptions: List[Expression][source]

Assumptions of the formula (e.g. Z1 == 1 or 2*half == 1).

code: List[CodeOp][source]

The collection of ops that constitute the code of the formula.

unified: bool[source]

Whether the formula specifies that it is unified.

shortname: ClassVar[str] = 'scl'[source]

A shortname for the type of the formula.

num_inputs: ClassVar[int] = 1[source]

Number of inputs (points) of the formula.

num_outputs: ClassVar[int] = 1[source]

Number of outputs (points) of the formula.

class DifferentialAdditionFormula[source]

Bases: Formula, ABC

Differential addition formula that adds two points with a known difference.

The first input point is the difference of the third input and the second input (P[0] = P[2] - P[1]).

property assumptions_str[source]
property input_index[source]

Return the starting index where this formula reads its inputs.

property inputs[source]

Return the input variables of the formula.

property num_addsubs: int[source]

Return the number of additions and subtractions.

property num_divisions: int[source]

Return the number of divisions.

property num_inversions: int[source]

Return the number of inversions.

property num_multiplications: int[source]

Return the number of multiplications.

property num_operations: int[source]

Return the number of operations.

property num_powers: int[source]

Return the number of powers.

property num_squarings: int[source]

Return the number of squarings.

property output_index[source]

Return the starting index where this formula stores its outputs.

property outputs[source]

Return the output variables of the formula.

name: str[source]

Name of the formula.

coordinate_model: Any[source]

Coordinate model of the formula.

meta: MutableMapping[str, Any][source]

Meta information about the formula, such as its source.

parameters: List[str][source]

Formula parameters (i.e. new parameters introduced by the formula, like half = 1/2).

assumptions: List[Expression][source]

Assumptions of the formula (e.g. Z1 == 1 or 2*half == 1).

code: List[CodeOp][source]

The collection of ops that constitute the code of the formula.

unified: bool[source]

Whether the formula specifies that it is unified.

shortname: ClassVar[str] = 'dadd'[source]

A shortname for the type of the formula.

num_inputs: ClassVar[int] = 3[source]

Number of inputs (points) of the formula.

num_outputs: ClassVar[int] = 1[source]

Number of outputs (points) of the formula.

class LadderFormula[source]

Bases: Formula, ABC

Ladder formula for simultaneous addition of two points and doubling of the one of them, with a known difference.

The first input point is the difference of the third input and the second input (P[0] = P[2] - P[1]). The first output point is the doubling of the second input point (O[0] = 2 * P[1]). The second output point is the addition of the second and third input points (O[1] = P[1] + P[2]).

property assumptions_str[source]
property input_index[source]

Return the starting index where this formula reads its inputs.

property inputs[source]

Return the input variables of the formula.

property num_addsubs: int[source]

Return the number of additions and subtractions.

property num_divisions: int[source]

Return the number of divisions.

property num_inversions: int[source]

Return the number of inversions.

property num_multiplications: int[source]

Return the number of multiplications.

property num_operations: int[source]

Return the number of operations.

property num_powers: int[source]

Return the number of powers.

property num_squarings: int[source]

Return the number of squarings.

property output_index[source]

Return the starting index where this formula stores its outputs.

property outputs[source]

Return the output variables of the formula.

name: str[source]

Name of the formula.

coordinate_model: Any[source]

Coordinate model of the formula.

meta: MutableMapping[str, Any][source]

Meta information about the formula, such as its source.

parameters: List[str][source]

Formula parameters (i.e. new parameters introduced by the formula, like half = 1/2).

assumptions: List[Expression][source]

Assumptions of the formula (e.g. Z1 == 1 or 2*half == 1).

code: List[CodeOp][source]

The collection of ops that constitute the code of the formula.

unified: bool[source]

Whether the formula specifies that it is unified.

shortname: ClassVar[str] = 'ladd'[source]

A shortname for the type of the formula.

num_inputs: ClassVar[int] = 3[source]

Number of inputs (points) of the formula.

num_outputs: ClassVar[int] = 2[source]

Number of outputs (points) of the formula.