Class: IOTA::Models::Seed
Instance Method Summary collapse
-
#as_trits ⇒ Object
Converter methods.
- #getAddress(index, security, checksum) ⇒ Object
-
#initialize(seed) ⇒ Seed
constructor
A new instance of Seed.
Constructor Details
#initialize(seed) ⇒ Seed
Returns a new instance of Seed.
4 5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/iota/models/seed.rb', line 4 def initialize(seed) @utils = IOTA::Utils::Utils.new # Check if correct seed if seed.class == String && !@utils.validator.isTrytes(seed) raise StandardError, "Invalid seed provided" end seed += "9" * (81 - seed.length) if seed.length < 81 @seed = seed end |
Instance Method Details
#as_trits ⇒ Object
Converter methods
28 29 30 |
# File 'lib/iota/models/seed.rb', line 28 def as_trits IOTA::Crypto::Converter.trits(@seed) end |
#getAddress(index, security, checksum) ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'lib/iota/models/seed.rb', line 17 def getAddress(index, security, checksum) pk = IOTA::Crypto::PrivateKey.new(self.as_trits, index, security) address_trits = IOTA::Crypto::Signing.address(pk.digests) address = IOTA::Crypto::Converter.trytes(address_trits) address = @utils.addChecksum(address) if checksum address end |