CoreCryptoFfiProtocol
public protocol CoreCryptoFfiProtocol : AnyObject, Sendable
CoreCrypto wraps around MLS and Proteus implementations and provides a transactional interface for each.
-
conversationCipherSuite(conversationId:Asynchronous) Returns the cipher_suite in use for the given conversation.
Declaration
Swift
func conversationCipherSuite(conversationId: ConversationId) async throws -> CipherSuite -
conversationCredential(conversationId:Asynchronous) Get the credential ref for the given conversation.
Declaration
Swift
func conversationCredential(conversationId: ConversationId) async throws -> CredentialRef -
conversationEpoch(conversationId:Asynchronous) Returns the current MLS epoch of the given conversation.
Declaration
Swift
func conversationEpoch(conversationId: ConversationId) async throws -> UInt64 -
conversationExists(conversationId:Asynchronous) Returns true if a conversation with the given id exists in the local state.
Declaration
Swift
func conversationExists(conversationId: ConversationId) async throws -> Bool -
e2eiConversationState(conversationId:Asynchronous) Returns the end-to-end identity verification state of the given conversation.
Declaration
Swift
func e2eiConversationState(conversationId: ConversationId) async throws -> E2eiConversationState -
e2eiIsEnabled(cipherSuite:Asynchronous) Returns true if end-to-end identity is enabled for the given cipher_suite.
Declaration
Swift
func e2eiIsEnabled(cipherSuite: CipherSuite) async throws -> Bool -
e2eiIsPkiEnvSetup()AsynchronousReturns true if the PKI environment has been set up and its provider is configured.
Declaration
Swift
func e2eiIsPkiEnvSetup() async -> Bool -
exportSecretKey(conversationId:AsynchronouskeyLength: ) Derives and exports a secret of
key_lengthbytes for the given conversation.The secret is derived from the MLS key schedule’s exporter mechanism (RFC 9420 §8.5), which produces output bound to the current group state and epoch. The exported value changes whenever the epoch advances.
Declaration
Swift
func exportSecretKey(conversationId: ConversationId, keyLength: UInt32) async throws -> SecretKey -
Get all credentials from this client which match the provided parameters.
Parameters which are unset or
Nonematch anything. Those with a particular value find only credentials matching that value.Declaration
Swift
func findCredentials(clientId: ClientId?, publicKey: Data?, cipherSuite: CipherSuite?, credentialType: CredentialType?, earliestValidity: UInt64?) async throws -> [CredentialRef] -
getClientIds(conversationId:Asynchronous) Returns the client ids of all members of the given conversation.
Declaration
Swift
func getClientIds(conversationId: ConversationId) async throws -> [ClientId] -
getCredentials()AsynchronousGet all credentials from this client.
Declaration
Swift
func getCredentials() async throws -> [CredentialRef] -
getDeviceIdentities(conversationId:AsynchronousdeviceIds: ) Returns the E2EI identity claims for the specified devices in the given conversation.
Declaration
Swift
func getDeviceIdentities(conversationId: ConversationId, deviceIds: [ClientId]) async throws -> [WireIdentity] -
getExternalSender(conversationId:Asynchronous) Returns the serialized public key of the external sender for the given conversation.
Declaration
Swift
func getExternalSender(conversationId: ConversationId) async throws -> Data -
getPkiEnvironment()AsynchronousGet the PKI environment of the CoreCrypto instance.
Returns null if it is not set.
Declaration
Swift
func getPkiEnvironment() async -> PkiEnvironment? -
getUserIdentities(conversationId:AsynchronoususerIds: ) Returns the E2EI identity claims for the specified users in the given conversation, grouped by user ID.
Declaration
Swift
func getUserIdentities(conversationId: ConversationId, userIds: [String]) async throws -> [String : [WireIdentity]] -
isHistorySharingEnabled(conversationId:Asynchronous) Returns true if history sharing is currently enabled for the given conversation.
Declaration
Swift
func isHistorySharingEnabled(conversationId: ConversationId) async throws -> Bool -
proteusFingerprint()AsynchronousReturns the hex-encoded public key fingerprint of this device’s Proteus identity.
Declaration
Swift
func proteusFingerprint() async throws -> String -
proteusFingerprintLocal(sessionId:Asynchronous) Returns the hex-encoded local public key fingerprint for the Proteus session with the given ID.
Declaration
Swift
func proteusFingerprintLocal(sessionId: String) async throws -> String -
proteusFingerprintRemote(sessionId:Asynchronous) Returns the hex-encoded remote public key fingerprint for the Proteus session with the given ID.
Declaration
Swift
func proteusFingerprintRemote(sessionId: String) async throws -> String -
proteusSessionExists(sessionId:Asynchronous) Returns true if a Proteus session with the given ID exists in local storage.
Declaration
Swift
func proteusSessionExists(sessionId: String) async throws -> Bool -
publicKey(credentialRef:Asynchronous) Get the public key associated with this credential
Declaration
Swift
func publicKey(credentialRef: CredentialRef) async throws -> Data -
registerEpochObserver(epochObserver:Asynchronous) Add an epoch observer to this client.
This function should be called 0 or 1 times in a session’s lifetime. If called when an epoch observer already exists, this will return an error.
Declaration
Swift
func registerEpochObserver(epochObserver: EpochObserver) async throws -
registerHistoryObserver(historyObserver:Asynchronous) Add a history observer to this client.
This function should be called 0 or 1 times in a session’s lifetime. If called when a history observer already exists, this will return an error.
Declaration
Swift
func registerHistoryObserver(historyObserver: HistoryObserver) async throws -
setPkiEnvironment(pkiEnvironment:Asynchronous) Set the PKI environment of the CoreCrypto instance.
Declaration
Swift
func setPkiEnvironment(pkiEnvironment: PkiEnvironment?) async -
transactionFfi(command:Asynchronous) Starts a new transaction in Core Crypto. If the callback succeeds, it will be committed, otherwise, every operation performed with the context will be discarded.
When calling this function from within Rust, async functions accepting a context implement
CoreCryptoCommand, so operations can be defined inline as follows:core_crypto.transaction(Arc::new(async |context| { // your implementation here Ok(()) }))?;Declaration
Swift
func transactionFfi(command: CoreCryptoCommand) async throws