pyecsca.ec.formula.fake module

Provides “fake” formulas.

class FakeFormula(coordinate_model)[source]

Bases: Formula, ABC

No matter what the input point is, it just returns the right amount of FakePoints.

Useful for computing with the scalar multipliers without having concrete formulas and points (for example to get the addition chain via the MultipleContext).

coordinate_model: Any[source]

Coordinate model of the formula.

code: List[CodeOp][source]

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

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.

shortname: ClassVar[str][source]

A shortname for the type 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).

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.

class FakeAdditionFormula(coordinate_model)[source]

Bases: FakeFormula, AdditionFormula

name: str = 'fake'[source]

Name of the formula.

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.

num_inputs: ClassVar[int] = 2[source]

Number of inputs (points) of the formula.

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.

num_outputs: ClassVar[int] = 1[source]

Number of outputs (points) of the formula.

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.

shortname: ClassVar[str] = 'add'[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.

unified: bool[source]

Whether the formula specifies that it is unified.

class FakeDoublingFormula(coordinate_model)[source]

Bases: FakeFormula, DoublingFormula

name: str = 'fake'[source]

Name of the formula.

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.

num_inputs: ClassVar[int] = 1[source]

Number of inputs (points) of the formula.

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.

num_outputs: ClassVar[int] = 1[source]

Number of outputs (points) of the formula.

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.

shortname: ClassVar[str] = 'dbl'[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.

unified: bool[source]

Whether the formula specifies that it is unified.

class FakeTriplingFormula(coordinate_model)[source]

Bases: FakeFormula, TriplingFormula

name: str = 'fake'[source]

Name of the formula.

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.

num_inputs: ClassVar[int] = 1[source]

Number of inputs (points) of the formula.

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.

num_outputs: ClassVar[int] = 1[source]

Number of outputs (points) of the formula.

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.

shortname: ClassVar[str] = 'tpl'[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.

unified: bool[source]

Whether the formula specifies that it is unified.

class FakeNegationFormula(coordinate_model)[source]

Bases: FakeFormula, NegationFormula

name: str = 'fake'[source]

Name of the formula.

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.

num_inputs: ClassVar[int] = 1[source]

Number of inputs (points) of the formula.

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.

num_outputs: ClassVar[int] = 1[source]

Number of outputs (points) of the formula.

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.

shortname: ClassVar[str] = 'neg'[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.

unified: bool[source]

Whether the formula specifies that it is unified.

class FakeScalingFormula(coordinate_model)[source]

Bases: FakeFormula, ScalingFormula

name: str = 'fake'[source]

Name of the formula.

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.

num_inputs: ClassVar[int] = 1[source]

Number of inputs (points) of the formula.

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.

num_outputs: ClassVar[int] = 1[source]

Number of outputs (points) of the formula.

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.

shortname: ClassVar[str] = 'scl'[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.

unified: bool[source]

Whether the formula specifies that it is unified.

class FakeDifferentialAdditionFormula(coordinate_model)[source]

Bases: FakeFormula, DifferentialAdditionFormula

name: str = 'fake'[source]

Name of the formula.

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.

num_inputs: ClassVar[int] = 3[source]

Number of inputs (points) of the formula.

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.

num_outputs: ClassVar[int] = 1[source]

Number of outputs (points) of the formula.

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.

shortname: ClassVar[str] = 'dadd'[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.

unified: bool[source]

Whether the formula specifies that it is unified.

class FakeLadderFormula(coordinate_model)[source]

Bases: FakeFormula, LadderFormula

name: str = 'fake'[source]

Name of the formula.

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.

num_inputs: ClassVar[int] = 3[source]

Number of inputs (points) of the formula.

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.

num_outputs: ClassVar[int] = 2[source]

Number of outputs (points) of the formula.

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.

shortname: ClassVar[str] = 'ladd'[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.

unified: bool[source]

Whether the formula specifies that it is unified.

class FakePoint(model)[source]

Bases: Point

Just a fake point.

equals(other)[source]

Test whether this point is equal to other irrespective of the coordinate model (in the affine sense).

Return type:

bool

equals_affine(other)[source]

Test whether this point is equal to other irrespective of the coordinate model (in the affine sense).

Return type:

bool

equals_scaled(other)[source]

Test whether this point is equal to other using the “z” scaling formula.

The “z” scaling formula maps the projective class to a single representative.

Parameters:

other (Point) – The point to compare

Raises:

ValueError – If the “z” formula is not available for the coordinate system.

Return type:

bool

Returns:

Whether the points are equal.

to_affine()[source]

Convert this point into the affine coordinate model, if possible.

Return type:

Point

to_model(coordinate_model, curve, randomized=False)[source]

Convert an affine point into a given coordinate model, if possible.

Return type:

Point

coordinate_model: CoordinateModel[source]
coords: Mapping[str, Mod][source]
field: int[source]