Class: BitcoinAddrgen::Curve

Inherits:
Object
  • Object
show all
Defined in:
lib/bitcoin_addrgen/addrgen.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(prime, a, b) ⇒ Curve

Returns a new instance of Curve.



32
33
34
35
36
# File 'lib/bitcoin_addrgen/addrgen.rb', line 32

def initialize(prime, a, b)
  @prime = prime
  @a = a
  @b = b
end

Instance Attribute Details

#aObject (readonly)

Returns the value of attribute a.



30
31
32
# File 'lib/bitcoin_addrgen/addrgen.rb', line 30

def a
  @a
end

#bObject (readonly)

Returns the value of attribute b.



30
31
32
# File 'lib/bitcoin_addrgen/addrgen.rb', line 30

def b
  @b
end

#primeObject (readonly)

Returns the value of attribute prime.



30
31
32
# File 'lib/bitcoin_addrgen/addrgen.rb', line 30

def prime
  @prime
end

Class Method Details

.cmp(cp1, cp2) ⇒ Object



42
43
44
45
46
47
48
# File 'lib/bitcoin_addrgen/addrgen.rb', line 42

def self.cmp(cp1, cp2)
  if cp1.a == cp2.a and cp1.b == cp2.b and cp1.prime == cp2.prime
    return 0
  else
    return 1
  end
end

Instance Method Details

#contains(x, y) ⇒ Object



38
39
40
# File 'lib/bitcoin_addrgen/addrgen.rb', line 38

def contains(x, y)
  GMP::Z.new(0) == (y**2 - (x ** 3 + @a * x + @b)).fmod(@prime)
end