lib/stellar/key_pair.rb in stellar-base-0.0.20 vs lib/stellar/key_pair.rb in stellar-base-0.1.0
- old
+ new
@@ -1,9 +1,9 @@
module Stellar
class KeyPair
def self.from_seed(seed)
- seed_bytes = Util::Base58.stellar.check_decode(:seed, seed)
+ seed_bytes = Util::StrKey.check_decode(:seed, seed)
from_raw_seed seed_bytes
end
def self.from_raw_seed(seed_bytes)
secret_key = RbNaCl::SigningKey.new(seed_bytes)
@@ -15,11 +15,11 @@
public_key = RbNaCl::VerifyKey.new(pk_bytes)
new(public_key)
end
def self.from_address(address)
- pk_bytes = Util::Base58.stellar.check_decode(:account_id, address)
+ pk_bytes = Util::StrKey.check_decode(:account_id, address)
from_public_key(pk_bytes)
end
def self.random
secret_key = RbNaCl::SigningKey.generate
@@ -31,15 +31,15 @@
@public_key = public_key
@secret_key = secret_key
end
def account_id
- Stellar::AccountID.new :key_types_ed25519, raw_public_key
+ Stellar::AccountID.new :key_type_ed25519, raw_public_key
end
def public_key
- Stellar::PublicKey.new :key_types_ed25519, raw_public_key
+ Stellar::PublicKey.new :key_type_ed25519, raw_public_key
end
def raw_public_key
@public_key.to_bytes
end
@@ -61,17 +61,17 @@
@public_key
end
def address
pk_bytes = raw_public_key
- Util::Base58.stellar.check_encode(:account_id, pk_bytes)
+ Util::StrKey.check_encode(:account_id, pk_bytes)
end
def seed
raise "no private key" if @secret_key.nil?
#TODO: improve the error class above
seed_bytes = raw_seed
- encoder = Util::Base58.stellar.check_encode(:seed, seed_bytes)
+ encoder = Util::StrKey.check_encode(:seed, seed_bytes)
end
def sign?
!@secret_key.nil?
end