class EllipticCurve::P
A point on an elliptic curve
Attributes
ec[R]
x[R]
y[R]
Public Class Methods
new(ec, x, y)
click to toggle source
ec: the elliptic curve x, y: coordinates if x == Float::INFINITY, y is ignored
# File lib/elliptic_curve.rb, line 69 def initialize(ec, x, y) @ec, @x, @y = ec, x, y end
Public Instance Methods
*(d)
click to toggle source
Multiplies itself by d
# File lib/elliptic_curve.rb, line 84 def *(d) ([self] * d).inject(:+) end
+(p2)
click to toggle source
Adds p2 to self
# File lib/elliptic_curve.rb, line 79 def +(p2) @ec.add(self, p2) end
==(o)
click to toggle source
Compare with another point
# File lib/elliptic_curve.rb, line 89 def ==(o) @x == o.x && @y == o.y end
is_infinity?()
click to toggle source
returns whether x is Float::INFINITY, ignores y
# File lib/elliptic_curve.rb, line 74 def is_infinity? @x == Float::INFINITY end