Point
in package
implements
PointInterface
This class is where the elliptic curve arithmetic takes place.
The important methods are:
- add: adds two points according to ec arithmetic
- double: doubles a point on the ec field mod p
- mul: uses double and add to achieve multiplication The rest of the methods are there for supporting the ones above.
Table of Contents
Interfaces
- PointInterface
- This is the contract for implementing Point, which encapsulates entities and operations over the points on the Elliptic Curve. Implementations must be immutable.
Properties
- $adapter : GmpMathInterface
- $curve : CurveFpInterface
- $infinity : bool
- $modAdapter : ModularArithmetic
- $order : GMP
- $windowSize : int
- $x : GMP
- $y : GMP
Methods
- __construct() : mixed
- Initialize a new instance.
- __debugInfo() : array<string|int, mixed>
- __toString() : string
- Returns the string representation of the point.
- add() : self
- Adds another point to the current one and returns the resulting point.
- cmp() : int
- Compares the current instance to another point.
- cswapValue() : mixed
- equals() : bool
- Checks whether the current instance is equal to the given point.
- getAdapter() : GmpMathInterface
- getCurve() : CurveFpInterface
- Returns the curve to which the point belongs.
- getDouble() : self
- Doubles the current point and returns the resulting point.
- getOrder() : GMP
- Returns the order of the point.
- getWindowSize() : int
- getX() : GMP
- Returns the X coordinate of the point.
- getY() : GMP
- Returns the Y coordinate of the point.
- isInfinity() : bool
- Returns true if instance is an non-finite point.
- mul() : PointInterface
- Multiplies the point by a scalar value and returns the resulting point.
- setWindowSize() : self
- cswap() : mixed
- validate() : mixed
Properties
$adapter
private
GmpMathInterface
$adapter
$curve
private
CurveFpInterface
$curve
$infinity
private
bool
$infinity
= false
$modAdapter
private
ModularArithmetic
$modAdapter
$order
private
GMP
$order
$windowSize
private
int
$windowSize
$x
private
GMP
$x
$y
private
GMP
$y
Methods
__construct()
Initialize a new instance.
public
__construct(GmpMathInterface $adapter, CurveFpInterface $curve, GMP $x, GMP $y[, GMP $order = null ][, bool $infinity = false ]) : mixed
Parameters
- $adapter : GmpMathInterface
- $curve : CurveFpInterface
- $x : GMP
- $y : GMP
- $order : GMP = null
- $infinity : bool = false
Tags
__debugInfo()
public
__debugInfo() : array<string|int, mixed>
Return values
array<string|int, mixed>__toString()
Returns the string representation of the point.
public
__toString() : string
Tags
Return values
stringadd()
Adds another point to the current one and returns the resulting point.
public
add(PointInterface $addend) : self
Parameters
- $addend : PointInterface
Tags
Return values
selfcmp()
Compares the current instance to another point.
public
cmp(PointInterface $other) : int
Parameters
- $other : PointInterface
Tags
Return values
int —A number different than 0 when current instance is less than the given point, 0 when they are equal.
cswapValue()
public
cswapValue(bool|GMP &$a, bool|GMP &$b, int $cond, int $maskBitSize) : mixed
Parameters
- $a : bool|GMP
- $b : bool|GMP
- $cond : int
- $maskBitSize : int
equals()
Checks whether the current instance is equal to the given point.
public
equals(PointInterface $other) : bool
Parameters
- $other : PointInterface
Tags
Return values
bool —true when points are equal, false otherwise.
getAdapter()
public
getAdapter() : GmpMathInterface
Return values
GmpMathInterfacegetCurve()
Returns the curve to which the point belongs.
public
getCurve() : CurveFpInterface
Tags
Return values
CurveFpInterfacegetDouble()
Doubles the current point and returns the resulting point.
public
getDouble() : self
Tags
Return values
selfgetOrder()
Returns the order of the point.
public
getOrder() : GMP
Tags
Return values
GMPgetWindowSize()
public
getWindowSize() : int
Return values
intgetX()
Returns the X coordinate of the point.
public
getX() : GMP
Tags
Return values
GMPgetY()
Returns the Y coordinate of the point.
public
getY() : GMP
Tags
Return values
GMPisInfinity()
Returns true if instance is an non-finite point.
public
isInfinity() : bool
Tags
Return values
boolmul()
Multiplies the point by a scalar value and returns the resulting point.
public
mul(GMP $n) : PointInterface
Parameters
- $n : GMP
Tags
Return values
PointInterfacesetWindowSize()
public
setWindowSize(int $n) : self
Parameters
- $n : int
Return values
selfcswap()
private
cswap(self $a, self $b, int $cond, int $curveSize) : mixed
Parameters
- $a : self
- $b : self
- $cond : int
- $curveSize : int
validate()
private
validate() : mixed