Matter smart home protocol implementation for OCaml
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

OCaml 97.5%
Dune 0.7%
Other 1.8%
59 1 0

Clone this repository

https://tangled.org/gazagnaire.org/ocaml-matter https://tangled.org/did:plc:jhift2vwcxhou52p3sewcrpx/ocaml-matter
git@git.recoil.org:gazagnaire.org/ocaml-matter git@git.recoil.org:did:plc:jhift2vwcxhou52p3sewcrpx/ocaml-matter

For self-hosted knots, clone URLs may differ based on your setup.

Download tar.gz
README.md

matter#

Matter protocol implementation for OCaml.

Overview#

This library provides an implementation of the Matter smart home protocol as specified in the Matter Core Specification.

Features#

  • TLV encoding/decoding with all tag forms (anonymous, context-specific, common/implicit profile, fully-qualified)
  • PASE (Password-Authenticated Session Establishment) via SPAKE2+
  • CASE (Certificate-Authenticated Session Establishment) via X.509
  • Message framing with encryption for secure sessions
  • mDNS discovery of Matter devices on the local network
  • Session management with secure key exchange
  • AES-CCM encryption for Matter messages

Installation#

Install with opam:

$ opam install matter

If opam cannot find the package, it may not yet be released in the public opam-repository. Add the overlay repository, then install it:

$ opam repo add samoht https://tangled.org/gazagnaire.org/opam-overlay.git
$ opam update
$ opam install matter

Usage#

open Matter.Tlv

(* Create elements *)
let elem =
  structure
    [ ctx_int 1 42; ctx_string 2 "hello"; ctx_bool 3 true ]

(* Encode to binary *)
let binary = encode_one elem

(* Decode from binary *)
let elements =
  match decode binary with
  | Ok elements -> elements
  | Error msg -> failwith msg

API#

TLV Module#

  • Matter.Tlv.encode - Encode elements to binary TLV
  • Matter.Tlv.decode - Decode binary TLV to elements
  • Matter.Tlv.int, uint, bool, string, bytes, null - Value constructors
  • Matter.Tlv.structure, array, list - Container constructors
  • Matter.Tlv.ctx_int, ctx_uint, etc. - Context-tagged constructors

Security Modules#

  • Matter.Pase - SPAKE2+ password-authenticated session establishment
  • Matter.Case - X.509 certificate-authenticated session establishment
  • Matter.Aes_ccm - AES-CCM encryption for secure messages
  • Matter.Session - Session key management and lifecycle
  • Matter.Msg - Matter message framing with encryption

Discovery#

  • Matter.Discovery - mDNS-based device discovery on the local network

Licence#

MIT License. See LICENSE.md for details.