Invest in the Future You Want to See. Closing Soon!

A First Public Offering of Purism Stock on StartEngine. Minimum $500.

Invest Now

Latest posts by Mohammed Sadiq (see all)

We have been aiming for proper Matrix support for the Chats application since the beginning of its development.

The initial support for Matrix was provided with the purple-matrix plugin. It had rudimentary Matrix support for non-encrypted chats and decryption (but not for encryption).

This plug-in has been unmaintained for quite a long time and making it work flawlessly would have been a bit difficult. It is limiting us to the libpurple workflow, and adding signals with callbacks would result them in being APIs which can’t ever be modified.

An Integrated Matrix Implementation for Chats

Therefore, it was decided to implement the Matrix support within Chats and eventually possibly moving it to some library or even to purple-matrix itself. It would give us enough time to improve and test the code before we publish the code as a library for wider inclusion.

Since Matrix is using a RESTful API, plugging in to Matrix was easy. The basic features like fetching room list, chat history, user details, sending text messages, etc. was done without much effort.

Support for End to End Encryption

The End to End Encryption support is baked using libolm. Getting it right was a bit harder, the official article on how to implement them was pretty helpful on understanding how to implement them under the hood. The session and account secret data are stored in an SQLite database. They are encrypted when saved to the database. The key used to encrypt is handed to the library user which can be stored in a secure space (e.g.: We implemented storing the key with libsecret within Chats)

File encryption and decryption are handled by libgcrypt which is also used to generate random bytes and encryption keys where it’s not supported by libolm.


As the Matrix code in Chats became mature enough, we separated it to create libcmatrix which is a Matrix client library. It has support for transparent E2EE support, and the users of the library don’t have to worry about encryption/decryption as those are handled transparently by libcmatrix.

libcmatrix doesn’t maintain any stable API/ABI and thus users of the library should use it as a subproject to add Matrix support. We wrote libcmatrix in GObjectified C.

Until now, Matrix support within Chats was considered experimental because Chats only stored message events to the database. Other events were either partially stored or ignored. Since the latest 0.7.0rc1 release of Chats, all events are now stored to the database along with the source json. So even if the events are not handled (either by Chats or libcmatrix), the event history is not lost and it’s possible to improve how they are presented in the UI at a later time.

Coming Next…

While you can already enjoy basic end-to-end-encrypted Matrix conversations within Chats, the road is still long before complete Matrix support is finalized. We are actively working toward that goal.

The next steps will be about the following:

  • Improving file sharing support (optimizing file size)
  • Support for room creation and invitation
  • GNOME Contacts integration with support for merging 1:1 SMS/Matrix/XMPP conversations from the same contact
  • Better Librem One integration through GNOME Online Accounts
  • And more…

Feel free to send us your feedback on the current release and stay tuned for the next update.

Recent Posts

Related Content