• Stars
    star
    157
  • Rank 237,504 (Top 5 %)
  • Language
    Dart
  • License
    GNU General Publi...
  • Created over 4 years ago
  • Updated about 2 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Signal Protocol library for Dart/Flutter

libsignal_protocol_dart

pub package Dart CI

libsignal_protocol_dart is a pure 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.

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_print
  print(utf8.decode(plaintextFromAlice));

More Repositories

1

mixin

🚀 The Mixin TEE-BFT-DAG network reference implementation.
Go
508
star
2

ios-app

📱iOS private messenger, crypto wallet and light node to Mixin Network
Swift
497
star
3

android-app

📱 Android private messenger, crypto wallet and light node to Mixin Network
Kotlin
456
star
4

flutter-plugins

🧱 Flutter plugins used in Mixin Messenger.
C
436
star
5

kraken

🐙 High performance WebRTC SFU implemented with pure Go.
Go
330
star
6

flutter-app

💻 Mixin Messenger desktop app for macOS, iPadOS, Linux, and Windows powered by Flutter/Dart.
Dart
281
star
7

ocean.one

🌊 Ocean ONE is a decentralized exchange built on Mixin Network
Go
186
star
8

developers.mixin.one

📒 The Mixin Developers dashboard and docs.
JavaScript
128
star
9

desktop-app

[DEPRECATED]💻 Mixin Messenger desktop app for Windows, macOS, and Linux powered by Electron.
JavaScript
88
star
10

bot-api-go-client

🤖️ Mixin API for Go
Go
71
star
11

tip

🔑 A decentralized key derivation protocol for simple passphrase.
Go
51
star
12

mixin.one

ℹ️ The website of Mixin core team and Mixin Network explorer
TypeScript
49
star
13

kraken.fm

Kraken is an instant and anonymous audio conferencing service
JavaScript
42
star
14

supergroup.mixin.one

🐚 Mixin Super Group Source Code
Go
32
star
15

mixin-wallet

👛 An open-source cryptocurrency wallet bot based on Mixin API, which supports almost all popular cryptocurrencies.
Dart
30
star
16

trusted-group

🪐 Mixin Trusted Group makes decentralized applications on Mixin Messenger and Kernel.
Go
28
star
17

logs

updates and announcements
Shell
25
star
18

donate.cafe

☕️ Accept bitcoin donations now
Vue
19
star
19

multisig-bot

A client only bot to demonstrate the multisig feature of Mixin Messenger.
Go
18
star
20

nfo

🏆 A decentralized layer to support NFT on Mixin Messenger and Kernel.
Go
17
star
21

asset-profile

asset icon and price in Mixin Messenger
16
star
22

bot-api-nodejs-client

Mixin API for JavaScript & Node.js
TypeScript
14
star
23

bot-api-js-client

Mixin bot API for Javascript
JavaScript
13
star
24

safe

🏦 A multiplex cold wallet with multisig and MPC.
Go
12
star
25

bot-manager

Vue
11
star
26

supergroup-bot

Go
9
star
27

mixin_bot_sdk_dart

Dart/Flutter SDK for Mixin
Dart
6
star
28

mobilecoin-go

MobileCoin utilities in Golang
Go
5
star
29

audits

🚨 Security audits for all the repositories.
5
star
30

mvm-contracts

Solidity
4
star
31

mixin.network

The website to showcase the ecosystem of Mixin Network
4
star
32

mvm.app

The website of Mixin Virtual Machine.
TypeScript
4
star
33

flutter_pasteboard

Dart
4
star
34

bot-api-kotlin-client

Mixin bot SDK for Java/Kotlin
Kotlin
4
star
35

near-sdk-go

Go
4
star
36

developer-competition

3
star
37

mixswap_sdk_dart

MixSwap Dart SDK
Dart
3
star
38

safe-go-sdk

Go
2
star
39

mips

Messenger Improvement Proposals
2
star
40

tink-eddsa

Kotlin
2
star
41

governance

Go
2
star
42

mixin-testnet-setup

Mixin Testnet Faucet
2
star
43

bridge.mvm.app

TypeScript
2
star
44

mvm.dev

MVM (Mixin Virtual Machine) document
JavaScript
2
star
45

mixin-rust-sdk

🦀️
Rust
2
star
46

githook-bot

A Mixin Messenger bot for GitHub Webhooks
JavaScript
2
star
47

bot-api-swift-client

Swift
1
star
48

go-number

A golang number library
Go
1
star
49

monero-core

C++
1
star
50

shop

JavaScript
1
star
51

handsaw

A tool for generating i18n strings for multiple platforms.
Kotlin
1
star