class DbchainClient::PublicKey
Public Class Methods
new(pub_key)
click to toggle source
# File lib/dbchain_client/key.rb, line 6 def initialize(pub_key) # hex or raw public key if pub_key.instance_of?(Secp256k1::PublicKey) @public_key = pub_key else raw_pub_key = Secp256k1::Utils.decode_hex(pub_key) @public_key = Secp256k1::PublicKey.new(pubkey: raw_pub_key, raw: true) end end
Public Instance Methods
address()
click to toggle source
# File lib/dbchain_client/key.rb, line 27 def address @address ||= Mnemonics.public_key_to_address(public_key_hex) end
public_key_hex()
click to toggle source
# File lib/dbchain_client/key.rb, line 15 def public_key_hex @public_key.serialize.unpack('H*')[0] end
to_raw()
click to toggle source
# File lib/dbchain_client/key.rb, line 19 def to_raw @public_key.serialize end
to_s()
click to toggle source
# File lib/dbchain_client/key.rb, line 23 def to_s public_key_hex end
verify(message, signature)
click to toggle source
# File lib/dbchain_client/key.rb, line 31 def verify(message, signature) raw_sig = signature.raw @public_key.ecdsa_verify(message, raw_sig) end