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 TLVMatter.Tlv.decode- Decode binary TLV to elementsMatter.Tlv.int,uint,bool,string,bytes,null- Value constructorsMatter.Tlv.structure,array,list- Container constructorsMatter.Tlv.ctx_int,ctx_uint, etc. - Context-tagged constructors
Security Modules#
Matter.Pase- SPAKE2+ password-authenticated session establishmentMatter.Case- X.509 certificate-authenticated session establishmentMatter.Aes_ccm- AES-CCM encryption for secure messagesMatter.Session- Session key management and lifecycleMatter.Msg- Matter message framing with encryption
Discovery#
Matter.Discovery- mDNS-based device discovery on the local network
Related Work#
Licence#
MIT License. See LICENSE.md for details.