Module ECP
Elliptic Curve Point Arithmetic (ECP)
Base arithmetical operations on elliptic curve point coordinates.
ECP arithmetic operations are provided to implement existing and new encryption schemes: they are elliptic curve cryptographic primitives and work the same across different curves.
It is possible to create ECP points instances using the new
method. The values of each coordinate can be imported using BIG
methods BIG.hex()
or BIG.base64()
.
Once ECP numbers are created this way, the arithmetic operations of addition, subtraction and multiplication can be executed normally using overloaded operators (+  *).
Info:
 Copyright: Dyne.org foundation 20172018
 License: GPLv3
 Author: Denis "Jaromil" Roio
Functions
new ([X=BIG[, Y=BIG]])  Create a new ECP point from two X,Y BIG arguments. 
generator ()  Returns the generator of the curve: an ECP point to its X and Y coordinates. 
Class ecp
ecp:affine ()  Make an existing ECP point affine with its curve 
ecp:infinity ()  Gives a new infinity point that is definitely not on the curve. 
ecp:isinf ()  Returns true if an ECP coordinate points to infinity (out of the curve) and false otherwise. 
ecp:mapit (BIG)  Map a BIG number to a point of the curve, where the BIG number should be the output of some hash function. 
ecp:add (first, second)  Add two ECP points to each other (commutative and associative operation). 
ecp:sub (first, second)  Subtract an ECP point from another (commutative and associative operation). 
ecp:negative ()  Transforms an ECP point into its equivalent negative point on the elliptic curve. 
ecp:double ()  Transforms an ECP pointo into the double of its value, multiplying it by two. 
ecp:mul (ecp, number)  Multiply an ECP point a number of times, indicated by an arbitrary ordinal number. 
ecp:eq (first, second)  Compares two ECP objects and returns true if they indicate the same point on the curve (they are equal) or false otherwise. 
ecp:octet (ecp)  Sets or returns an octet containing a BIG number composed by both x,y coordinates of an ECP point on the curve. 
ecp:order ()  Gives the order of the curve, a BIG number contained in an octet. 
ecp:x ()  Gives the X coordinate of the ECP point as a single BIG number. 
ecp:y ()  Gives the Y coordinate of the ECP point as a single BIG number. 
Functions
 new ([X=BIG[, Y=BIG]])

Create a new ECP point from two X,Y BIG arguments. If no X,Y arguments are specified then the ECP points to the curve's generator coordinates. If the first argument is an X coordinate on the curve and Y is just a number 0 or 1 then Y is calculated from the curve equation according to the given sign (plus or minus).
(X,Y)
Parameters:
 X a BIG number on the curve (default BIG)
 Y a BIG number on the curve, 0 or 1 to calculate it (default BIG)
Returns:

a new ECP point on the curve at X,Y coordinates or Infinity
See also:
 generator ()

Returns the generator of the curve: an ECP point to its X and Y coordinates. ()
Returns:

ECP coordinates of the curve's generator.
Class ecp
Instance Methods ecp:affine ()
 Make an existing ECP point affine with its curve ()
 ecp:infinity ()

Gives a new infinity point that is definitely not on the curve. ()
Returns:

ECP pointing to infinity out of the curve.
 ecp:isinf ()

Returns true if an ECP coordinate points to infinity (out of the curve) and false otherwise. ()
Returns:

false if point is on curve, true if its off curve into infinity.
 ecp:mapit (BIG)

Map a BIG number to a point of the curve, where the BIG number should be the output of some hash function. (BIG)
Parameters:
 BIG number resulting from an hash function
 ecp:add (first, second)

Add two ECP points to each other (commutative and associative operation). Can be made using the overloaded operator
+
between two ECP objects just like the would be numbers. (first,second)Parameters:
 first number to be summed
 second number to be summed
Returns:

sum resulting from the addition
 ecp:sub (first, second)

Subtract an ECP point from another (commutative and associative operation). Can be made using the overloaded operator

between two ECP objects just like the would be numbers. (first,second)Parameters:
 first number from which the second should be subtracted
 second number to use in the subtraction
Returns:

new ECP point resulting from the subtraction
 ecp:negative ()
 Transforms an ECP point into its equivalent negative point on the elliptic curve. ()
 ecp:double ()
 Transforms an ECP pointo into the double of its value, multiplying it by two. This works faster than multiplying it an arbitrary number of times. ()
 ecp:mul (ecp, number)

Multiply an ECP point a number of times, indicated by an arbitrary ordinal number. Can be made using the overloaded operator
*
between an ECP object and an integer number. (ecp,num)Parameters:
 ecp point on the elliptic curve to be multiplied
 number indicating how many times it should be multiplied
Returns:

new ecp point resulting from the multiplication
 ecp:eq (first, second)

Compares two ECP objects and returns true if they indicate the same point on the curve (they are equal) or false otherwise. It can also be executed by using the
==
overloaded operator. (first,second)Parameters:
 first ecp point to be compared
 second ecp point to be compared
Returns:

bool value: true if equal, false if not equal
 ecp:octet (ecp)

Sets or returns an octet containing a BIG number composed by both x,y coordinates of an ECP point on the curve. It can be used to port the value of an ECP point into OCTET:hex or OCTET:base64 encapsulation, to be later set again into an ECP point using this same call.
(ecp)
Parameters:
 ecp [opt=octet] the octet to be imported, none if to be exported
 ecp:order ()

Gives the order of the curve, a BIG number contained in an octet. ()
Returns:

a BIG containing the curve's order
 ecp:x ()

Gives the X coordinate of the ECP point as a single BIG number. ()
Returns:

a BIG number indicating the X coordinate of the point on curve.
 ecp:y ()

Gives the Y coordinate of the ECP point as a single BIG number. ()
Returns:

a BIG number indicating the Y coordinate of the point on curve.