EosioVault
public final class EosioVault
Utility library for managing keys and signing with Apple’s Keychain and Secure Enclave.
-
Notification you can subscribe to notifying of Keychain updates.
Declaration
Swift
public static let updateNotification: Notification.Name -
The accessGroup allows multiple apps (including extensions) in the same team to share the same Keychain.
Declaration
Swift
public let accessGroup: String -
Init with accessGroup. The accessGroup allows multiple apps (including extensions) in the same team to share the same Keychain.
Declaration
Swift
public init(accessGroup: String)Parameters
accessGroupThe access group should be an
App Groupon the developer account. -
Get the vaultIdentifierKey (a special Secure Enclave key with tag “VAULT”.) Create if not present.
Throws
If a vault key does not exist and cannot be created.Declaration
Swift
public func vaultIdentifierKey() throws -> Keychain.ECKeyReturn Value
The vault identifier key, as an ECKey.
-
Get the vaultIdentifierKey public key, as hex.
Throws
If a vault key does not exist and cannot be created.Declaration
Swift
public func vaultIdentifier() throws -> StringReturn Value
The vaultIdentifierKey public key, as hex.
-
Compute the uncompressed public key for an eosio key
Throws
If the uncompressed public key cannot be computedDeclaration
Swift
public func getUncompressedPublicKey(eosioPublicKey: String) throws -> DataParameters
eosioPublicKeyThe eosio public key
Return Value
The uncompressed public key
-
Create a new Secure Enclave key and return the Vault Key.
Throws
If a new key cannot be created.Important
Metadata must follow the rules for JSONSerialization.Declaration
Parameters
protectionAccessibility defaults to whenUnlockedThisDeviceOnly.
bioFactorThe
BioFactorfor this key.metadataAny metadata to associate with this key.
Return Value
The new key as a VaultKey.
-
Create a new elliptic curve key and return as a VaultKey.
Throws
If a new key cannot be created.Important
Metadata must follow the rules for JSONSerialization.Declaration
Parameters
secureEnclaveGenerate this key in Secure Enclave?
protectionAccessibility defaults to whenUnlockedThisDeviceOnly.
bioFactorThe
BioFactorfor this key.metadataAny metadata to associate with this key.
Return Value
The new key as a VaultKey.
-
Import an external EOSIO private key into the Keychain. Returns a VaultKey or throws an error.
Throws
If the key is not valid or cannot be imported.Important
Metadata must follow the rules for JSONSerialization.Declaration
Parameters
eosioPrivateKeyAn EOSIO private key.
protectionAccessibility defaults to .whenUnlockedThisDeviceOnly.
bioFactorThe
BioFactorfor this key.metadataAny metadata to associate with this key.
Return Value
The imported key as a VaultKey.
-
Delete a key given the public key. USE WITH CARE!
Throws
If there is an error deleting the key.Declaration
Swift
public func deleteKey(eosioPublicKey: String) throwsParameters
eosioPublicKeyThe public key for the EOSIO key to delete.
-
Update the label identifying the key.
Throws
If the label cannot be updated.Declaration
Swift
public func update(label: String, publicKey: String) throwsParameters
labelThe new value for the label.
publicKeyThe public EOSIO key.
-
Update key. (The only items that are updatable are the metadata items.)
Important
Metadata must follow the rules for JSONSerialization.Declaration
Swift
public func update(key: EosioVault.VaultKey) -> BoolParameters
keyThe VaultKey to update.
Return Value
True if the key was updated, otherwise false.
-
Get all vault keys and their metadata by combining all Keychain keys (excluding the special VAULT identifier key.)
Throws
If there is an error getting the keys.Declaration
Swift
public func getAllVaultKeys() throws -> [EosioVault.VaultKey]Return Value
An array of VaultKeys.
-
Get the vault key for the eosioPublicKey. IMPORTANT: If the key requires a biometric check for access, the system will prompt the user for FaceID/TouchID
Throws
If the key cannot be found.Declaration
Swift
public func getVaultKey(eosioPublicKey: String) throws -> EosioVault.VaultKeyParameters
eosioPublicKeyAn EOSIO public key.
Return Value
A VaultKey.
-
Sign a message with the private key corresponding to the public key if the private key is found in the Keychain. Throws an error if the public key is not valid or the key is not found.
Declaration
Swift
public func sign(message: Data, eosioPublicKey: String, requireBio: Bool, prompt: String = "Sign Transaction", completion: @escaping (String?, EosioError?) -> Void)Parameters
messageThe message to sign.
eosioPublicKeyThe EOSIO public key corresponding to the key to use for signing.
requireBioRequire biometric identification even if the key does not require it.
completionClosure returning an EOSIO signature or an error.
-
Dismiss biometrics dialogue and cancel the sign request.
Declaration
Swift
public func cancelPendingSigningRequest() -
Save metadata for the eosioPublicKey.
Important
Metadata must follow the rules for JSONSerialization.Declaration
Swift
public func saveKeyMetadata(eosioPublicKey: String, dictionary: [String : Any]) -> BoolParameters
eosioPublicKeyThe EOSIO public key.
dictionaryA metadata dictionary to save.
Return Value
True if the metadata was saved, otherwise false.
-
Delete metadata for the eosioPublicKey.
Important
Metadata must follow the rules for JSONSerialization.Declaration
Swift
public func deleteKeyMetadata(publicKey: String)Parameters
publicKeyThe public key.
-
Get metadata for the eosioPublicKey.
Important
Metadata must follow the rules for JSONSerialization.Declaration
Swift
public func getKeyMetadata(eosioPublicKey: String) -> [String : Any]?Parameters
eosioPublicKeyAn EOSIO public key.
Return Value
The metadata dictionary for the key, if existing.
-
Get metadata for all keys.
Important
Metadata must follow the rules for JSONSerialization.Declaration
Swift
public func getAllKeysMetadata() -> [String : [String : Any]]?Return Value
Dictionary of metadata dictionaries for all keys.
-
VaultKey collects properties into a single object for an EOSIO elliptic curve key.
See moreDeclaration
Swift
struct VaultKey
View on GitHub
EosioVault Class Reference