
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
libsignal-protocol
Advanced tools
[](https://travis-ci.org/signalapp/libsignal-protocol-javascript)
Signal Protocol implementation for the browser based on libsignal-protocol-java.
/dist # Distributables
/build # Intermediate build files
/src # JS source files
/native # C source files for curve25519
/protos # Protobuf definitions
/test # Tests
A ratcheting forward secrecy protocol that works in synchronous and asynchronous messaging environments.
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.
Signal 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 two ways:
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:
This implementation currently depends on the presence of the following types/interfaces, which are available in most modern browsers.
Include dist/libsignal-protocol.js in your webpage.
At install time, a libsignal client needs to generate its identity keys, registration id, and prekeys.
var KeyHelper = libsignal.KeyHelper;
var registrationId = KeyHelper.generateRegistrationId();
// Store registrationId somewhere durable and safe.
KeyHelper.generateIdentityKeyPair().then(function(identityKeyPair) {
// keyPair -> { pubKey: ArrayBuffer, privKey: ArrayBuffer }
// Store identityKeyPair somewhere durable and safe.
});
KeyHelper.generatePreKey(keyId).then(function(preKey) {
store.storePreKey(preKey.keyId, preKey.keyPair);
});
KeyHelper.generateSignedPreKey(identityKeyPair, keyId).then(function(signedPreKey) {
store.storeSignedPreKey(signedPreKey.keyId, signedPreKey.keyPair);
});
// Register preKeys and signedPreKey with the server
A libsignal client needs to implement a storage interface that will manage
loading and storing of identity, prekeys, signed prekeys, and session state.
See test/InMemorySignalProtocolStore.js for an example.
Once this is implemented, building a session is fairly straightforward:
var store = new MySignalProtocolStore();
var address = new libsignal.SignalProtocolAddress(recipientId, deviceId);
// Instantiate a SessionBuilder for a remote recipientId + deviceId tuple.
var sessionBuilder = new libsignal.SessionBuilder(store, address);
// Process a prekey fetched from the server. Returns a promise that resolves
// once a session is created and saved in the store, or rejects if the
// identityKey differs from a previously seen identity for this address.
var promise = sessionBuilder.processPreKey({
registrationId: <Number>,
identityKey: <ArrayBuffer>,
signedPreKey: {
keyId : <Number>,
publicKey : <ArrayBuffer>,
signature : <ArrayBuffer>
},
preKey: {
keyId : <Number>,
publicKey : <ArrayBuffer>
}
});
promise.then(function onsuccess() {
// encrypt messages
});
promise.catch(function onerror(error) {
// handle identity key conflict
});
Once you have a session established with an address, you can encrypt messages using SessionCipher.
var plaintext = "Hello world";
var sessionCipher = new libsignal.SessionCipher(store, address);
sessionCipher.encrypt(plaintext).then(function(ciphertext) {
// ciphertext -> { type: <Number>, body: <string> }
handle(ciphertext.type, ciphertext.body);
});
Ciphertexts come in two flavors: WhisperMessage and PreKeyWhisperMessage.
var address = new SignalProtocolAddress(recipientId, deviceId);
var sessionCipher = new SessionCipher(store, address);
// Decrypt a PreKeyWhisperMessage by first establishing a new session.
// Returns a promise that resolves when the message is decrypted or
// rejects if the identityKey differs from a previously seen identity for this
// address.
sessionCipher.decryptPreKeyWhisperMessage(ciphertext).then(function(plaintext) {
// handle plaintext ArrayBuffer
}).catch(function(error) {
// handle identity key conflict
});
// Decrypt a normal message using an existing session
var sessionCipher = new SessionCipher(store, address);
sessionCipher.decryptWhisperMessage(ciphertext).then(function(plaintext) {
// handle plaintext ArrayBuffer
});
To compile curve25519 from C souce files in /native, install
emscripten.
grunt compile
Copyright 2015-2018 Open Whisper Systems
Licensed under the GPLv3: http://www.gnu.org/licenses/gpl-3.0.html
FAQs
[](https://travis-ci.org/signalapp/libsignal-protocol-javascript)
The npm package libsignal-protocol receives a total of 267 weekly downloads. As such, libsignal-protocol popularity was classified as not popular.
We found that libsignal-protocol demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

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.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.