class Integer

Public Instance Methods

method_missing(method, *args) click to toggle source
Calls superclass method
# File lib/schnorr.rb, line 126
def method_missing(method, *args)
  return mod_pow(args[0], args[1]) if method == :pow && args.length < 3
  super
end
mod_pow(x, y) click to toggle source

alternative implementation of Integer#pow for ruby 2.4 and earlier.

# File lib/schnorr.rb, line 132
def mod_pow(x, y)
  return self ** x unless y
  b = self
  result = 1
  while x > 0
    result = (result * b) % y if (x & 1) == 1
    x >>= 1
    b = (b * b) % y
  end
  result
end
to_hex() click to toggle source
# File lib/schnorr.rb, line 121
def to_hex
  hex = to_s(16)
  hex.rjust((hex.length / 2.0).ceil * 2, '0')
end