Top Level Namespace

Defined Under Namespace

Modules: BitcoinAddrgen, GMP

Instance Method Summary collapse

Instance Method Details

#gmp_add(a, b) ⇒ Object



73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/bitcoin_addrgen/addrgen.rb', line 73

def gmp_add(a, b)
  ptr = FFI::MemoryPointer.new :char, 16
  GMP::collect(ptr)
  if a.instance_of? Fixnum
    GMP::__gmpz_add_ui(ptr, b, a)
  elsif b.instance_of? Fixnum
    GMP::__gmpz_add_ui(ptr, a, b)
  else
    GMP::__gmpz_add(ptr, a, b)
  end
  ptr
end

#gmp_and(a, b) ⇒ Object



86
87
88
89
90
91
# File 'lib/bitcoin_addrgen/addrgen.rb', line 86

def gmp_and(a, b)
  ptr = FFI::MemoryPointer.new :char, 16
  GMP::collect(ptr)
  GMP::__gmpz_and(ptr, a, b)
  ptr
end

#gmp_cmp(a, b) ⇒ Object



93
94
95
96
97
98
99
100
101
102
103
# File 'lib/bitcoin_addrgen/addrgen.rb', line 93

def gmp_cmp(a, b)
  if a.instance_of? Fixnum and b.instance_of? Fixnum
    a <=> b
  elsif a.instance_of? Fixnum
    -GMP::__gmpz_cmp_si(b, a)
  elsif b.instance_of? Fixnum
    GMP::__gmpz_cmp_si(a, b)
  else
    GMP::__gmpz_cmp(a, b)
  end
end

#gmp_div(a, b) ⇒ Object



105
106
107
108
109
110
# File 'lib/bitcoin_addrgen/addrgen.rb', line 105

def gmp_div(a, b)
  ptr = FFI::MemoryPointer.new :char, 16
  GMP::collect(ptr)
  GMP::__gmpz_fdiv_q_ui(ptr, a, b)
  ptr
end

#gmp_init(str, base) ⇒ Object



62
63
64
65
66
67
# File 'lib/bitcoin_addrgen/addrgen.rb', line 62

def gmp_init(str, base)
  ptr = FFI::MemoryPointer.new :char, 16
  GMP::collect(ptr)
  GMP::__gmpz_init_set_str(ptr, str, base)
  ptr
end

#gmp_invert(a, b) ⇒ Object



112
113
114
115
116
117
# File 'lib/bitcoin_addrgen/addrgen.rb', line 112

def gmp_invert(a, b)
  ptr = FFI::MemoryPointer.new :char, 16
  GMP::collect(ptr)
  GMP::__gmpz_invert(ptr, a, b)
  ptr
end

#gmp_mod(a, b) ⇒ Object



119
120
121
122
123
124
# File 'lib/bitcoin_addrgen/addrgen.rb', line 119

def gmp_mod(a, b)
  ptr = FFI::MemoryPointer.new :char, 16
  GMP::collect(ptr)
  GMP::__gmpz_fdiv_r(ptr, a, b)
  ptr
end

#gmp_mul(a, b) ⇒ Object



126
127
128
129
130
131
132
133
134
135
136
137
# File 'lib/bitcoin_addrgen/addrgen.rb', line 126

def gmp_mul(a, b)
  ptr = FFI::MemoryPointer.new :char, 16
  GMP::collect(ptr)
  if a.instance_of? Fixnum
    GMP::__gmpz_mul_si(ptr, b, a)
  elsif b.instance_of? Fixnum
    GMP::__gmpz_mul_si(ptr, a, b)
  else
    GMP::__gmpz_mul(ptr, a, b)
  end
  ptr
end

#gmp_neg(a) ⇒ Object



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

def gmp_neg(a)
  ptr = FFI::MemoryPointer.new :char, 16
  GMP::collect(ptr)
  GMP::__gmpz_neg(ptr, a)
  ptr
end

#gmp_pow(a, b) ⇒ Object



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

def gmp_pow(a, b)
  ptr = FFI::MemoryPointer.new :char, 16
  GMP::collect(ptr)
  GMP::__gmpz_pow_ui(ptr, a, b)
  ptr
end

#gmp_strval(op, base) ⇒ Object



69
70
71
# File 'lib/bitcoin_addrgen/addrgen.rb', line 69

def gmp_strval(op, base)
  GMP::__gmpz_get_str(nil, base, op)
end

#gmp_sub(a, b) ⇒ Object



153
154
155
156
157
158
# File 'lib/bitcoin_addrgen/addrgen.rb', line 153

def gmp_sub(a, b)
  ptr = FFI::MemoryPointer.new :char, 16
  GMP::collect(ptr)
  GMP::__gmpz_sub(ptr, a, b)
  ptr
end