CoreCryptoFfiProtocol

public protocol CoreCryptoFfiProtocol : AnyObject, Sendable

CoreCrypto wraps around MLS and Proteus implementations and provides a transactional interface for each.

  • Returns the ciphersuite in use for the given conversation.

    Declaration

    Swift

    func conversationCiphersuite(conversationId: ConversationId) async throws -> Ciphersuite
  • Get the credential ref for the given conversation.

    Declaration

    Swift

    func conversationCredential(conversationId: ConversationId) async throws -> CredentialRef
  • Returns the current MLS epoch of the given conversation.

    Declaration

    Swift

    func conversationEpoch(conversationId: ConversationId) async throws -> UInt64
  • Returns true if a conversation with the given id exists in the local state.

    Declaration

    Swift

    func conversationExists(conversationId: ConversationId) async throws -> Bool
  • Returns the end-to-end identity verification state of the given conversation.

    Declaration

    Swift

    func e2eiConversationState(conversationId: ConversationId) async throws -> E2eiConversationState
  • Returns true if end-to-end identity is enabled for the given ciphersuite.

    Declaration

    Swift

    func e2eiIsEnabled(ciphersuite: Ciphersuite) async throws -> Bool
  • e2eiIsPkiEnvSetup() Asynchronous

    Returns true if the PKI environment has been set up and its provider is configured.

    Declaration

    Swift

    func e2eiIsPkiEnvSetup() async -> Bool
  • Derives and exports a secret of key_length bytes 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 -> Data
  • Returns the client ids of all members of the given conversation.

    Declaration

    Swift

    func getClientIds(conversationId: ConversationId) async throws -> [ClientId]
  • Returns the E2EI identity claims for the specified devices in the given conversation.

    Declaration

    Swift

    func getDeviceIdentities(conversationId: ConversationId, deviceIds: [ClientId]) async throws -> [WireIdentity]
  • Returns the serialized public key of the external sender for the given conversation.

    Declaration

    Swift

    func getExternalSender(conversationId: ConversationId) async throws -> Data
  • getPkiEnvironment() Asynchronous

    Get the PKI environment of the CoreCrypto instance.

    Returns null if it is not set.

    Declaration

    Swift

    func getPkiEnvironment() async -> PkiEnvironment?
  • 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]]
  • Returns true if history sharing is currently enabled for the given conversation.

    Declaration

    Swift

    func isHistorySharingEnabled(conversationId: ConversationId) async throws -> Bool
  • proteusFingerprint() Asynchronous

    Returns the hex-encoded public key fingerprint of this device’s Proteus identity.

    Declaration

    Swift

    func proteusFingerprint() async throws -> String
  • 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
  • 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
  • Returns true if a Proteus session with the given ID exists in local storage.

    Declaration

    Swift

    func proteusSessionExists(sessionId: String) async throws -> Bool
  • 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
  • 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
  • Set the PKI environment of the CoreCrypto instance.

    Declaration

    Swift

    func setPkiEnvironment(pkiEnvironment: PkiEnvironment?) async throws
  • 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