Class: Ecc::Curve
- Inherits:
-
Object
- Object
- Ecc::Curve
- Defined in:
- lib/ecc/curve.rb
Instance Attribute Summary collapse
-
#a ⇒ Object
Returns the value of attribute a.
-
#b ⇒ Object
Returns the value of attribute b.
-
#fp ⇒ Object
Returns the value of attribute fp.
Instance Method Summary collapse
- #belong?(x, y) ⇒ Boolean
-
#initialize(a, b, fp) ⇒ Curve
constructor
A new instance of Curve.
- #point_order(x, y) ⇒ Object
Constructor Details
#initialize(a, b, fp) ⇒ Curve
Returns a new instance of Curve.
7 8 9 10 11 12 13 14 15 |
# 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 |
Instance Attribute Details
#a ⇒ Object
Returns the value of attribute a.
5 6 7 |
# File 'lib/ecc/curve.rb', line 5 def a @a end |
#b ⇒ Object
Returns the value of attribute b.
5 6 7 |
# File 'lib/ecc/curve.rb', line 5 def b @b end |
#fp ⇒ Object
Returns the value of attribute fp.
5 6 7 |
# File 'lib/ecc/curve.rb', line 5 def fp @fp end |
Instance Method Details
#belong?(x, y) ⇒ Boolean
17 18 19 20 21 |
# File 'lib/ecc/curve.rb', line 17 def belong?(x,y) return (y ** 2) % @fp == (x ** 3 + @a * x + @b) % @fp end |