EThree
@objc(VTEEThree)
open class EThree : NSObject
Main class containing all features of E3Kit
-
Typealias for the valid result of lookupPublicKeys call
Declaration
Swift
public typealias LookupResult = [String : VirgilPublicKey] -
Typealias for callback used below
Declaration
Swift
public typealias JwtStringCallback = (String?, Error?) -> Void -
Typealias for callback used below
Declaration
Swift
public typealias RenewJwtCallback = (@escaping JwtStringCallback) -> Void -
Typealias for callback used below
Declaration
Swift
public typealias PublishCardCallback = (RawSignedModel) throws -> Card -
Identity of user
Declaration
Swift
@objc public let identity: String -
CardManager instance
Declaration
Swift
@objc public let cardManager: CardManager -
AccessTokenProvider
Declaration
Swift
@objc public let accessTokenProvider: AccessTokenProvider -
LocalKeyStorage
Declaration
Swift
@objc public let localKeyStorage: LocalKeyStorage -
Offline init
Declaration
Swift
@objc public let offlineInit: Bool -
VirgilCrypto instance
Declaration
Swift
@objc public var crypto: VirgilCrypto { get } -
ChangedKeyDelegate to notify changing of User’s keys
Declaration
Swift
@objc public var changedKeyDelegate: ChangedKeyDelegate? { get } -
init(identity:tokenCallback: changedKeyDelegate: storageParams: keyPairType: enableRatchet: enableRatchetPqc: keyRotationInterval: ) Initializer
Throws
corresponding errorImportant
identity should be the same as in JWT generated at server sideDeclaration
Swift
@objc public convenience init( identity: String, tokenCallback: @escaping RenewJwtCallback, changedKeyDelegate: ChangedKeyDelegate? = nil, storageParams: KeychainStorageParams? = nil, keyPairType: KeyPairType = Defaults.keyPairType, enableRatchet: Bool = Defaults.enableRatchet, enableRatchetPqc: Bool = Defaults.enableRatchetPqc, keyRotationInterval: TimeInterval = Defaults.keyRotationInterval ) throwsParameters
identityUser identity
tokenCallbackcallback to get Virgil access token
changedKeyDelegateChangedKeyDelegateto notify about changes of User’s keysstorageParamsKeychainStorageParamswith specific parameterskeyPairTypekey pair type
enableRatchetenable ratchet
keyRotationInvervalkey rotation interval for ratchet
-
Init
Declaration
Swift
@objc public convenience init(params: EThreeParams) throwsParameters
paramsparams
-
Publishes Card on Virgil Cards Service and saves Private Key in local storage
Declaration
Swift
public func register(with keyPair: VirgilKeyPair? = nil) -> GenericOperation<Void>Parameters
keyPairVirgilKeyPairto publish Card with. Will generate if not specifiedReturn Value
CallbackOperation
-
Generates Key Pair, calls publishCardCallback and saves Private Key in local storage
Declaration
Swift
public func register( with keyPair: VirgilKeyPair? = nil, publishCardCallback: @escaping PublishCardCallback ) -> GenericOperation<Void>Parameters
keyPairVirgilKeyPairto publish Card with. Will generate if not specifiedReturn Value
CallbackOperation
-
Generates new Private Key, publishes new Card to replace the current one on Virgil Cards Service and saves new Private Key in local storage
Declaration
Swift
public func rotatePrivateKey() -> GenericOperation<Void>Return Value
CallbackOperation
-
Revokes Card from Virgil Cards Service, deletes Private Key from local storage
Declaration
Swift
public func unregister() -> GenericOperation<Void>Return Value
CallbackOperation
-
Checks existance of private key in keychain storage
Throws
KeychainStorageErrorDeclaration
Swift
public func hasLocalPrivateKey() throws -> BoolReturn Value
true if private key exists in keychain storage
-
Deletes Private Key from local storage, cleand local cards storage
Throws
KeychainStorageErrorDeclaration
Swift
@objc open func cleanUp() throws
-
Derives different passwords for login and for backup from one
Declaration
Swift
@objc public static func derivePasswords(from password: String) throws -> DerivedPasswordsParameters
passwordpassword to derive from
-
Encrypts user’s private key using password and backs up the encrypted private key to Virgil’s cloud. This enables users to log in from other devices and have access to their private key to decrypt data.
Important
Requires private key in local storageDeclaration
Swift
public func backupPrivateKey(password: String, keyName: String? = nil) -> GenericOperation<Void>Parameters
passwordString with password
keyNameoptional name of the key. Can be used to create additional key backup
Return Value
CallbackOperation
-
Restores encrypted private key from Virgil’s cloud, decrypts it using user’s password and saves it in local storage
Declaration
Swift
public func restorePrivateKey(password: String, keyName: String? = nil) -> GenericOperation<Void>Parameters
passwordString with password
keyNameoptional name of the key
Return Value
CallbackOperation
-
Changes the password on a backed-up private key.
Declaration
Swift
public func changePassword(from oldOne: String, to newOne: String, keyName: String? = nil) -> GenericOperation<Void>Parameters
oldOneold password
newOnenew password
keyNameoptional name of the key
Return Value
CallbackOperation
-
Deletes Private Key stored on Virgil’s cloud. This will disable user to log in from other devices.
Declaration
Swift
public func resetPrivateKeyBackup(keyName: String? = nil) -> GenericOperation<Void>Parameters
keyNameoptional name of the key
-
Retrieves cards from local storage with given identities
Throws
corresponding errorDeclaration
Swift
@objc open func findCachedUsers( with identities: [String], checkResult: Bool = true ) throws -> FindUsersResultParameters
identitiesidentities of cards to retrieve
checkResultchecks that cards for all identities were found if true
Return Value
-
Returnes card from local storage with given identity
Declaration
Swift
@objc open func findCachedUser(with identity: String) -> Card?Parameters
identityidentity
Return Value
Card if it exists, nil otherwise
-
Retrieves users Cards from the Virgil Cloud or local storage if exists
Declaration
Swift
public func findUsers( with identities: [String], forceReload: Bool = false, checkResult: Bool = true ) -> GenericOperation<FindUsersResult>Parameters
identitiesarray of identities to find
forceReloadwill not use local cached cards if true
checkResultchecks that cards for all identities were found if true
Return Value
CallbackOperation
-
Retrieves user Card from the Virgil Cloud or local storage if exists
Declaration
Swift
public func findUser(with identity: String, forceReload: Bool = false) -> GenericOperation<Card>Parameters
identityidentity to find
forceReloadwill not use local cached card if true
Return Value
CallbackOperation
-
Updates local cached cards
Declaration
Swift
public func updateCachedUsers() -> GenericOperation<Void>
-
Encrypts data stream
Important
Automatically includes self key to recipientsKeys.Important
Requires private key in local storageDeclaration
Swift
@available(*, deprecated, message: "Use authEncrypt method instead.") @objc(encryptStream:toStream:forUser:error:) public func encrypt(_ stream: InputStream, to outputStream: OutputStream, for user: Card) throwsParameters
streamdata stream to be encrypted
outputStreamstream with encrypted data
useruser Card to encrypt for
-
Encrypts data stream
Important
Automatically includes self key to recipientsKeys.Important
Requires private key in local storageNote
Avoid key duplicationDeclaration
Swift
@available(*, deprecated, message: "Use authEncrypt method instead.") @objc(encryptStream:toStream:forUsers:error:) public func encrypt( _ stream: InputStream, to outputStream: OutputStream, for users: FindUsersResult? = nil ) throwsParameters
streamdata stream to be encrypted
outputStreamstream with encrypted data
usersresult of findUsers call recipient Cards with Public Keys to sign and encrypt with. Use nil to sign and encrypt for self
-
Decrypts data stream
Important
Requires private key in local storageDeclaration
Swift
@available(*, deprecated, message: "Use authDecrypt method instead.") @objc public func decrypt(_ stream: InputStream, to outputStream: OutputStream) throwsParameters
streamstream with encrypted data
outputStreamstream with decrypted data
-
Signs and encrypts data for user
Important
Automatically includes self key to recipientsKeys.Important
Requires private key in local storageDeclaration
Swift
@available(*, deprecated, message: "Use authEncrypt method instead.") @objc(encryptData:forUser:error:) public func encrypt(data: Data, for user: Card) throws -> DataParameters
datadata to encrypt
useruser Card to encrypt for
Return Value
encrypted data
-
Signs and encrypts string for user
Important
Automatically includes self key to recipientsKeys.Important
Requires private key in local storageDeclaration
Swift
@available(*, deprecated, message: "Use authEncrypt method instead.") @objc(encryptText:forUser:error:) public func encrypt(text: String, for user: Card) throws -> StringParameters
textString to encrypt
useruser Card to encrypt for
Return Value
encrypted String
-
Decrypts and verifies data from users
Important
Requires private key in local storageDeclaration
Swift
@available(*, deprecated, message: "Use authDecrypt method instead.") @objc(decryptData:fromUsers:error:) public func decrypt(data: Data, from user: Card? = nil) throws -> DataParameters
datadata to decrypt
usersender Card with Public Key to verify with. Use nil to decrypt and verify from self
Return Value
decrypted Data
-
Decrypts and verifies data from users
Important
Requires private key in local storageDeclaration
Swift
@available(*, deprecated, message: "Use authDecrypt method instead.") @objc(decryptData:fromUsers:date:error:) public func decrypt(data: Data, from user: Card, date: Date) throws -> DataParameters
datadata to decrypt
usersender Card with Public Key to verify with
datedate of encryption to use proper card version
Return Value
decrypted Data
-
Decrypts and verifies base64 string from users
Important
Requires private key in local storageDeclaration
Swift
@available(*, deprecated, message: "Use authDecrypt method instead.") @objc(decryptText:fromUser:error:) public func decrypt(text: String, from user: Card? = nil) throws -> StringParameters
textencrypted String
usersender Card with Public Key to verify with. Use nil to decrypt and verify from self.
Return Value
decrypted String
-
Decrypts and verifies base64 string from users
Important
Requires private key in local storageDeclaration
Swift
@available(*, deprecated, message: "Use authDecrypt method instead.") @objc(decryptText:fromUser:date:error:) public func decrypt(text: String, from user: Card, date: Date) throws -> StringParameters
textencrypted String
usersender Card with Public Key to verify with
datedate of encryption to use proper card version
Return Value
decrypted String
-
Signs then encrypts string for group of users
Important
Automatically includes self key to recipientsKeys.Important
Requires private key in local storageNote
Avoid key duplicationDeclaration
Swift
@available(*, deprecated, message: "Use authEncrypt method instead.") @objc(encryptText:forUsers:error:) public func encrypt(text: String, for users: FindUsersResult? = nil) throws -> StringParameters
textString to encrypt
usersresult of findUsers call recipient Cards with Public Keys to sign and encrypt with. Use nil to sign and encrypt for self
Return Value
encrypted base64String
-
Signs then encrypts data for group of users
Important
Automatically includes self key to recipientsKeys.Important
Requires private key in local storageNote
Avoid key duplicationDeclaration
Swift
@available(*, deprecated, message: "Use authEncrypt method instead.") @objc(encryptData:forUsers:error:) public func encrypt(data: Data, for users: FindUsersResult? = nil) throws -> DataParameters
datadata to encrypt
userresult of findUsers call recipient Cards with Public Keys to sign and encrypt with. Use nil to sign and encrypt for self
Return Value
decrypted Data
-
Signs then encrypts data for group of users
Important
Automatically includes self key to recipientsKeys.Important
Requires private key in local storageNote
Avoid key duplicationDeclaration
Swift
@available(*, deprecated, message: "Use authEncrypt method instead.") @objc public func encrypt(data: Data, for recipientKeys: LookupResult) throws -> DataParameters
datadata to encrypt
recipientKeysresult of lookupPublicKeys call recipient PublicKeys to sign and encrypt with
Return Value
decrypted Data
-
Decrypts and verifies data from users
Important
Requires private key in local storageDeclaration
Swift
@available(*, deprecated, message: "Use authDecrypt method instead.") @objc public func decrypt(data: Data, from senderPublicKey: VirgilPublicKey) throws -> DataParameters
datadata to decrypt
senderPublicKeysender PublicKey to verify with
Return Value
decrypted Data
-
Encrypts data stream
Important
Automatically includes self key to recipientsKeys.Important
Requires private key in local storageNote
Avoid key duplicationDeclaration
Swift
@available(*, deprecated, message: "Use authEncrypt method instead.") @objc public func encrypt( _ stream: InputStream, to outputStream: OutputStream, for recipientKeys: LookupResult ) throwsParameters
streamdata stream to be encrypted
outputStreamstream with encrypted data
recipientKeysresult of lookupPublicKeys call recipient PublicKeys to sign and encrypt with.
-
Signs then encrypts string for group of users
Important
Automatically includes self key to recipientsKeys.Important
Requires private key in local storageNote
Avoid key duplicationDeclaration
Swift
@available(*, deprecated, message: "Use authEncrypt method instead.") @objc public func encrypt(text: String, for recipientKeys: LookupResult) throws -> StringParameters
textString to encrypt
recipientKeysresult of lookupPublicKeys call recipient PublicKeys to sign and encrypt with.
Return Value
encrypted base64String
-
Decrypts and verifies base64 string from users
Important
Requires private key in local storageDeclaration
Swift
@available(*, deprecated, message: "Use authDecrypt method instead.") @objc public func decrypt(text: String, from senderPublicKey: VirgilPublicKey) throws -> StringParameters
textencrypted String
senderPublicKeysender PublicKey to verify with
Return Value
decrypted String
-
Initializes EThree with a callback to get Virgil access token
Declaration
Swift
@available(*, deprecated, message: "Use constructor instead") public static func initialize( tokenCallback: @escaping RenewJwtCallback, changedKeyDelegate: ChangedKeyDelegate? = nil, storageParams: KeychainStorageParams? = nil, overrideVirgilPublicKey: String? = nil, serviceUrls: EThreeParams.ServiceUrls? = nil ) -> GenericOperation<EThree>Parameters
tokenCallbackcallback to get Virgil access token
changedKeyDelegateChangedKeyDelegateto notify about changes of User’s keysstorageParamsKeychainStorageParamswith specific parametersoverrideVirgilPublicKeyUse this only while working with environments other than Virgil production
serviceUrlsService urls
-
initialize(tokenCallback:changedKeyDelegate: storageParams: overrideVirgilPublicKey: serviceUrls: completion: ) Initializes E3Kit with a callback to get Virgil access token
Declaration
Swift
@available(*, deprecated, message: "Use constructor instead") @objc public static func initialize( tokenCallback: @escaping RenewJwtCallback, changedKeyDelegate: ChangedKeyDelegate? = nil, storageParams: KeychainStorageParams? = nil, overrideVirgilPublicKey: String? = nil, serviceUrls: EThreeParams.ServiceUrls? = nil, completion: @escaping (_ ethree: EThree?, _ error: Error?) -> Void )Parameters
tokenCallbackcallback to get Virgil access token
changedKeyDelegateChangedKeyDelegateto notify changing of User’s keysstorageParamsKeychainStorageParamswith specific parametersoverrideVirgilPublicKeyUse this only while working with environments other than Virgil production
serviceUrlsService urls
completioncompletion handler
ethreeinitialized EThree instance
errorcorresponding error
-
Retrieves users public keys from the Virgil Cloud
Declaration
Swift
@available(*, deprecated, message: "Use findUsers instead.") public func lookupPublicKeys(of identities: [String]) -> GenericOperation<LookupResult>Parameters
identitiesarray of identities to find
Return Value
CallbackOperation
-
Retrieves users public keys from the Virgil Cloud
Declaration
Swift
@available(*, deprecated, message: "Use findUsers instead.") @objc public func lookupPublicKeys( of identities: [String], completion: @escaping ( _ lookupResult: LookupResult?, _ error: Error? ) -> Void )Parameters
identitiesarray of identities to find
completioncompletion handler
lookupResultdictionary with idenities as keys and found keys as values
errorcorresponding error
-
Deletes Private Key stored on Virgil’s cloud. This will disable user to log in from other devices.
Declaration
Swift
@available(*, deprecated, message: "Use resetPrivateKeyBackup without password instead") @objc open func resetPrivateKeyBackup(password: String, completion: @escaping (_ error: Error?) -> Void)Parameters
passwordString with password
completioncompletion handler
errorcorresponding error
-
Deletes Private Key stored on Virgil’s cloud. This will disable user to log in from other devices.
Declaration
Swift
@available(*, deprecated, message: "Use resetPrivateKeyBackup without password instead") public func resetPrivateKeyBackup(password: String) -> GenericOperation<Void>Parameters
passwordString with password
Return Value
CallbackOperation
-
Generates new Private Key, publishes Card on Virgil Cards Service and saves Private Key in local storage
Declaration
Swift
@objc open func register(completion: @escaping (_ error: Error?) -> Void)Parameters
completioncompletion handler
errorcorresponding error
-
Uses provided Private Key to publish Card to Virgil Cards Service. Saves Private Key in local storage
Declaration
Swift
@objc open func register(with keyPair: VirgilKeyPair, completion: @escaping (_ error: Error?) -> Void)Parameters
keyPairKey Pair to publish Card with
-
Generates new Private Key, publishes new Card to replace the current one on Virgil Cards Service and saves new Private Key in local storage
Declaration
Swift
@objc open func rotatePrivateKey(completion: @escaping (_ error: Error?) -> Void)Parameters
completioncompletion handler
- error: corresponding error
-
Revokes Card from Virgil Cards Service, deletes Private Key from local storage
Declaration
Swift
@objc open func unregister(completion: @escaping (_ error: Error?) -> Void)Parameters
completioncompletion handler
- error: corresponding error
-
Encrypts user’s private key using password and backs up the encrypted private key to Virgil’s cloud. This enables users to log in from other devices and have access to their private key to decrypt data.
Important
Requires private key in local storageDeclaration
Swift
@objc open func backupPrivateKey(password: String, completion: @escaping (_ error: Error?) -> Void)Parameters
passwordString with password
completioncompletion handler
errorcorresponding error
-
Restores encrypted private key from Virgil’s cloud, decrypts it using user’s password and saves it in local storage
Declaration
Swift
@objc open func restorePrivateKey(password: String, completion: @escaping (_ error: Error?) -> Void)Parameters
passwordString with password
completioncompletion handler
errorcorresponding error
-
Changes the password on a backed-up private key.
Declaration
Swift
@objc open func changePassword( from oldOne: String, to newOne: String, completion: @escaping (_ error: Error?) -> Void )Parameters
oldOneold password
newOnenew password
completioncompletion handler
errorcorresponding error
-
Deletes Private Key stored on Virgil’s cloud. This will disable user to log in from other devices.
Declaration
Swift
@objc open func resetPrivateKeyBackup(completion: @escaping (_ error: Error?) -> Void)Parameters
completioncompletion handler
errorcorresponding error
-
Retrieves users Cards from the Virgil Cloud or local storage if exists
Declaration
Swift
@objc open func findUsers( with identities: [String], forceReload: Bool = false, checkResult: Bool = true, completion: @escaping ( _ findResult: FindUsersResult?, _ error: Error? ) -> Void )Parameters
identitiesarray of identities to find
forceReloadwill not use local cached cards if true
checkResultchecks that cards for all identities were found if true
completioncompletion handler
finddictionary with idenities as keys and found Cards as values
errorcorresponding error
-
Retrieves user Card from the Virgil Cloud or local storage if exists
Declaration
Swift
@objc open func findUser( with identity: String, forceReload: Bool = false, completion: @escaping ( _ card: Card?, _ error: Error? ) -> Void )Parameters
identityidentity to find
forceReloadwill not use local cached card if true
completioncompletion handler
cardfound Card
errorcorresponding error
-
Updates local cached cards
Declaration
Swift
@objc open func updateCachedUsers(completion: @escaping (_ error: Error?) -> Void)Parameters
completioncompletion handler
errorcorresponding error
-
Encrypts user’s private key using password and backs up the encrypted private key to Virgil’s cloud. This enables users to log in from other devices and have access to their private key to decrypt data.
Important
Requires private key in local storageDeclaration
Swift
@objc open func backupPrivateKey( password: String, keyName: String, completion: @escaping (_ error: Error?) -> Void )Parameters
passwordString with password
keyNamename of the key. Can be used to create additional key backup
completioncompletion handler
errorcorresponding error
-
Restores encrypted private key from Virgil’s cloud, decrypts it using user’s password and saves it in local storage
Declaration
Swift
@objc open func restorePrivateKey( password: String, keyName: String, completion: @escaping (_ error: Error?) -> Void )Parameters
passwordString with password
keyNamename of the key
completioncompletion handler
errorcorresponding error
-
Changes the password on a backed-up private key.
Declaration
Swift
@objc open func changePassword( from oldOne: String, to newOne: String, keyName: String, completion: @escaping (_ error: Error?) -> Void )Parameters
oldOneold password
newOnenew password
keyNamename of the key
completioncompletion handler
errorcorresponding error
-
Deletes Private Key stored on Virgil’s cloud. This will disable user to log in from other devices.
Declaration
Swift
@objc open func resetPrivateKeyBackup(keyName: String, completion: @escaping (_ error: Error?) -> Void)Parameters
keyNamename of the key
completioncompletion handler
errorcorresponding error
-
Creates group, saves in cloud and locally
Declaration
Swift
@objc(createGroupWithDataId:findResult:completion:) public func createGroup( id identifier: Data, with findResult: FindUsersResult = [:], completion: @escaping ( _ group: Group?, _ error: Error? ) -> Void )Parameters
identifieridentifier of group
findResultCards of participants. Result of findUsers call
completioncompletion handler
groupcreated
Grouperrorcorresponding error
-
Loads group from cloud, saves locally
Declaration
Swift
@objc(loadGroupWithDataId:initiator:completion:) public func loadGroup( id identifier: Data, initiator card: Card, completion: @escaping ( _ group: Group?, _ error: Error? ) -> Void )Parameters
identifieridentifier of group
cardCard of group initiator
completioncompletion handler
grouploaded
Grouperrorcorresponding error
-
Deletes group from cloud and local storage
Declaration
Swift
@objc(deleteGroupWithDataId:completion:) public func deleteGroup(id identifier: Data, completion: @escaping (_ error: Error?) -> Void) -
Creates group, saves in cloud and locally
Declaration
Swift
@objc(createGroupWithStringId:findResult:completion:) public func createGroup( id identifier: String, with findResult: FindUsersResult, completion: @escaping ( _ group: Group?, _ error: Error? ) -> Void )Parameters
identifieridentifier of group
findResultCards of participants. Result of findUsers call
completioncompletion handler
groupcreated
Grouperrorcorresponding error
-
Loads group from cloud, saves locally
Declaration
Swift
@objc(loadGroupWithStringId:initiator:completion:) public func loadGroup( id identifier: String, initiator card: Card, completion: @escaping ( _ group: Group?, _ error: Error? ) -> Void )Parameters
identifieridentifier of group
cardCard of group initiator
completioncompletion handler
grouploaded
Grouperrorcorresponding error
-
Deletes group from cloud and local storage
Declaration
Swift
@objc(deleteGroupWithStringId:completion:) public func deleteGroup(id identifier: String, completion: @escaping (_ error: Error?) -> Void)Parameters
identifieridentifier of group
completioncompletion handler
errorcorresponding error
-
Creates group, saves in cloud and locally
Note
identifier length should be > 10Declaration
Swift
@objc(createGroupWithDataId:users:completion:) public func createGroup( id identifier: Data, with users: [String], completion: @escaping ( _ group: Group?, _ error: Error? ) -> Void )Parameters
identifieridentifier of group
usersparticipants
completioncompletion handler
groupcreated
Grouperrorcorresponding error
-
Creates group, saves in cloud and locally
Note
identifier length should be > 10Declaration
Swift
public func createGroup( id identifier: String, with users: [String], completion: @escaping ( _ group: Group?, _ error: Error? ) -> Void )Parameters
identifieridentifier of group
usersparticipants
completioncompletion handler
groupcreated
Grouperrorcorresponding error
-
Loads group from cloud, saves locally
Declaration
Swift
public func loadGroup( id identifier: Data, initiator: String, completion: @escaping ( _ group: Group?, _ error: Error? ) -> Void )Parameters
identifieridentifier of group
initiatorinitiator
completioncompletion handler
grouploaded
Grouperrorcorresponding error
-
Loads group from cloud, saves locally
Declaration
Swift
public func loadGroup( id identifier: String, initiator: String, completion: @escaping ( _ group: Group?, _ error: Error? ) -> Void )Parameters
identifieridentifier of group
cardCard of group initiator
completioncompletion handler
grouploaded
Grouperrorcorresponding error
-
Creates double ratchet channel with user, saves it locally
Declaration
Swift
@objc open func createRatchetChannel( with card: Card, name: String? = nil, completion: @escaping ( _ channel: RatchetChannel?, _ error: Error? ) -> Void )Parameters
cardCard of participant
namename of channel
completioncompletion handler
channelcreated
RatchetChannelintanceerrorcorresponding error
-
Joins double ratchet channel with user, saves it locally
Declaration
Swift
@objc open func joinRatchetChannel( with card: Card, name: String? = nil, completion: @escaping ( _ channel: RatchetChannel?, _ error: Error? ) -> Void )Parameters
cardCard of initiator
namename of channel
completioncompletion handler
channelRatchetChannelintanceerrorcorresponding error
-
Deletes double ratchet channel
Declaration
Swift
@objc open func deleteRatchetChannel( with card: Card, name: String? = nil, completion: @escaping (_ error: Error?) -> Void )Parameters
cardCard of participant
namename of channel
completioncompletion handler
errorcorresponding error
-
Creates double ratchet channel with user, saves it locally
Declaration
Swift
public func createRatchetChannel( with identity: String, name: String? = nil, completion: @escaping ( _ channel: RatchetChannel?, _ error: Error? ) -> Void )Parameters
identityparticipant identity
namename of channel
completioncompletion handler
channelcreated
RatchetChannelintanceerrorcorresponding error
-
Joins double ratchet channel with user, saves it locally
Declaration
Swift
public func joinRatchetChannel( with initiator: String, name: String? = nil, completion: @escaping ( _ channel: RatchetChannel?, _ error: Error? ) -> Void )Parameters
initiatorinitiator identity
namename of channel
completioncompletion handler
channelRatchetChannelintanceerrorcorresponding error
-
Deletes double ratchet channel from cloud (if user is creator) and local storage
Declaration
Swift
public func deleteRatchetChannel( with participant: String, name: String? = nil, completion: @escaping (_ error: Error?) -> Void )Parameters
participantparticipant identity
namename of channel
completioncompletion handler
errorcorresponding error
-
Creates channel with unregistered user
Important
Temporary key for unregistered user is stored unencrypted.
Declaration
Swift
@objc open func createTemporaryChannel( with identity: String, completion: @escaping ( _ channel: TemporaryChannel?, _ error: Error? ) -> Void )Parameters
identityidentity of unregistered user
completioncompletion handler
channelcreated
TemporaryChannelinsanceerrorcorresponding error
-
Loads temporary channel by fetching temporary key form Cloud
Declaration
Swift
@objc open func loadTemporaryChannel( asCreator: Bool, with identity: String, completion: @escaping ( _ channel: TemporaryChannel?, _ error: Error? ) -> Void )Parameters
asCreatorBool to specify wether caller is creator of channel or not
identityidentity of participant
completioncompletion handler
channelloaded
TemporaryChannelinsanceerrorcorresponding error
-
Deletes temporary channel from cloud (if user is owner) and local storage
Declaration
Swift
@objc open func deleteTemporaryChannel(with identity: String, completion: @escaping (_ error: Error?) -> Void)Parameters
identityidentity of participant
completioncompletion handler
errorcorresponding error
-
Signs then encrypts data (and signature) for user
Important
Deprecated decrypt method is unable to decrypt result of this method
Important
Automatically includes self key to recipientsKeys.
Important
Requires private key in local storage
Declaration
Swift
@objc(authEncryptData:forUser:error:) public func authEncrypt(data: Data, for user: Card) throws -> DataParameters
datadata to encrypt
useruser Card to encrypt for
Return Value
encrypted data
-
Signs then encrypts string (and signature) for user
Important
Deprecated decrypt method is unable to decrypt result of this method
Important
Automatically includes self key to recipientsKeys.
Important
Requires private key in local storage
Declaration
Swift
@objc(authEncryptText:forUser:error:) public func authEncrypt(text: String, for user: Card) throws -> StringParameters
textString to encrypt
useruser Card to encrypt for
Return Value
encrypted String
-
Decrypts data and signature and verifies signature of sender
Important
Requires private key in local storageDeclaration
Swift
@objc(authDecryptData:fromUsers:error:) public func authDecrypt(data: Data, from user: Card? = nil) throws -> DataParameters
datadata to decrypt
usersender Card with Public Key to verify with. Use nil to decrypt and verify from self
Return Value
decrypted Data
-
Decrypts data and signature and verifies signature of sender
Important
Requires private key in local storageDeclaration
Swift
@objc(authDecryptData:fromUsers:date:error:) public func authDecrypt(data: Data, from user: Card, date: Date) throws -> DataParameters
datadata to decrypt
usersender Card with Public Key to verify with
datedate of encryption to use proper card version
Return Value
decrypted Data
-
Decrypts base64 string and signature and verifies signature of sender
Important
Requires private key in local storageDeclaration
Swift
@objc(authDecryptText:fromUser:error:) public func authDecrypt(text: String, from user: Card? = nil) throws -> StringParameters
textencrypted String
usersender Card with Public Key to verify with. Use nil to decrypt and verify from self.
Return Value
decrypted String
-
Decrypts base64 string and signature and verifies signature of sender
Important
Requires private key in local storageDeclaration
Swift
@objc(authDecryptText:fromUser:date:error:) public func authDecrypt(text: String, from user: Card, date: Date) throws -> StringParameters
textencrypted String
usersender Card with Public Key to verify with
datedate of encryption to use proper card version
Return Value
decrypted String
-
Signs then encrypts string (and signature) for group of users
Important
Deprecated decrypt method is unable to decrypt result of this method
Important
Automatically includes self key to recipientsKeys.
Important
Requires private key in local storage
Note
Avoid key duplication
Declaration
Swift
@objc(authEncryptText:forUsers:error:) public func authEncrypt(text: String, for users: FindUsersResult? = nil) throws -> StringParameters
textString to encrypt
usersresult of findUsers call recipient Cards with Public Keys to sign and encrypt with. Use nil to sign and encrypt for self
Return Value
encrypted base64String
-
Signs then encrypts string (and signature) for group of users
Important
Deprecated decrypt method is unable to decrypt result of this method
Important
Automatically includes self key to recipientsKeys.
Important
Requires private key in local storage
Note
Avoid key duplication
Declaration
Swift
@objc(authEncryptData:forUsers:error:) public func authEncrypt(data: Data, for users: FindUsersResult? = nil) throws -> DataParameters
datadata to encrypt
usersresult of findUsers call recipient Cards with Public Keys to sign and encrypt with. Use nil to sign and encrypt for self
Return Value
decrypted Data
-
Creates group, saves in cloud and locally
Note
identifier length should be > 10Declaration
Swift
public func createGroup(id identifier: Data, with users: FindUsersResult = [:]) -> GenericOperation<Group>Parameters
identifieridentifier of group
usersCards of participants. Result of findUsers call
Return Value
CallbackOperation
-
Returnes cached local group
Throws
corresponding errorDeclaration
Swift
public func getGroup(id identifier: Data) throws -> Group?Parameters
identifieridentifier of group
Return Value
Group if exists, nil otherwise
-
Loads group from cloud, saves locally
Declaration
Swift
public func loadGroup(id identifier: Data, initiator card: Card) -> GenericOperation<Group>Parameters
identifieridentifier of group
cardCard of group initiator
Return Value
CallbackOperation
-
Deletes group from cloud (if user is initiator) and local storage
Declaration
Swift
public func deleteGroup(id identifier: Data) -> GenericOperation<Void>Parameters
identifieridentifier of group
Return Value
CallbackOperation
-
Creates group, saves in cloud and locally
Note
identifier length should be > 10Declaration
Swift
public func createGroup(id identifier: String, with users: FindUsersResult = [:]) -> GenericOperation<Group>Parameters
identifieridentifier of group
usersCards of participants. Result of findUsers call
Return Value
CallbackOperation
-
Returnes cached local group
Throws
corresponding errorDeclaration
Swift
public func getGroup(id identifier: String) throws -> Group?Parameters
identifieridentifier of group
Return Value
Group if exists, nil otherwise
-
Loads group from cloud, saves locally
Declaration
Swift
public func loadGroup(id identifier: String, initiator card: Card) -> GenericOperation<Group>Parameters
identifieridentifier of group
cardCard of group initiator
Return Value
CallbackOperation
-
Deletes group from cloud and local storage
Declaration
Swift
public func deleteGroup(id identifier: String) -> GenericOperation<Void>Parameters
identifieridentifier of group
Return Value
CallbackOperation
-
Creates group, saves in cloud and locally
Note
identifier length should be > 10Declaration
Swift
public func createGroup(id identifier: Data, with users: [String]) -> GenericOperation<Group>Parameters
identifieridentifier of group
usersparticipants
Return Value
CallbackOperation
-
Creates group, saves in cloud and locally
Note
identifier length should be > 10Declaration
Swift
public func createGroup(id identifier: String, with users: [String]) -> GenericOperation<Group>Parameters
identifieridentifier of group
usersparticipants
Return Value
CallbackOperation
-
Loads group from cloud, saves locally
Declaration
Swift
public func loadGroup(id identifier: Data, initiator: String) -> GenericOperation<Group>Parameters
identifieridentifier of group
initiatorinitiator
Return Value
CallbackOperation
-
Loads group from cloud, saves locally
Declaration
Swift
public func loadGroup(id identifier: String, initiator: String) -> GenericOperation<Group>Parameters
identifieridentifier of group
cardCard of group initiator
Return Value
CallbackOperation
-
Creates double ratchet channel with user, saves it locally
Declaration
Swift
public func createRatchetChannel(with card: Card, name: String? = nil) -> GenericOperation<RatchetChannel>Parameters
cardCard of participant
namename of channel
-
Joins double ratchet channel with user, saves it locally
Declaration
Swift
public func joinRatchetChannel(with card: Card, name: String? = nil) -> GenericOperation<RatchetChannel>Parameters
cardCard of initiator
namename of channel
-
Retrieves double ratchet channel from local storage
Declaration
Swift
public func getRatchetChannel(with card: Card, name: String? = nil) throws -> RatchetChannel?Parameters
cardCard of participant
namename of channel
-
Deletes double ratchet channel from cloud (if user is creator) and local storage
Declaration
Swift
public func deleteRatchetChannel(with card: Card, name: String? = nil) -> GenericOperation<Void>Parameters
cardCard of participant
namename of channel
-
Creates double ratchet channel with user, saves it locally
Declaration
Swift
public func createRatchetChannel(with identity: String, name: String? = nil) -> GenericOperation<RatchetChannel>Parameters
identityparticipant identity
namename of channel
-
Joins double ratchet channel with user, saves it locally
Declaration
Swift
public func joinRatchetChannel(with initiator: String, name: String? = nil) -> GenericOperation<RatchetChannel>Parameters
initiatorinitiator identity
namename of channel
-
Retrieves double ratchet channel from local storage
Declaration
Swift
public func getRatchetChannel(with participant: String, name: String? = nil) throws -> RatchetChannel?Parameters
participantparticipant identity
namename of channel
-
Deletes double ratchet channel from cloud (if user is creator) and local storage
Declaration
Swift
public func deleteRatchetChannel(with participant: String, name: String? = nil) -> GenericOperation<Void>Parameters
participantparticipant identity
namename of channel
-
Encrypts file stream with a new private key.
File is signed with a private key from the local storage.
Throws
corresponding errorImportant
Requires private key in local storage to sign streamDeclaration
Swift
@objc(encryptSharedStream:withSize:toStream:error:) public func encryptShared( _ stream: InputStream, streamSize: Int, to outputStream: OutputStream ) throws -> DataParameters
streamdata stream to be encrypted
streamSizetotal stream size in bytes
outputStreamstream with encrypted data
Return Value
- serialized private key
-
Decrypts file stream.
Throws
corresponding errorDeclaration
Swift
@objc(decryptSharedStream:toStream:with:verifyWithSenderCard:error:) public func decryptShared( _ stream: InputStream, to outputStream: OutputStream, with privateKeyData: Data, verifyWith senderCard: Card ) throwsParameters
streamstream with encrypted data
outputStreamstream with decrypted data
privateKeyDataserialized private key to decrypt file stream
senderCardsender Card with Public Key to verify with
-
Decrypts file stream.
Throws
corresponding errorImportant
Requires private key in local storage, if senderPublicKey is not givenDeclaration
Swift
@objc(decryptSharedStream:toStream:with:verifyWithSenderPublicKey:error:) public func decryptShared( _ stream: InputStream, to outputStream: OutputStream, with privateKeyData: Data, verifyWith senderPublicKey: VirgilPublicKey? = nil ) throwsParameters
streamstream with encrypted data
outputStreamstream with decrypted data
privateKeyDataserialized private key to decrypt file stream
senderPublicKeysender Public Key to verify with, if nill then self public key is used
-
Signs then encrypts stream and signature for user
Throws
corresponding errorImportant
Automatically includes self key to recipientsKeys.Important
Requires private key in local storageDeclaration
Swift
@objc(authEncryptStream:withSize:toStream:forUser:error:) public func authEncrypt( _ stream: InputStream, streamSize: Int, to outputStream: OutputStream, for user: Card ) throwsParameters
streamdata stream to be encrypted
outputStreamstream with encrypted data
useruser Card to encrypt for
-
Signs then encrypts stream and signature for users
Throws
corresponding errorImportant
Automatically includes self key to recipientsKeys.Important
Requires private key in local storageNote
Avoid key duplicationDeclaration
Swift
@objc(authEncryptStream:withSize:toStream:forUsers:error:) public func authEncrypt( _ stream: InputStream, streamSize: Int, to outputStream: OutputStream, for users: FindUsersResult? = nil ) throwsParameters
streamdata stream to be encrypted
outputStreamstream with encrypted data
usersresult of findUsers call recipient Cards with Public Keys to sign and encrypt with. Use nil to sign and encrypt for self
-
Decrypts stream and signature and verifies signature of sender
Throws
corresponding errorImportant
Requires private key in local storageDeclaration
Swift
@objc open func authDecrypt(_ stream: InputStream, to outputStream: OutputStream, from user: Card? = nil) throwsParameters
streamstream with encrypted data
outputStreamstream with decrypted data
usersender Card with Public Key to verify with. Use nil to decrypt and verify from self.
-
Decrypts stream and signature and verifies signature of sender
Throws
corresponding errorImportant
Requires private key in local storageDeclaration
Swift
@objc open func authDecrypt( _ stream: InputStream, to outputStream: OutputStream, from user: Card, date: Date ) throwsParameters
streamstream with encrypted data
outputStreamstream with decrypted data
usersender Card with Public Key to verify with
datedate of encryption to use proper card version
-
Creates channel with unregistered user
Important
Temporary key for unregistered user is stored unencrypted on Cloud.
Declaration
Swift
public func createTemporaryChannel(with identity: String) -> GenericOperation<TemporaryChannel>Parameters
identityidentity of unregistered user
-
Loads temporary channel by fetching temporary key form Cloud
Declaration
Swift
public func loadTemporaryChannel(asCreator: Bool, with identity: String) -> GenericOperation<TemporaryChannel>Parameters
asCreatorBool to specify wether caller is creator of channel or not
identityidentity of participant
-
Returns cached temporary channel
Declaration
Swift
public func getTemporaryChannel(with identity: String) throws -> TemporaryChannel?Parameters
identityidentity of participant
-
Deletes temporary channel from cloud (if user is creator) and local storage
Declaration
Swift
public func deleteTemporaryChannel(with identity: String) -> GenericOperation<Void>Parameters
identityidentity of participant
EThree Class Reference