搜尋套件、儲存庫與 APP 分類

套件詳情v0.8.2

libsignal_protocol_dart

適用於 Dart 原生與 Flutter 的 Signal 協議庫,Signal 協議的純 Dart 實現

AndroidiOSWebmacOSWindowsLinux
近 30 天下載
1.8萬
喜歡數
67
Pub 分數
150

安裝套件

flutter pub add libsignal_protocol_dart

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

一種純 Dart 實作的 Signal 協定,可於 Flutter 與 Dart 應用中實現安全的端對端加密通訊。專為跨平台使用設計,支援 Android、iOS、Web、macOS、Windows 與 Linux。該函式庫提供私密訊息傳遞所需的強大加密原語,包含金鑰交換、訊息加密與會話管理。由 Mixin Network 建構,確保與現有 Signal 協定生態系統相容,同時在各平台上維持效能與安全性標準。

適用情境

  • 安全訊息應用
  • 端對端加密聊天
  • 跨平台加密通訊
  • 私人資料傳輸
  • 即時加密語音/影片通話
  • 使用安全會話進行驗證

主要特色

  • 純 Dart 實現
  • 跨平台支援
  • 端對端加密
  • 會話管理
  • 金鑰交換協議
  • 符合訊號協定規範

適合對象

  • 開發安全訊息傳遞的開發者
  • 需要強加密的應用程式
  • 跨平台應用程式
  • 注重隱私的服務
  • 實施安全即時通訊的團隊

使用建議

  • 需要理解密碼學概念
  • 在低階設備上可能有性能開銷
  • 依賴於正確實現以確保安全
  • 不適用於非加密使用情境
  • 僅限信號協議特定功能

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

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));

所屬分類

依賴

依賴清單 11 項

原始碼儲存庫

使用此套件的專案