Remove throwing API

This commit is contained in:
keefertaylor 2018-10-28 20:25:20 +00:00
parent 324e3ae337
commit b4046066da
1 changed files with 7 additions and 4 deletions

View File

@ -66,19 +66,22 @@ public class Mnemonic: NSObject {
*/ */
public static func deterministicSeedString(from mnemonic: String, public static func deterministicSeedString(from mnemonic: String,
passphrase: String = "", passphrase: String = "",
language: MnemonicLanguageType = .english) throws -> String { language: MnemonicLanguageType = .english) -> String? {
guard let normalizedData = self.normalized(string: mnemonic), guard let normalizedData = self.normalized(string: mnemonic),
let saltData = normalized(string: "mnemonic" + passphrase) else { let saltData = normalized(string: "mnemonic" + passphrase) else {
return "" return nil
} }
let passwordBytes = normalizedData.bytes let passwordBytes = normalizedData.bytes
let saltBytes = saltData.bytes let saltBytes = saltData.bytes
do { do {
let bytes = try PKCS5.PBKDF2(password: passwordBytes, salt: saltBytes, iterations: 2048, variant: .sha512).calculate() let bytes = try PKCS5.PBKDF2(password: passwordBytes,
salt: saltBytes,
iterations: 2048,
variant: .sha512).calculate()
return bytes.toHexString() return bytes.toHexString()
} catch { } catch {
throw error throw nil
} }
} }