Begin with root key index when reading keystores.
Instead of using the zero value, explicitly set the last chain index to -1, which represents the root key. If no additional keys are read from the io.Reader, this could result in panics when looking up keys at index 0, when no additional keys have been created yet. Fixes #119.
This commit is contained in:
parent
9b14cd99f1
commit
8bc6eee32c
1 changed files with 1 additions and 0 deletions
|
@ -706,6 +706,7 @@ func (s *Store) ReadFrom(r io.Reader) (n int64, err error) {
|
|||
rootAddr := s.keyGenerator.Address()
|
||||
s.addrMap[getAddressKey(rootAddr)] = &s.keyGenerator
|
||||
s.chainIdxMap[rootKeyChainIdx] = rootAddr
|
||||
s.lastChainIdx = rootKeyChainIdx
|
||||
|
||||
// Fill unserializied fields.
|
||||
wts := appendedEntries.entries
|
||||
|
|
Loading…
Reference in a new issue