Skip to content

Instantly share code, notes, and snippets.

@santoshshinde2012
Last active October 28, 2023 17:06
Show Gist options
  • Save santoshshinde2012/748d7188dfd8df4548c5827577760f70 to your computer and use it in GitHub Desktop.
Save santoshshinde2012/748d7188dfd8df4548c5827577760f70 to your computer and use it in GitHub Desktop.
Basic Of Matrix - An open network for secure, decentralized communication

Basic Of Matrix - An open network for secure, decentralized communication

Introduction

  • Making VoIP, IP messaging and IoT as ubiquitous and flexible as email
  • What is Matrix ?
    • Matrix is an open network for secure, decentralised real-time communication
      • Open Network
        • Open Specification
        • Open Implementation
      • Secure
        • By Default End to End encryption
    • Decentralised
      • Any one can run their own matrix server
    • Matrix is an open standard for interoperable, decentralised, real-time communication over IP.
      • Open standard - Matrix Specification - https://matrix.org/docs/spec/
      • Interoperable - It is designed to interoperate with other communication systems, and being an Open Standard means it's easy to see how to interoperate with it
      • Decentralised - It means there is no central point - anyone can host their own server and have control over their data
      • Real Time - It is designed to function in real-time, which means it is ideal for building systems that require immediate exchange of data, such as Instant Messaging

Problems

  • Users are locked into proprietary communications apps
  • They have no control over or their privacy
  • Their conversation and contacts are fragmented
  • Users wants to communicate with the apps and services which they trust
  • Not be forced into specific services chosen by user contacts

Matrix is for

  • Group chat
  • One to one chat
  • Webrtc signalling
  • Bridging common silos
  • Internet of things data
  • And anything else which needs to pubsub persistent data to the world.

The Matrix Ecosystem

  • The matrix specification (Client/Server API)
  • Server Side
    • Synapse (Reference Matrix) - 1st Generation Matrix Server
    • Dendrite - 2nd Generation Matrix Server
    • Matrix Application Services & Bridges
    • Other servers and Services
  • Client Side
    • matrix-js-sdk
    • matrix-ios-sdk
    • matrix-android-sdk(java)
    • matrix-android-sdk-rx
    • Matrix-android-sdk(kotlin)
    • matrix-angular-sdk
    • matrix-react-sdk
    • MatrixKit (iOS)
    • Matrix iOS Console
    • Matrix Android Console
    • Matrix Web console
    • Other clients

Features

  • Open specification of the Matrix standard
  • Distributed and Federated network (no single party owns your conversations)
  • End to End encryptions
  • Encrypted voice and video calls using WebRTC
  • Bridge break boundaries between networks
  • Integration Widgets
  • Healthy and Friendly community

E2E Encryption

  • Encryption without open source cannot be trusted (Security by obscurity doesn’t work)
  • Without end to end encryption , Matrix’s replicated conversations history is a privacy problem.
  • More then a year is spent building decentralised E2E crypto into the heart of Matrix
  • End-to-End Encryption implementation guide - https://www.matrix.org/docs/guides/end-to-end-encryption-implementation-guide
  • End-to-end encryption in Matrix is based on the Olm and Megolm cryptographic ratchets
  • Implementation of the olm and megolm cryptographic ratchets

    • The library is written in C/C++, but is architected in a way which makes it easy to write wrappers for higher-level languages.
    • https://gitlab.matrix.org/matrix-org/olm
    • The Double Ratchet Algorithm

      • The Double Ratchet algorithm is used by two parties to exchange encrypted messages based on a shared secret key.
      • An implementation of the Double Ratchet cryptographic ratchet described by https://whispersystems.org/docs/specifications/doubleratchet/, written in C and C++11 and exposed as a C API.
      • Typically the parties will use some key agreement protocol (such as X3DH) to agree on the shared secret key.
      • X3DH (Extended Triple Diffie-Hellman)

        • X3DH establishes a shared secret key between two parties who mutually authenticate each other based on public keys.
        • X3DH provides forward secrecy and cryptographic deniability.
        • X3DH is designed for asynchronous settings where one user ("Bob") is offline but has published some information to a server.
        • Another user ("Alice") wants to use that information to send encrypted data to Bob, and also establish a shared secret key for future communication.
        • https://signal.org/docs/specifications/x3dh/
  • The specification of the Olm ratchet can be found in https://gitlab.matrix.org/matrix-org/olm/-/blob/master/docs/olm.md
  • This library also includes an implementation of the Megolm cryptographic ratchet, as specified in https://gitlab.matrix.org/matrix-org/olm/-/blob/master/docs/megolm.md

Matrix Architecture

Home Servers

Client

  • Users in Matrix use one or more clients to communicate.
  • This could be any combination of a web client, a command line client, a mobile client - or embedded clients built into existing apps.
  • It could even be a piece of hardware (e.g. a drone) that is Matrix enabled.
  • Client Server API
  • simple lightweight API to let clients send messages and control rooms
  • synchronise conversation history
  • It is designed to support both lightweight clients which store no state and lazy-load data from the server as required - as well as heavyweight clients which maintain a full local persistent copy of server state.
  • https://matrix.org/docs/spec/client_server/latest

Application Servers

  • Application services are passive and can only observe events from homeserver.
  • Application Services to help you create new communication solutions or extend the capabilities and reach of existing ones
  • Defines how to extend the functionality of Matrix with 'integrations' and bridge to other networks
  • Application Server API

    • Have privileged access to the server
    • Can subscribe to server traffic to provide custom application logic
    • Can masquerade as virtual users
    • The Application Service API (AS API) defines a standard API to allow such extensible functionality to be implemented irrespective of the underlying homeserver implementation.
    • https://matrix.org/docs/spec/application_service/latest
  • Integration API

    • You can embed some widget in room like Etherpad
    • You can integrate bots in room like RSS feed
    • Monitoring tool integration like Grafana
    • Video call conferencing API integration like Jitsi
  • Bridges

    • Unique feature of matrix to unite different networks together
    • Bridge Type
      • Bridgebot
        • Exchange messages with a remote network is to have the bridge log into the network using one or more predefined users called bridge bots
      • Puppeted
        • Matrix user has to already have a valid account on the remote system

Identity Servers

  • A Matrix "Identity" describes both the user ID and any other existing IDs from third party namespaces linked to their account.
  • "Identity Servers" (IS) be used to verify the 3PID and persist and replicate the mappings.

Getting Started

Synapse

Installation Instructions

Try Matrix Now

References

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment