libsignal_protocol_dart 0.0.2

Dart native
Flutter Android iOS

Signal Protocol libray for Dart native and Flutter

libsignal_protocol_dart #

libsignal_protocol_dart is a Dart/Flutter implementation of the Signal Protocol.

Documentation #

For more information on how the Signal Protocol works:

Usage #

Install time #

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

void install() {
  var identityKeyPair = KeyHelper.generateIdentityKeyPair();
  var registerationId = KeyHelper.generateRegistrationId(false);

  var preKeys = KeyHelper.generatePreKeys(0, 110);

  var signedPreKey = KeyHelper.generateSignedPreKey(identityKeyPair, 0);

  var sessionStore = InMemorySessionStore();
  var preKeyStore = InMemoryPreKeyStore();
  var signedPreKeyStore = InMemorySignedPreKeyStore();
  var identityStore =
      InMemoryIdentityKeyStore(identityKeyPair, registerationId);

  for (var p in preKeys) {
    preKeyStore.storePreKey(, p);
  signedPreKeyStore.storeSignedPreKey(, signedPreKey);

Building a session #

A signal 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, you can build a session in this way:

  var remoteAddress = SignalProtocolAddress("remote", 1);
  var sessionBuilder = SessionBuilder(sessionStore, preKeyStore,
      signedPreKeyStore, identityStore, remoteAddress);


  var sessionCipher = SessionCipher(sessionStore, preKeyStore,
      signedPreKeyStore, identityStore, remoteAddress);
  var ciphertext = sessionCipher.encrypt(utf8.encode("Hello Mixin"));