Uniform.Matrix.Protocol.Crypto
0.1.2
dotnet add package Uniform.Matrix.Protocol.Crypto --version 0.1.2
NuGet\Install-Package Uniform.Matrix.Protocol.Crypto -Version 0.1.2
<PackageReference Include="Uniform.Matrix.Protocol.Crypto" Version="0.1.2" />
<PackageVersion Include="Uniform.Matrix.Protocol.Crypto" Version="0.1.2" />
<PackageReference Include="Uniform.Matrix.Protocol.Crypto" />
paket add Uniform.Matrix.Protocol.Crypto --version 0.1.2
#r "nuget: Uniform.Matrix.Protocol.Crypto, 0.1.2"
#:package Uniform.Matrix.Protocol.Crypto@0.1.2
#addin nuget:?package=Uniform.Matrix.Protocol.Crypto&version=0.1.2
#tool nuget:?package=Uniform.Matrix.Protocol.Crypto&version=0.1.2
Uniform.Matrix.Protocol.Crypto
Matrix end-to-end encryption in pure .NET: Olm and Megolm, device keys, cross-signing, secret storage, server-side key backup with a recovery key, key requests between own devices, and emoji (SAS) verification. No native libraries; the curves come from BouncyCastle.
dotnet add package Uniform.Matrix.Protocol.Crypto
Encrypt a room
OlmMachine does the protocol work for one device. It talks to the server through IKeyTransport; Uniform.Matrix.Client has MatrixKeyTransport over a logged-in MatrixClient.
using Uniform.Matrix.Protocol.Crypto;
using OlmMachine machine = await OlmMachine.CreateAsync(new MatrixKeyTransport(client), new InMemoryCryptoStore(), client.UserId!, client.DeviceId!, pickleKey);
await machine.UploadInitialKeysAsync();
// Every sync goes through the machine: to-device messages, device lists, one-time key counts
await machine.ReceiveSyncAsync(sync);
// Send encrypted, and decrypt what arrives
EncryptedContent content = await machine.EncryptRoomEventAsync(roomId, EventTypes.RoomMessage, new MessageContent { MessageType = MessageTypes.Text, Body = "secret" }, memberIds);
await client.SendEventAsync(roomId, EventTypes.RoomEncrypted, content);
RoomEventDecryption result = await machine.DecryptRoomEventAsync(roomId, clientEvent);
SetUpRecoveryAsync creates cross-signing keys, a key backup and the recovery key; RecoverAsync restores them on a new login. RequestVerificationAsync, AcceptVerificationAsync and ConfirmVerificationAsync run emoji verification.
Olm and Megolm directly
using MegolmOutboundSession outbound = MegolmOutboundSession.Create();
using MegolmInboundSession inbound = MegolmInboundSession.FromSessionKey(outbound.SessionKey);
string ciphertext = outbound.Encrypt("hello");
MegolmPlaintext plaintext = inbound.Decrypt(ciphertext);
Console.WriteLine(plaintext.Text); // hello
OlmAccount and OlmSession cover Olm. Pickles use vodozemac's format, so state moves between the two implementations.
Notes
- The Olm and Megolm code is a C# port of vodozemac 0.11.1, and is tested against vodozemac itself. Unlike vodozemac, it has not been audited, and .NET cannot guarantee constant-time code or wipe all secrets from memory.
- Licensed
MIT AND Apache-2.0: the vodozemac-derived files stay under the Apache License 2.0, whose text and the notices are included in the package.
About
Part of Uniform.Matrix, a pure .NET implementation of the Matrix specification. Version 0.1 is an early pre-release: APIs may still change.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- BouncyCastle.Cryptography (>= 2.7.0)
- Uniform.Matrix.Protocol.Core (>= 0.1.2)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on Uniform.Matrix.Protocol.Crypto:
| Package | Downloads |
|---|---|
|
Uniform.Matrix.Client
Matrix client engine with local SQLite storage: session, sync, outbox, media cache, encryption and room state. |
|
|
Uniform.Matrix.Protocol.Server
Matrix homeserver building blocks: room versions, event format, content hashes, signing, redaction and authorization rules. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.1.2 | 0 | 10/27/2026 |
| 0.1.0 | 29 | 10/26/2026 |
| 0.1.0-alpha.1 | 27 | 10/26/2026 |