PHPackages                             rakshazi/libsignal-php - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Security](/categories/security)
4. /
5. rakshazi/libsignal-php

ActiveLibrary[Security](/categories/security)

rakshazi/libsignal-php
======================

Fork of mgp25/libsignal-php. This is a php port of libsignal-java originally written by Moxie Marlinspike

03.1kPHP

Since Apr 9Pushed 6y agoCompare

[ Source](https://github.com/rakshazi/libsignal-php)[ Packagist](https://packagist.org/packages/rakshazi/libsignal-php)[ RSS](/packages/rakshazi-libsignal-php/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependenciesVersions (1)Used By (0)

[![axolotl-php](https://camo.githubusercontent.com/404b6974ffdcdf83e4286c1ea63fcfb4872b4d529d221ff8f988b600fba72af9/687474703a2f2f636c2e6c792f696d6167652f306833633137314c313930412f646f776e6c6f61642f61786f6c6f746c7068702e706e67)](https://camo.githubusercontent.com/404b6974ffdcdf83e4286c1ea63fcfb4872b4d529d221ff8f988b600fba72af9/687474703a2f2f636c2e6c792f696d6167652f306833633137314c313930412f646f776e6c6f61642f61786f6c6f746c7068702e706e67)

This is a php port of [libaxolotl-android](https://github.com/WhisperSystems/libaxolotl-android) originally written by [Moxie Marlinspike](https://github.com/moxie0)

This is used in [Chat API](https://github.com/WHAnonymous/Chat-API).

Overview from original author's:

> This is a ratcheting forward secrecy protocol that works in synchronous and asynchronous messaging environments. The protocol overview is available [here](https://github.com/trevp/axolotl/wiki), and the details of the wire format are available [here](https://github.com/trevp/axolotl/wiki).

Read rest of of details [here](https://github.com/WhisperSystems/libaxolotl-android/blob/master/README.md).

Overview
========

[](#overview)

This is a ratcheting forward secrecy protocol that works in synchronous and asynchronous messaging environments. The protocol overview is available [here](https://github.com/trevp/axolotl/wiki), and the details of the wire format are available [here](https://github.com/WhisperSystems/TextSecure/wiki/ProtocolV2).

PreKeys
-------

[](#prekeys)

This protocol uses a concept called 'PreKeys'. A PreKey is an ECPublicKey and an associated unique ID which are stored together by a server. PreKeys can also be signed.

At install time, clients generate a single signed PreKey, as well as a large list of unsigned PreKeys, and transmit all of them to the server.

Sessions
--------

[](#sessions)

The axolotl protocol is session-oriented. Clients establish a "session," which is then used for all subsequent encrypt/decrypt operations. There is no need to ever tear down a session once one has been established.

Sessions are established in one of three ways:

1. PreKeyBundles. A client that wishes to send a message to a recipient can establish a session by retrieving a PreKeyBundle for that recipient from the server.
2. PreKeyWhisperMessages. A client can receive a PreKeyWhisperMessage from a recipient and use it to establish a session.
3. KeyExchangeMessages. Two clients can exchange KeyExchange messages to establish a session.

State
-----

[](#state)

An established session encapsulates a lot of state between two clients. That state is maintained in durable records which need to be kept for the life of the session.

State is kept in the following places:

1. Identity State. Clients will need to maintain the state of their own identity key pair, as well as identity keys received from other clients.
2. PreKey State. Clients will need to maintain the state of their generated PreKeys.
3. Signed PreKey States. Clients will need to maintain the state of their signed PreKeys.
4. Session State. Clients will need to maintain the state of the sessions they have established.

Install time
------------

[](#install-time)

At install time, a libaxolotl client needs to generate its identity keys, registration id, and prekeys.

```
    $axolotl = new KeyHelper();
    $identityKeyPair = $axolotl->generateIdentityKeyPair();
    $registrationId  = $axolotl->generateRegistrationId();
    $preKeys         = $axolotl->generatePreKeys(startId, 100);
    $lastResortKey   = $axolotl->generateLastResortKey();
    $signedPreKey    = $axolotl->generateSignedPreKey(identityKeyPair, 5);

    // Store $identityKeyPair somewhere durable and safe.
    // Store $registrationId somewhere durable and safe.

    // Store preKeys in PreKeyStore.
    // Store signed prekey in SignedPreKeyStore.
```

Building a session
------------------

[](#building-a-session)

A libaxolotl client needs to implement four interfaces: IdentityKeyStore, PreKeyStore, SignedPreKeyStore, and SessionStore. These will manage loading and storing of identity, prekeys, signed prekeys, and session state.

Once those are implemented, building a session is fairly straightforward:

```
    $sessionStore      = new MySessionStore();
    $preKeyStore       = new MyPreKeyStore();
    $signedPreKeyStore = new MySignedPreKeyStore();
    $identityStore     = new MyIdentityKeyStore();

    // Instantiate a SessionBuilder for a remote recipientId + deviceId tuple.
    $sessionBuilder = new SessionBuilder($sessionStore, $preKeyStore, $signedPreKeyStore,
                                                       $identityStore, $recipientId, $deviceId);

    // Build a session with a PreKey retrieved from the server.
    $sessionBuilder->process($retrievedPreKey);

    $essionCipher = new SessionCipher($sessionStore, $recipientId, $deviceId);
    $message      = $sessionCipher->encrypt("Hello world!");
```

Legal things
============

[](#legal-things)

Cryptography Notice
-------------------

[](#cryptography-notice)

This distribution includes cryptographic software. The country in which you currently reside may have restrictions on the import, possession, use, and/or re-export to another country, of encryption software. BEFORE using any encryption software, please check your country's laws, regulations and policies concerning the import, possession, or use, and re-export of encryption software, to see if this is permitted. See  for more information.

The U.S. Government Department of Commerce, Bureau of Industry and Security (BIS), has classified this software as Export Commodity Control Number (ECCN) 5D002.C.1, which includes information security software using or performing cryptographic functions with asymmetric algorithms. The form and manner of this distribution makes it eligible for export under the License Exception ENC Technology Software Unrestricted (TSU) exception (see the BIS Export Administration Regulations, Section 740.13) for both object code and source code.

License
-------

[](#license)

Licensed under the GPLv3:

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity34

Early-stage or recently created project

 Bus Factor1

Top contributor holds 60% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/5d07cb59ba8a7317225b73c56424f74b590ac60f6991f958f58d31ab50bb70ef?d=identicon)[rakshazi](/maintainers/rakshazi)

---

Top Contributors

[![mgp25](https://avatars.githubusercontent.com/u/5390120?v=4)](https://github.com/mgp25 "mgp25 (42 commits)")[![sgatu](https://avatars.githubusercontent.com/u/11692467?v=4)](https://github.com/sgatu "sgatu (14 commits)")[![archergod](https://avatars.githubusercontent.com/u/4686220?v=4)](https://github.com/archergod "archergod (8 commits)")[![rakshazi](https://avatars.githubusercontent.com/u/3428087?v=4)](https://github.com/rakshazi "rakshazi (6 commits)")

### Embed Badge

![Health badge](/badges/rakshazi-libsignal-php/health.svg)

```
[![Health](https://phpackages.com/badges/rakshazi-libsignal-php/health.svg)](https://phpackages.com/packages/rakshazi-libsignal-php)
```

###  Alternatives

[defuse/php-encryption

Secure PHP Encryption Library

3.9k162.4M214](/packages/defuse-php-encryption)[roave/security-advisories

Prevents installation of composer packages with known security vulnerabilities: no API, simply require it

2.9k97.3M6.4k](/packages/roave-security-advisories)[mews/purifier

Laravel 5/6/7/8/9/10 HtmlPurifier Package

2.0k16.7M113](/packages/mews-purifier)[robrichards/xmlseclibs

A PHP library for XML Security

41278.1M118](/packages/robrichards-xmlseclibs)[bjeavons/zxcvbn-php

Realistic password strength estimation PHP library based on Zxcvbn JS

86917.5M63](/packages/bjeavons-zxcvbn-php)[enlightn/security-checker

A PHP dependency vulnerabilities scanner based on the Security Advisories Database.

33732.2M110](/packages/enlightn-security-checker)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
