class Ecc::Curve

Attributes

a[RW]
b[RW]
fp[RW]

Public Class Methods

new(a, b, fp) click to toggle source
# File lib/ecc/curve.rb, line 7
def initialize(a, b, fp)
  
  @a = a
  @b = b
  @fp = fp
  
  raise "not elliptic curve" if 4 * (@a ** 3) + 27 * (@b ** 2) == 0
  
end

Public Instance Methods

belong?(x,y) click to toggle source
# File lib/ecc/curve.rb, line 17
def belong?(x,y)
  
  return (y ** 2) % @fp == (x ** 3 + @a * x + @b) % @fp
  
end
point_order(x, y) click to toggle source
# File lib/ecc/curve.rb, line 23
def point_order(x, y)
  
  p2 = Point.new(self, x, y)
  
  i = 2
  loop do
    break if p * i == p2
    i += 1
  end
  i
end