class Montgomery extends Base (View source)

Curves over y^2 = x^3 + a*x + x

Properties

protected object[] $doubles Doubles from  Base
protected BigInteger $order The Order
protected PrimeField $factory Prime Field Integer factory
protected object $a Cofficient for x
protected object $a24 Constant used for point doubling
protected object $zero The Number Zero
protected object $one The Number One
protected object $p Base Point
protected BigInteger $modulo The modulo

Methods

object
randomInteger()

Returns a random integer

from  Base
object
convertInteger(BigInteger $x)

Converts a BigInteger to a FiniteField integer

from  Base
int
getLengthInBytes()

Returns the length, in bytes, of the modulo

from  Base
int
getLength()

Returns the length, in bits, of the modulo

from  Base
array
multiplyPoint(array $p, Integer $d)

Multiply a point on the curve by a scalar

FiniteField
createRandomMultiplier()

Creates a random scalar multiplier

from  Base
setOrder(BigInteger $order)

Sets the Order

from  Base
getOrder()

Returns the Order

from  Base
object
setReduction(callable $func)

Use a custom defined modular reduction function

from  Base
object[]
convertToAffine(array $p)

Returns the affine point

object[]
convertToInternal(array $p)

Converts an affine point to an XZ coordinate

object[]
negatePoint(array $p)

Negates a point

from  Base
int[]
multiplyAddPoints(array $points, array $scalars)

Multiply and Add Points

from  Base
setModulo(BigInteger $modulo)

Sets the modulo

setCoefficients(BigInteger $a)

Set coefficients a

PrimeInteger[]
setBasePoint(BigInteger|PrimeInteger $x, BigInteger|PrimeInteger $y)

Set x and y coordinates for the base point

array
getBasePoint()

Retrieve the base point as an array

Details

object randomInteger()

Returns a random integer

Return Value

object

object convertInteger(BigInteger $x)

Converts a BigInteger to a FiniteField integer

Parameters

BigInteger $x

Return Value

object

int getLengthInBytes()

Returns the length, in bytes, of the modulo

Return Value

int

int getLength()

Returns the length, in bits, of the modulo

Return Value

int

array multiplyPoint(array $p, Integer $d)

Multiply a point on the curve by a scalar

Uses the montgomery ladder technique as described here:

https://en.wikipedia.org/wiki/Elliptic_curve_point_multiplication#Montgomery_ladder https://github.com/phpecc/phpecc/issues/16#issuecomment-59176772

Parameters

array $p
Integer $d

Return Value

array

FiniteField createRandomMultiplier()

Creates a random scalar multiplier

Return Value

FiniteField

setOrder(BigInteger $order)

Sets the Order

Parameters

BigInteger $order

BigInteger getOrder()

Returns the Order

Return Value

BigInteger

object setReduction(callable $func)

Use a custom defined modular reduction function

Parameters

callable $func

Return Value

object

object[] convertToAffine(array $p)

Returns the affine point

Parameters

array $p

Return Value

object[]

object[] convertToInternal(array $p)

Converts an affine point to an XZ coordinate

From https://hyperelliptic.org/EFD/g1p/auto-montgom-xz.html

XZ coordinates represent x y as X Z satsfying the following equations:

x=X/Z

Parameters

array $p

Return Value

object[]

object[] negatePoint(array $p)

Negates a point

Parameters

array $p

Return Value

object[]

int[] multiplyAddPoints(array $points, array $scalars)

Multiply and Add Points

Parameters

array $points
array $scalars

Return Value

int[]

setModulo(BigInteger $modulo)

Sets the modulo

Parameters

BigInteger $modulo

setCoefficients(BigInteger $a)

Set coefficients a

Parameters

BigInteger $a

PrimeInteger[] setBasePoint(BigInteger|PrimeInteger $x, BigInteger|PrimeInteger $y)

Set x and y coordinates for the base point

Parameters

BigInteger|PrimeInteger $x
BigInteger|PrimeInteger $y

Return Value

PrimeInteger[]

array getBasePoint()

Retrieve the base point as an array

Return Value

array