Module Pk.Decryption

type t = {
buf : char Ctypes.ptr;
pk_dec : C.Types.PkDecryption.t Ctypes_static.ptr;
pubkey : string;
}
val clear : C.Types.PkDecryption.t Ctypes_static.ptr -> (int, [> `OlmError ]) Core.result

clear pk_dec

Clear memory backing the given pk_dec pointer.

val check_error : t -> Unsigned.size_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 pk decryption object t if so.

val alloc : unit -> t

alloc ()

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

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

create ()

Create a new PK decryption object, returning its pointers and public key in a t

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

pickle ?pass t

Stores a PK decryption object t as a base64 string, encrypting it using the optionally supplied passphrase pass. Returns a base64 encoded string of the pickled pk decryption on success.

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

from_pickle ?pass pickle

Loads PK decryption object 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 decrypt : ?⁠ignore_unicode_errors:bool -> t -> Message.t -> (string, [> OlmError.t | `UnicodeError ]) Core.result

decrypt t msg

Decrypts a previously encrypted pk msg into plaintext with t. Invalid unicode characters are replaced with Uutf.u_rep unless ignore_unicode_errors is set to true.

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

private_key t

Get the private key from t.