KeyPair

public struct KeyPair

A struct representing a both a PrivateKey and PublicKey with helper methods to create various kinds

Public Helpers

  • Create a regular (non HD) KeyPair from a hex seed string

    Declaration

    Swift

    public static func regular(fromSeedString seedString: String) -> KeyPair?

    Parameters

    seedString

    A hex string representing a cryptographic seed (can be created from Mnemonic)

    Return Value

    A KeyPair instance, if able, nil otherwise

  • Create a regular (non HD) KeyPair from a Mnemonic instance

    Declaration

    Swift

    public static func regular(fromMnemonic mnemonic: Mnemonic, passphrase: String) -> KeyPair?

    Parameters

    mnemonic

    An instance of Mnemonic

    Return Value

    A KeyPair instance, if able, nil otherwise

  • Create a HD KeyPair from a hex seed string and optional Derivation Path (defaults to m/44’/1729’/0’/0’ ). Only TZ1 are produceable

    Declaration

    Swift

    public static func hd(fromSeedString seedString: String, andDerivationPath derivationPath: String = HD.defaultDerivationPath) -> KeyPair?

    Parameters

    seedString

    A hex string representing a cryptographic seed (can be created from Mnemonic)

    derivationPath

    The derivationPath to use

    Return Value

    A KeyPair instance, if able, nil otherwise

  • Create a HD KeyPair from a Mnemonic instance

    Declaration

    Swift

    public static func hd(fromMnemonic mnemonic: Mnemonic, passphrase: String, andDerivationPath derivationPath: String = HD.defaultDerivationPath) -> KeyPair?

    Parameters

    mnemonic

    An instance of Mnemonic

    derivationPath

    The derivationPath to use

    Return Value

    A KeyPair instance, if able, nil otherwise

Helpers

  • 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]