Module Olm.Account

module IdentityKeys : sig ... end
module OneTimeKeys : sig ... end
type t = {
buf : char Ctypes_static.ptr;
acc : C.Types.Account.t Ctypes_static.ptr;
}
val clear : C.Types.Account.t Ctypes_static.ptr -> (int, [> `OlmError ]) Core.result

clear acc

Clear memory backing the given account pointer.

val check_error : t -> Unsigned.Size_t.t -> (int, [> OlmError.t ]) Core.result

check_error t ret

Check whether return code ret is equal to `olm_error()` ( -1 ), returning the return value as an int if not, and the `last_error` from the account t if so.

val alloc : unit -> t

alloc ()

Allocate an C.Types.Account.t and return the pointers in a t.

val create : unit -> (t[> OlmError.t ]) Core.result

create ()

Create a new Olm account, and its matching identity key pair. If there weren't enough random bytes for the account creation the error will be `NotEnoughRandom.

val pickle : ?⁠pass:string -> t -> (string, [> OlmError.t ]) Core.result

pickle ?pass t

Stores an account t as a base64 string. Encrypts the account using the optionally supplied passphrase pass. Returns a base64 encoded string of the pickled account on success.

val from_pickle : ?⁠pass:string -> string -> (t[> OlmError.t | `ValueError of string ]) Core.result

from_pickle ?pass pickle

Loads an account from a pickled base64-encoded string pickle and returns a t, decrypted with the optionally supplied passphrase pass. If the passphrase doesn't match the one used to encrypt the account then the error will be `BadAccountKey. If the base64 couldn't be decoded then the error will be `InvalidBase64.

val identity_keys : t -> (IdentityKeys.t[> OlmError.t | `YojsonError of string ]) Core.result

identity_keys t

Get the public part of the identity keys from the account t.

val sign : t -> string -> (string, [> OlmError.t ]) Core.result

sign t msg

Signs a message with the private ed25519 identity key of the account t, returning the signature.

val max_one_time_keys : t -> (int, [> OlmError.t ]) Core.result

max_one_time_keys t

The maximum number of one-time keys the account t can store.

val mark_keys_as_published : t -> (int, [> OlmError.t ]) Core.result

mark_keys_as_published t

Mark the current set of one-time keys in account t as being published.

val generate_one_time_keys : t -> int -> (int, [> OlmError.t ]) Core.result

generate_one_time_keys t n

Generate n new one-time keys. If the total number of keys stored by this account exceeds max_one_time_keys t then the old keys are discarded.

val one_time_keys : t -> (OneTimeKeys.t[> OlmError.t | `YojsonError of string ]) Core.result

one_time_keys t

Get the public part of the one-time keys for the account t.