Class OlmAccount
An Olm account: the device's identity keys, one-time keys and fallback keys.
Implements
Inherited Members
Namespace: Uniform.Matrix.Protocol.Crypto
Assembly: Uniform.Matrix.Protocol.Crypto.dll
Syntax
public sealed class OlmAccount : IDisposable
Remarks
Ported from vodozemac 0.11.1 (olm/account). Pickles use vodozemac's format.
Properties
| Edit this page View SourceFallbackKey
The fallback key when not yet published, by key ID; empty otherwise.
Declaration
public IReadOnlyDictionary<string, string> FallbackKey { get; }
Property Value
| Type | Description |
|---|---|
| IReadOnlyDictionary<string, string> |
IdentityKeys
Public identity keys.
Declaration
public IdentityKeys IdentityKeys { get; }
Property Value
| Type | Description |
|---|---|
| IdentityKeys |
MaxOneTimeKeys
How many one-time keys to keep on the server; the account stores more, as some may be claimed before their messages arrive.
Declaration
public int MaxOneTimeKeys { get; }
Property Value
| Type | Description |
|---|---|
| int |
OneTimeKeys
One-time keys not yet published, by key ID.
Declaration
public IReadOnlyDictionary<string, string> OneTimeKeys { get; }
Property Value
| Type | Description |
|---|---|
| IReadOnlyDictionary<string, string> |
Methods
| Edit this page View SourceCreate()
Create an account with new identity keys.
Declaration
public static OlmAccount Create()
Returns
| Type | Description |
|---|---|
| OlmAccount |
CreateInboundSession(string, string)
Create a session from a pre-key message of identityKey's device; use up the one-time key only when the message decrypts.
Declaration
public (OlmSession Session, byte[] Plaintext) CreateInboundSession(string identityKey, string preKeyCiphertext)
Parameters
| Type | Name | Description |
|---|---|---|
| string | identityKey | |
| string | preKeyCiphertext |
Returns
| Type | Description |
|---|---|
| (OlmSession Session, byte[] Plaintext) | The session and the decrypted first message. |
CreateOutboundSession(string, string)
Start a session with a device from its identity key and a claimed one-time key, both unpadded base64.
Declaration
public OlmSession CreateOutboundSession(string identityKey, string oneTimeKey)
Parameters
| Type | Name | Description |
|---|---|---|
| string | identityKey | |
| string | oneTimeKey |
Returns
| Type | Description |
|---|---|
| OlmSession |
Dispose()
Wipe secrets.
Declaration
public void Dispose()
FromPickle(string, ReadOnlySpan<byte>)
Restore an account from Pickle(ReadOnlySpan<byte>); throw OlmException for a wrong key.
Declaration
public static OlmAccount FromPickle(string pickle, ReadOnlySpan<byte> key)
Parameters
| Type | Name | Description |
|---|---|---|
| string | pickle | |
| ReadOnlySpan<byte> | key |
Returns
| Type | Description |
|---|---|
| OlmAccount |
GenerateFallbackKey()
Generate a new fallback key; the previous one keeps working until the next.
Declaration
public void GenerateFallbackKey()
GenerateOneTimeKeys(int)
Generate count one-time keys, dropping the oldest beyond the storage limit.
Declaration
public void GenerateOneTimeKeys(int count)
Parameters
| Type | Name | Description |
|---|---|---|
| int | count |
MarkKeysAsPublished()
Mark current one-time and fallback keys as published, so they are not returned again.
Declaration
public void MarkKeysAsPublished()
Pickle(ReadOnlySpan<byte>)
Pickle the account in vodozemac's format, encrypted with 32-byte key.
Declaration
public string Pickle(ReadOnlySpan<byte> key)
Parameters
| Type | Name | Description |
|---|---|---|
| ReadOnlySpan<byte> | key |
Returns
| Type | Description |
|---|---|
| string |
Sign(string)
Sign UTF-8 message with the Ed25519 identity key; return the signature in unpadded base64.
Declaration
public string Sign(string message)
Parameters
| Type | Name | Description |
|---|---|---|
| string | message |
Returns
| Type | Description |
|---|---|
| string |