class

Ed25519::ExtendedPoint

Inherits Reference < Object

Extended Point works in extended coordinates: (x, y, z, t) ∋ (x=x/z, y=y/z, t=xy). Default Point works in affine coordinates: (x, y) https://en.wikipedia.org/wiki/Twisted_Edwards_curve#Extended_coordinates

Constants

BASE = ExtendedPoint.new(Curve::Gx, Curve::Gy, One, Ed25519.mod(Curve::Gx * Curve::Gy))
ZERO = ExtendedPoint.new(Zero, One, One, Zero)

Constructors

from_affine(p : Point) : ExtendedPoint
Source
new(x : BigInt, y : BigInt, z : BigInt, t : BigInt)
Source

Class methods

normalize_z(points : Array(ExtendedPoint)) : Array(ExtendedPoint)
Source
to_affine_batch(points : Array(ExtendedPoint)) : Array(Point)

Takes a bunch of Jacobian Points but executes only one invert on all of them. invert is very slow operation, so this improves performance massively.

Source

Instance methods

==(other : ExtendedPoint) : Bool
Source
add(other : ExtendedPoint)

Fast algo for adding 2 Extended Points when curve's a=-1. http://hyperelliptic.org/EFD/g1p/auto-twisted-extended-1.html#addition-add-2008-hwcd-4 Cost: 8M + 8add + 2*2. Note: It does not check whether the other point is valid.

Source
double

Fast algo for doubling Extended Point when curve's a=-1. http://hyperelliptic.org/EFD/g1p/auto-twisted-extended-1.html#doubling-dbl-2008-hwcd Cost: 3M + 4S + 1a + 7add + 12.

Source
equals(other : ExtendedPoint) : Bool

Compare one point to another.

Source
multiply(scalar : Int, affine_point : Point | Nil) : ExtendedPoint

Constant time multiplication. Uses w_naf method. Windowed method may be 10% faster, but takes 2x longer to generate and consumes 2x memory.

Source
multiply_unsafe(scalar : Int) : ExtendedPoint

Non-constant-time multiplication. Uses double-and-add algorithm. It's faster, but should only be used when you don't care about an exposed private key e.g. sig verification. Allows scalar bigger than curve order, but less than 2^256

Source
negate

Inverses point to one corresponding to (x, -y) in Affine coordinates.

Source
small_order?
Source
subtract(other : ExtendedPoint) : ExtendedPoint
Source
t=(t : BigInt)
Source
to_affine(inv_z : BigInt = Ed25519.invert(@z)) : Point

Converts Extended point to default (x, y) coordinates. Can accept precomputed Z^-1 - for example, from invert_batch.

Source
torsion_free?
Source
x=(x : BigInt)
Source
y=(y : BigInt)
Source
z=(z : BigInt)
Source