Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@jitsi/megolm

Package Overview
Dependencies
Maintainers
7
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@jitsi/megolm

Megolm single ratchet implementation in pure JavaScript

  • 0.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-50%
Maintainers
7
Weekly downloads
 
Created
Source

megolm.js

Megolm.js is an implementation of the megolm cryptographic ratchet in JavaScript.

Overview and motivation

Megolm is the current cryptographic ratchet used by libolm for group chat sessions.

Its security features and limitations can be found here.

This library exists because we wanted to use a ratchet with the same properties as megolm, but libolm currently ties its use to group chat messages. There are other use cases, however.

This implementation is a port of the C implementation without too many bells and whistles in order to make checking its correctness easier.

API

declare type RatchetData = Array<Uint8Array>;

interface RatchetState {
    counter: number;
    data: RatchetData;
}

/**
 * Megolm.js is a JavaScript implementation of the Megolm cryptographic ratchet.
 * It is intended to be used standalone, but it's interoperable with libolm's
 * implementation.
 */
export declare class Megolm {
    /**
     * Builds a Megolm object from the shared session format used by libolm's
     * OutgoingSession.session_key() method.
     */
    static fromSharedSession(sessionKey: string): Megolm;
    /**
     * Builds a new Megolm instance. The given initial state can be used to restore
     * a previously saved ratchet state.
     */
    constructor(initialState?: RatchetState);
    /**
     * Advances the ratched by one step.
     */
    advance(): Promise<void>;
    /**
     * Advances the ratchet the given number of steps.
     */
    advanceTo(idx: number): Promise<void>;
    /**
     * Encrypts the given data using the current key.
     * The encryption performed is AES-CBC, as specified by megolm.
     */
    encrypt(data: Uint8Array): Promise<ArrayBuffer>;
    /**
     * Decrypts the given data using the current key.
     */
    decrypt(data: Uint8Array): Promise<ArrayBuffer>;
    /**
     * Computes the signature of the given data using HMAC SHA-256.
     */
    sign(data: Uint8Array): Promise<ArrayBuffer>;
    /**
     * Verfifies the given signature for the given data.
     */
    verify(signature: Uint8Array, data: Uint8Array): Promise<boolean>;
    /**
     * Returns the current ratchet state. This can be used to serialize and restore
     * it later.
     */
    getState(): RatchetState;
}

Acknowledgements

The Matrix team, for writing libolm and megolm in the first place.

FAQs

Package last updated on 30 Jul 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc