class EllipticCurve::PrivateKey

Attributes

openSslPrivateKey[R]

Public Class Methods

fromDer(string) click to toggle source
# File lib/privatekey.rb, line 43
def self.fromDer(string)
    return PrivateKey.new(nil, OpenSSL::PKey::EC.new(string))
end
fromPem(string) click to toggle source
# File lib/privatekey.rb, line 39
def self.fromPem(string)
    return PrivateKey.new(nil, OpenSSL::PKey::EC.new(string))
end
fromString(string) click to toggle source
# File lib/privatekey.rb, line 47
def self.fromString(string)
    return PrivateKey.new(nil, OpenSSL::PKey::EC.new(Base64.decode64(string)))
end
new(curve="secp256k1", openSslKey=nil) click to toggle source
# File lib/privatekey.rb, line 10
def initialize(curve="secp256k1", openSslKey=nil)
    if openSslKey.nil?
        @openSslPrivateKey = OpenSSL::PKey::EC.new(curve)
        @openSslPrivateKey.generate_key
    else
        @openSslPrivateKey = openSslKey
    end
end

Public Instance Methods

publicKey() click to toggle source
# File lib/privatekey.rb, line 21
def publicKey
    dupKey = OpenSSL::PKey::EC.new(@openSslPrivateKey.to_der())
    dupKey.private_key = nil
    return PublicKey.new(dupKey)
end
toDer() click to toggle source
# File lib/privatekey.rb, line 31
def toDer
    return @openSslPrivateKey.to_der()
end
toPem() click to toggle source
# File lib/privatekey.rb, line 35
def toPem
    return @openSslPrivateKey.to_pem()
end
toString() click to toggle source
# File lib/privatekey.rb, line 27
def toString
    return Base64.encode64(self.toDer())
end