Module ECP2
Twisted Elliptic Curve Point Arithmetic (ECP2)
Base arithmetical operations on twisted elliptic curve point coordinates.
ECP2 arithmetic operations are provided to implement existing and new encryption schemes: they are elliptic curve cryptographic primitives and work only on curves supporting twisting and pairing.
It is possible to create ECP2 points instances using the new
method. The values of each coordinate can be imported using BIG
methods from BIG.hex()
or BIG.base64()
.
Once ECP2 points 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
Global ECP2 functions
new (X, Xi, Y, Yi)  Create a new ECP2 point from four X,Xi,Y,Yi BIG arguments. 
generator ()  Returns the generator of the twisted curve: an ECP2 point to its X and Y coordinates. 
Class ecp2
ecp2:affine ()  Make an existing ECP2 point affine with the curve 
ecp2:isinf ()  Returns true if an ECP2 coordinate points to infinity (out of the curve) and false otherwise. 
ecp2:add (first, second)  Add two ECP2 points to each other (commutative and associative operation). 
ecp2:sub (first, second)  Subtract an ECP2 point from another (commutative and associative operation). 
ecp2:negative ()  Transforms an ECP2 point into its equivalent negative point on the elliptic curve. 
ecp2:eq (first, second)  Compares two ECP2 points and returns true if they indicate the same point on the curve (they are equal) or false otherwise. 
ecp2:octet ()  Returns an octet containing all serialized BIG number coordinatesof an ECP2 point on the curve. 
ecp2:mapit (BIG)  Map a BIG number to a point of the curve, where the BIG number should be the output of some hash function. 
Global ECP2 functions
 new (X, Xi, Y, Yi)

Create a new ECP2 point from four X,Xi,Y,Yi BIG arguments.
If no arguments are specified then the ECP points to the curve's generator coordinates.
If only the first two arguments are provided (X and Xi), then Y and Yi are calculated from them. (X,Xi,Y,Yi)
Parameters:
 X a BIG number on the curve
 Xi imaginary part of the X (BIG number)
 Y a BIG number on the curve
 Yi imaginary part of the Y (BIG number)
Returns:

a new ECP2 point on the curve at X,Xi,Y,Yi coordinates or the curve's Generator
 generator ()

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

ECP2 coordinates of the curve's generator.
Class ecp2
Class methods ecp2:affine ()

Make an existing ECP2 point affine with the curve ()
Returns:

affine version of the ECP2 point
 ecp2:isinf ()

Returns true if an ECP2 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.
 ecp2:add (first, second)

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

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

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

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

new ECP2 point resulting from the subtraction
 ecp2:negative ()
 Transforms an ECP2 point into its equivalent negative point on the elliptic curve. ()
 ecp2:eq (first, second)

Compares two ECP2 points 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 ECP2 point to be compared
 second ECP2 point to be compared
Returns:

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

Returns an octet containing all serialized BIG number coordinatesof an ECP2 point on the curve. It can be used to port the value of an ECP2 point into OCTET:hex or OCTET:base64 encapsulation, to be later set again into an ECP2 point using ECP2:new.
()
Returns:

an OCTET sequence
 ecp2: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