Package selection guidance compiled from public package information, community data, and project usage.
A pure Dart implementation of the Signal Protocol, enabling secure, end-to-end encrypted communication in Flutter and Dart applications. Designed for cross-platform use, it supports Android, iOS, Web, macOS, Windows, and Linux. The library provides robust cryptographic primitives essential for private messaging, including key exchange, message encryption, and session management. Built by Mixin Network, it ensures compatibility with existing Signal Protocol ecosystems while maintaining performance and security standards across platforms.
Use cases
Secure messaging apps
End-to-end encrypted chat
Cross-platform encrypted communication
Private data transfer
Real-time encrypted voice/video calls
Authentication with secure sessions
Key features
Pure Dart implementation
Cross-platform support
End-to-end encryption
Session management
Key exchange protocols
Compliant with Signal Protocol specification
Suitable for
Developers building secure messaging
Apps requiring strong encryption
Multi-platform applications
Privacy-focused services
Teams implementing secure real-time communication
Considerations
Requires understanding of cryptographic concepts
May have performance overhead on low-end devices
Depends on correct implementation to ensure security
Not suitable for non-encrypted use cases
Limited to Signal Protocol-specific features
Original README
Original README snapshot from the linked source repository. Visit the repository for the latest content.
libsignal_protocol_dart
libsignal_protocol_dart is a pure Dart/Flutter implementation of the Signal Protocol.
Documentation
For more information on how the Signal Protocol works:
At install time, a signal client needs to generate its identity keys, registration id, and prekeys.
Future<void> install() async {
final identityKeyPair = generateIdentityKeyPair();
final registrationId = generateRegistrationId(false);
final preKeys = generatePreKeys(0, 110);
final signedPreKey = generateSignedPreKey(identityKeyPair, 0);
final sessionStore = InMemorySessionStore();
final preKeyStore = InMemoryPreKeyStore();
final signedPreKeyStore = InMemorySignedPreKeyStore();
final identityStore =
InMemoryIdentityKeyStore(identityKeyPair, registrationId);
for (var p in preKeys) {
await preKeyStore.storePreKey(p.id, p);
}
await signedPreKeyStore.storeSignedPreKey(signedPreKey.id, 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:
final remoteAddress = SignalProtocolAddress("remote", 1);
final sessionBuilder = SessionBuilder(sessionStore, preKeyStore,
signedPreKeyStore, identityStore, remoteAddress);
sessionBuilder.processPreKeyBundle(retrievedPreKey);
final sessionCipher = SessionCipher(sessionStore, preKeyStore,
signedPreKeyStore, identityStore, remoteAddress);
final ciphertext = sessionCipher.encrypt(utf8.encode("Hello Mixin"));
deliver(ciphertext);
Building a group session
If you wanna send message to a group, send a SenderKeyDistributionMessage to all members of the group.
const alice = SignalProtocolAddress('+00000000001', 1);
const groupSender = SenderKeyName('Private group', alice);
final aliceStore = InMemorySenderKeyStore();
final bobStore = InMemorySenderKeyStore();
final aliceSessionBuilder = GroupSessionBuilder(aliceStore);
final bobSessionBuilder = GroupSessionBuilder(bobStore);
final aliceGroupCipher = GroupCipher(aliceStore, groupSender);
final bobGroupCipher = GroupCipher(bobStore, groupSender);
final sentAliceDistributionMessage =
await aliceSessionBuilder.create(groupSender);
final receivedAliceDistributionMessage =
SenderKeyDistributionMessageWrapper.fromSerialized(
sentAliceDistributionMessage.serialize());
await bobSessionBuilder.process(
groupSender, receivedAliceDistributionMessage);
final ciphertextFromAlice = await aliceGroupCipher
.encrypt(Uint8List.fromList(utf8.encode('Hello Mixin')));
final plaintextFromAlice = await bobGroupCipher.decrypt(ciphertextFromAlice);
// ignore: avoid_printprint(utf8.decode(plaintextFromAlice));