19 Oct 2015 18:14:01 UTC
- Distribution: Protocol-Matrix
- Module version: 0.02
- Source (raw)
- Browse (raw)
- How to Contribute
- Issues (1)
- Testers (823 / 0 / 93)
- KwaliteeBus factor: 1
- 89.94% Coverage
- License: perl_5
- Perl: v5.14.0
- Activity24 month
- Download (16.39KB)
- MetaCPAN Explorer
- Subscribe to distribution
- This version
- Latest version
Protocol::Matrix- Helper functions for the Matrix protocol
This module provides some helper functions for implementing a matrix client or server. Currently it only contains a few base-level functions to assist with signing and verifying signatures on federation-level events.
$json = encode_json_for_signing( $data )
Encodes a given HASH reference as Canonical JSON, having removed the
unsignedkeys if present. This is the first step towards signing it or verifying an embedded signature in it. The hash referred to by
$dataremains unmodified by this function.
$base64 = encode_base64( $bytes )
Returns a character string containing the Base-64 encoding of the given bytes, with no internal linebreaks and no trailing padding.
$bytes = decode_base64( $base64 )
Returns a byte string containing the bytes obtained by decoding the given character string. This is re-exported from MIME::Base64 for convenience.
sign_json( $data, secret_key => $key, origin => $name, key_id => $id )
Modifies the given HASH reference in-place to add a signature. This signature is created from the given key, and annotated as being from the given origin name and key ID. Existing signatures already in the hash are not disturbed.
my $data = signed_json( $data, ... )
verify_json_signature( $data, public_key => $key, origin => $name, key_id => $id )
Inspects the given HASH reference to check that it contains a signature from the named origin, with the given key ID, and that it is actually valid.
This function does not return an interesting value; all failures are indicated by thrown exceptions. If no exception is thrown, it can be presumed valid.
redact_event( $event )
Modifies the given HASH reference in-place to apply the transformation given by the Matrix Event Redaction specification.
sign_event_json( $data, secret_key => $key, origin => $name, key_id => $id )
Modifies the given HASH reference in-place to add a hash and signature, presuming it to be a Matrix event structure. This operates in a fashion analogous to "sign_json".
my $event = signed_event_json( $event, ... )
verify_event_json_signature( $event, public_key => $key, origin => $name, key_id => $id )
Paul Evans <firstname.lastname@example.org>
Module Install Instructions
To install Protocol::Matrix, copy and paste the appropriate command in to your terminal.
perl -MCPAN -e shell install Protocol::Matrix
For more information on module installation, please visit the detailed CPAN module installation guide.