{"id":15149949,"url":"https://github.com/hkk97/r2f_x3dh_e2e","last_synced_at":"2026-01-20T03:33:44.316Z","repository":{"id":216980067,"uuid":"742796595","full_name":"hkk97/r2f_x3dh_e2e","owner":"hkk97","description":"r2f_x3dh_e2e is a Rust to Flutter library that provides end-to-end encryption capabilities using the X3DH (Extended Triple Diffie-Hellman) protocol. It enables secure communication between parties by establishing shared secret keys and encrypting data using these keys.","archived":false,"fork":false,"pushed_at":"2024-01-13T17:31:36.000Z","size":81981,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-13T09:51:09.344Z","etag":null,"topics":["end-to-end-encryption","flutter","flutter-rust-bridge","rust","x3dh"],"latest_commit_sha":null,"homepage":"","language":"Dart","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hkk97.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-01-13T11:53:42.000Z","updated_at":"2024-10-11T11:12:40.000Z","dependencies_parsed_at":null,"dependency_job_id":"3a06c3cb-e3f5-4ade-b1db-cd9bf0ad91c1","html_url":"https://github.com/hkk97/r2f_x3dh_e2e","commit_stats":null,"previous_names":["hkk97/r2f_x3dh_e2e"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hkk97%2Fr2f_x3dh_e2e","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hkk97%2Fr2f_x3dh_e2e/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hkk97%2Fr2f_x3dh_e2e/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hkk97%2Fr2f_x3dh_e2e/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hkk97","download_url":"https://codeload.github.com/hkk97/r2f_x3dh_e2e/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247601496,"owners_count":20964863,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["end-to-end-encryption","flutter","flutter-rust-bridge","rust","x3dh"],"created_at":"2024-09-26T14:01:37.926Z","updated_at":"2026-01-20T03:33:44.273Z","avatar_url":"https://github.com/hkk97.png","language":"Dart","funding_links":[],"categories":[],"sub_categories":[],"readme":"# r2f_x3dh_e2e\n\nr2f_x3dh_e2e is a Rust to Flutter library enabling end-to-end encryption using the X3DH protocol, establishing shared secret keys for secure communication.\n\n## Motivation\n\nIn today's digital landscape, ensuring the privacy and security of sensitive data is of paramount importance. End-to-end encryption is a powerful technique that guarantees the confidentiality and integrity of data exchanged between communicating parties. However, implementing end-to-end encryption can be a complex task, requiring expertise in both cryptography and software development.\n\nThe motivation behind the r2f_x3dh_e2e library is to simplify the process of integrating robust end-to-end encryption into Flutter applications. By leveraging the strengths of Rust and Flutter, this library offers a seamless and efficient solution for developers seeking to incorporate secure communication features in their applications.\n\n## Testing Results in Profile Mode\nBased on the performance tests conducted in profile mode, the Rust implementation exhibited a substantial increase in frames per second (FPS), with performance improvements of up to 49 FPS. Similarly, the Dart implementation also demonstrated notable enhancements, achieving an improvement of up to 40 FPS. These results indicate that both Rust and Dart have shown promising optimizations, resulting in higher FPS values and improved overall performance.\n### Comparison of CPU Profile\n| Profile Type | Image |\n|--------------|-------|\n| r2f_x3dh_e2e | ![Rust CPU Profile](demo/rust_to_flutter_cpu_profiler_res.png) |\n| dart_x3dh_e2e | ![Dart CPU Profile](demo/pure_dart_cpu_profile_res.png) |\n\n### Comparison of Performance\n| Profile Type | Image |\n|--------------|-------|\n| r2f_x3dh_e2e | ![Rust Performance](demo/rust_to_flutter_performance_res.gif) |\n| dart_x3dh_e2e | ![Dart Performance](demo/pure_dart_performance_res.gif) |\n\n### Comparison of Memory\n| Profile Type | Image |\n|--------------|-------|\n| r2f_x3dh_e2e | ![Rust Memory](demo/rust_to_flutter_memory_res.gif) |\n| dart_x3dh_e2e | ![Dart Memory](demo/pure_dart_memory_res.gif) |\n\n## Features\n\n- Seamless integration of Rust's cryptography capabilities within Flutter applications.\n- Implements the X3DH protocol for strong security guarantees, including confidentiality and integrity of encrypted data.\n- Supports key generation, encryption, and decryption functions.\n- Accommodates both byte array and hexadecimal string-based keys.\n- Simplifies the process of incorporating secure end-to-end encryption into Flutter applications.\n\n## Advanced Testing\n\nThe [rust_x3dh_e2e](https://github.com/hkk97/rust_x3dh_e2e) and [dart_x3dh_e2e](https://github.com/hkk97/dart_x3dh_e2e) projects employ advanced testing techniques to ensure the reliability and security of their implementations. The testing process includes the following:\n\n- **Unit tests:** Comprehensive unit tests are written to verify the correctness of individual functions and components.\n- **Integration tests:** Integration tests are performed to ensure the seamless integration between the Rust and Flutter components of the library.\n- **End-to-end tests:** End-to-end tests may be conducted to validate the encryption and decryption process, ensuring the privacy and data integrity of the communication.\n\nTest coverage reports and test suite execution results can be used to assess the effectiveness and comprehensiveness of the testing approach.\n\n## Implementation Methods\n\nThe [rust_x3dh_e2e](https://github.com/hkk97/rust_x3dh_e2e) project is implemented in Rust, a programming language known for its focus on safety, performance, and concurrency. The use of Rust ensures that the implementation is memory-safe and provides efficient execution.\n\nThe [dart_x3dh_e2e](https://github.com/hkk97/dart_x3dh_e2e) project, on the other hand, is implemented in Dart, a language commonly used for developing cross-platform mobile applications. Dart offers a rich set of libraries and frameworks for building secure and performant applications.\n\nBoth projects leverage the Extended Triple Diffie-Hellman (X3DH) key agreement protocol, a cryptographic protocol used for establishing shared encryption keys between two parties. This protocol ensures secure key exchange and confidentiality of the communication.\n\nThe [dart_x3dh_e2e](https://github.com/hkk97/dart_x3dh_e2e) project utilizes the Flutter Rust-Bridge, which is a mechanism that allows integrating Rust code into Flutter applications. This combination enables the benefits of both Dart and Rust in terms of cross-platform development and high-performance cryptography.\n\nBy combining the power of Rust and Dart, the [rust_x3dh_e2e](https://github.com/hkk97/rust_x3dh_e2e) and [dart_x3dh_e2e](https://github.com/hkk97/dart_x3dh_e2e) projects aim to provide robust and secure end-to-end encryption solutions using the X3DH protocol. The advanced testing methodologies employed in these projects ensure the reliability, privacy, and data integrity of the communication process.\n\n## Getting Started\n\nTo use r2f_x3dh_e2e in your Flutter project, follow these steps:\n\n1. Add the library as a dependency in your `pubspec.yaml` file:\n    ```yaml\n    dependencies:\n      r2f_x3dh_e2e: ^0.0.2\n    ```\n\n2. Import the library in your Dart code:\n    ```dart\n    import 'package:r2f_x3dh_e2e/r2f_x3dh_e2e.dart';\n    ```\n\n3. Refer to the `example/pubspec.yaml` file in the project repository for usage instructions and code examples. It provides a working example demonstrating the usage of r2f_x3dh_e2e.\n\nFor detailed usage instructions and examples, please refer to the documentation.\n\n## Usage\n\nImport the required packages:\n\n```dart\nimport 'package:r2f_x3dh_e2e/models.dart';\nimport 'package:r2f_x3dh_e2e/r2f_x3dh_e2e.dart';\n```\n\nInitialize the library:\n\n```dart\nfinal r2fX3DHE2ESer = R2FX3DHE2ESer();\nawait r2fX3DHE2ESer.init();\n```\n\n### Encryption\n\nEncrypt data using a shared secret key represented as a list of integers:\n\n```dart\nfinal encryptedMsg = await r2fX3DHE2ESer.encryptWithBytesKey\u003cEncryptedMsg\u003e(\n  x3DHKey: [1, 2, 3, 4, 5], // Shared secret key\n  data: 'Hello, World!', // Data to be encrypted\n);\n\n// Access the encrypted message properties\nfinal ciphertext = encryptedMsg.ciphertext;\nfinal iv = encryptedMsg.iv;\n```\n\nEncrypt data using a shared secret key represented as a hexadecimal string:\n\n```dart\nfinal encryptedMsg = await r2fX3DHE2ESer.encryptWithHexStringKey\u003cEncryptedMsg\u003e(\n  x3DHKey: 'dad2dae999b40bfe4a60881771e87880511ddb0b6bbd503ddddbb4ae22b34ff1', // Shared secret key as a hexadecimal string\n  data: 'Hello, World!', // Data to be encrypted\n);\n\n// Access the encrypted message properties\nfinal ciphertext = encryptedMsg.ciphertext;\nfinal iv = encryptedMsg.iv;\n```\n\n### Decryption\n\nDecrypt a message using a shared secret key represented as a hexadecimal string:\n\n```dart\nfinal decryptedData = await r2fX3DHE2ESer.decryptWithHexStringKey(\n  x3DHKey: 'dad2dae999b40bfe4a60881771e87880511ddb0b6bbd503ddddbb4ae22b34ff1', // Shared secret key as a hexadecimal string\n  ciphertext: [1, 2, 3, 4, 5], // Ciphertext as a list of integers\n  iv: [10, 20, 30, 40, 50], // Initialization vector as a list of integers\n);\n\n// Access the decrypted data\nprint(decryptedData);\n```\n\n## Models\n\nThe `r2f_x3dh_e2e` library provides the following models:\n\n### X3DHKey\n\nRepresents an X3DH shared secret key.\n\nProperties:\n- `hexStr` (String): Hexadecimal string representation of the key.\n- `bytes` (List\u003cint\u003e): List of integers representing the key.\n\n### UniEncryptedMsg\n\nRepresents an encrypted message with additional X3DH key information.\n\nProperties:\n- `ciphertext` (Uint8List): Encrypted data.\n- `iv` (Uint8List): Initialization vector.\n- `x3dhKey` (X3DHKey): X3DH shared secret key.\n\n### EncryptedMsg\n\nRepresents an encrypted message.\n\nProperties:\n- `ciphertext` (Uint8List): Encrypted data.\n- `iv` (Uint8List): Initialization vector.\n\n## Contribution\n\nContributions to r2f_x3dh_e2e are welcome! If you encounter any issues or have suggestions for improvements, please open an issue or submit a pull request. We appreciate your feedback and contributions.\n\n## License\n\nr2f_x3dh_e2e is licensed under the [MIT License](LICENSE).\n\n## Project Repositories\n\n- [dart_x3dh_e2e](https://github.com/hkk97/dart_x3dh_e2e): Repository for the Dart implementation of the X3DH end-to-end encryption library.\n- [rust_x3dh_e2e](https://github.com/hkk97/rust_x3dh_e2e): Repository for the Rust implementation of the X3DH end-to-end encryption library.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhkk97%2Fr2f_x3dh_e2e","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhkk97%2Fr2f_x3dh_e2e","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhkk97%2Fr2f_x3dh_e2e/lists"}