fix a crash happening when long mnemonic is used to recover an account

pull/754/head
Ryan Zhao 2 years ago
parent 751eb8ce66
commit c867c95c7a

@ -198,7 +198,7 @@ final class RestoreVC: BaseVC {
do {
let hexEncodedSeed = try Mnemonic.decode(mnemonic: mnemonic)
let seed = Data(hex: hexEncodedSeed)
let (ed25519KeyPair, x25519KeyPair) = try! Identity.generate(from: seed)
let (ed25519KeyPair, x25519KeyPair) = try Identity.generate(from: seed)
Onboarding.Flow.recover.preregister(with: seed, ed25519KeyPair: ed25519KeyPair, x25519KeyPair: x25519KeyPair)
mnemonicTextView.resignFirstResponder()

@ -53,7 +53,7 @@ extension ECKeyPair {
public extension Identity {
static func generate(from seed: Data) throws -> (ed25519KeyPair: Sign.KeyPair, x25519KeyPair: ECKeyPair) {
assert(seed.count == 16)
guard (seed.count == 16) else { throw GeneralError.invalidSeed }
let padding = Data(repeating: 0, count: 16)
guard

@ -19,6 +19,7 @@ public enum General {
}
public enum GeneralError: Error {
case invalidSeed
case keyGenerationFailed
}

Loading…
Cancel
Save