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.



140
141
142
143
144
# File 'lib/bitcoin_addrgen/addrgen.rb', line 140

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

Instance Attribute Details

#aObject (readonly)

Returns the value of attribute a.



138
139
140
# File 'lib/bitcoin_addrgen/addrgen.rb', line 138

def a
  @a
end

#bObject (readonly)

Returns the value of attribute b.



138
139
140
# File 'lib/bitcoin_addrgen/addrgen.rb', line 138

def b
  @b
end

#primeObject (readonly)

Returns the value of attribute prime.



138
139
140
# File 'lib/bitcoin_addrgen/addrgen.rb', line 138

def prime
  @prime
end

Class Method Details

.cmp(cp1, cp2) ⇒ Object



150
151
152
# File 'lib/bitcoin_addrgen/addrgen.rb', line 150

def self.cmp(cp1, cp2)
  gmp_cmp(cp1.a, cp2.a) or gmp_cmp(cp1.b, cp.b) or gmp_cmp(cp.prime, cp.prime)
end

Instance Method Details

#contains(x, y) ⇒ Object



146
147
148
# File 'lib/bitcoin_addrgen/addrgen.rb', line 146

def contains(x, y)
  gmp_cmp(gmp_mod(gmp_sub(gmp_pow(y, 2), gmp_add(gmp_add(gmp_pow(x, 3), gmp_mul(@a, x)), @b)), @prime), 0) == 0
end