KeyPair
public struct KeyPair
A struct representing a both a PrivateKey and PublicKey with helper methods to create various kinds
-
The underlying
PrivateKeyof the pairDeclaration
Swift
public let privateKey: PrivateKey
-
Create a regular (non HD)
KeyPairfrom a hex seed stringDeclaration
Swift
public static func regular(fromSeedString seedString: String) -> KeyPair?Parameters
seedStringA hex string representing a cryptographic seed (can be created from
Mnemonic)Return Value
A
KeyPairinstance, if able, nil otherwise -
Create a
KeyPairfrom a Base58 Check encoded secret key, optionaly encrypted with a passphrase. Supports both Tz1 (edsk… edes…) and Tz2 (spsk… spes…)Declaration
Swift
public static func regular(fromSecretKey secretKey: String, andPassphrase: String?) -> KeyPair? -
Create a HD
KeyPairfrom a hex seed string and optional Derivation Path (defaults to m/44’/1729’/0’/0’ ). Only TZ1 are produceableDeclaration
Swift
public static func hd(fromSeedString seedString: String, andDerivationPath derivationPath: String = HD.defaultDerivationPath) -> KeyPair?Parameters
seedStringA hex string representing a cryptographic seed (can be created from
Mnemonic)derivationPathThe derivationPath to use
Return Value
A
KeyPairinstance, if able, nil otherwise
-
Helper method to take a secp256k1 private key (for a regualr keypair) and use it to create a public key for the same curve
Declaration
Swift
public static func secp256k1PublicKey(fromPrivateKeyBytes pkBytes: [UInt8]) -> PublicKey? -
Helper method to uncompress a secp256k1 public key
Declaration
Swift
public static func secp256k1PublicKey_uncompressed(fromBytes: [UInt8]) -> [UInt8] -
Declaration
Swift
public static func decryptSecretKey(_ secretKey: String, ellipticalCurve: EllipticalCurve, passphrase: String) -> KeyPair? -
Declaration
Swift
public static func pbkdf2(password: String, saltData: Data, keyByteCount: Int, prf: CCPseudoRandomAlgorithm, rounds: Int) -> Data? -
Declaration
Swift
public static func isSecretKeyEncrypted(_ secret: String) -> Bool
Install in Dash