Class: MoneyTree::Key

Inherits:
Object
  • Object
show all
Extended by:
Support
Includes:
Support, OpenSSL
Defined in:
lib/money-tree/key.rb

Direct Known Subclasses

PrivateKey, PublicKey

Defined Under Namespace

Classes: InvalidBase64Format, InvalidWIFFormat, KeyFormatNotFound, KeyGenerationFailure, KeyImportFailure, KeyInvalid

Constant Summary collapse

GROUP_NAME =
'secp256k1'
ORDER =
"fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141".to_i(16)

Constants included from Support

Support::BASE58_CHARS, Support::INT32_MAX, Support::INT64_MAX

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Support

base58_to_int, bytes_to_hex, bytes_to_int, decode_base58, decode_base64, digestify, encode_base58, encode_base64, from_serialized_base58, hex_to_bytes, hex_to_int, hmac_sha512, hmac_sha512_hex, int_to_base58, int_to_bytes, int_to_hex, ripemd160, sha256, to_serialized_base58

Instance Attribute Details

#ec_keyObject

Returns the value of attribute ec_key.



18
19
20
# File 'lib/money-tree/key.rb', line 18

def ec_key
  @ec_key
end

#keyObject (readonly)

Returns the value of attribute key.



17
18
19
# File 'lib/money-tree/key.rb', line 17

def key
  @key
end

#optionsObject (readonly)

Returns the value of attribute options.



17
18
19
# File 'lib/money-tree/key.rb', line 17

def options
  @options
end

#raw_keyObject (readonly)

Returns the value of attribute raw_key.



17
18
19
# File 'lib/money-tree/key.rb', line 17

def raw_key
  @raw_key
end

Instance Method Details

#to_bytesObject



28
29
30
# File 'lib/money-tree/key.rb', line 28

def to_bytes
  hex_to_bytes to_hex
end

#to_iObject



32
33
34
# File 'lib/money-tree/key.rb', line 32

def to_i
  bytes_to_int to_bytes
end

#valid?(eckey = nil) ⇒ Boolean

Returns:

  • (Boolean)


23
24
25
26
# File 'lib/money-tree/key.rb', line 23

def valid?(eckey = nil)
  eckey ||= ec_key
  eckey.nil? ? false : eckey.check_key
end