{"id":14971543,"url":"https://github.com/cosmian/cloudproof_flutter","last_synced_at":"2026-03-01T19:33:08.167Z","repository":{"id":61975589,"uuid":"544987478","full_name":"Cosmian/cloudproof_flutter","owner":"Cosmian","description":"The Flutter API library to Cosmian Cloudproof Encryption","archived":false,"fork":false,"pushed_at":"2024-03-20T14:10:04.000Z","size":197147,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-01-05T02:41:44.495Z","etag":null,"topics":["android","cloud","cloudproof","cryptography","dart","flutter","ios"],"latest_commit_sha":null,"homepage":"","language":"Dart","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Cosmian.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":"2022-10-03T15:30:50.000Z","updated_at":"2024-07-17T04:22:08.000Z","dependencies_parsed_at":"2023-02-18T07:15:55.975Z","dependency_job_id":"334c698d-4f56-4509-a3bd-f763b581f968","html_url":"https://github.com/Cosmian/cloudproof_flutter","commit_stats":{"total_commits":160,"total_committers":7,"mean_commits":"22.857142857142858","dds":0.4375,"last_synced_commit":"7fd01329ba7e70ef793aa5fdd2081fa521fd6b1c"},"previous_names":[],"tags_count":24,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cosmian%2Fcloudproof_flutter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cosmian%2Fcloudproof_flutter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cosmian%2Fcloudproof_flutter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cosmian%2Fcloudproof_flutter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Cosmian","download_url":"https://codeload.github.com/Cosmian/cloudproof_flutter/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240324971,"owners_count":19783585,"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":["android","cloud","cloudproof","cryptography","dart","flutter","ios"],"created_at":"2024-09-24T13:45:21.412Z","updated_at":"2026-03-01T19:33:08.127Z","avatar_url":"https://github.com/Cosmian.png","language":"Dart","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Cloudproof Flutter Library\n\n![workflow](https://github.com/Cosmian/cloudproof_flutter/actions/workflows/ci.yml/badge.svg?branch=main)\n\nThe Cloudproof Flutter library provides a Flutter-friendly API to the [Cosmian Cloudproof Encryption product](https://docs.cosmian.com/).\n\nIn summary, Cloudproof Encryption product secures data repositories in the cloud with attributes-based access control encryption and encrypted search.\n\n\u003c!-- toc --\u003e\n\n- [Licensing](#licensing)\n- [Cryptographic primitives](#cryptographic-primitives)\n  * [Cosmian libraries functionalities overview](#cosmian-libraries-functionalities-overview)\n- [Getting started](#getting-started)\n  * [CoverCrypt](#covercrypt)\n  * [Findex](#findex)\n- [Installation](#installation)\n  * [Download required native libraries](#download-required-native-libraries)\n- [Example](#example)\n- [Tests](#tests)\n  * [WARNINGS](#warnings)\n  * [Implementation details](#implementation-details)\n- [FFI libs notes](#ffi-libs-notes)\n  * [Generating Dart bindings from `cloudproof.h`](#generating-dart-bindings-from-cloudproofh)\n    + [iOS WARNING](#ios-warning)\n  * [Building `.so`, `.a`…](#building-so-a)\n    + [Linux](#linux)\n    + [Android](#android)\n    + [iOS](#ios)\n  * [Supported versions](#supported-versions)\n    + [Downgrade Flutter version with snap installation](#downgrade-flutter-version-with-snap-installation)\n- [Cloudproof versions Correspondence](#cloudproof-versions-correspondence)\n\n\u003c!-- tocstop --\u003e\n\n## Licensing\n\nThe library is available under a dual licensing scheme Affero GPL/v3 and commercial. See [LICENSE.md](LICENSE) for details.\n\n## Cryptographic primitives\n\nThe library is based on:\n\n- [CoverCrypt](https://github.com/Cosmian/cover_crypt) algorithm which allows\n  creating ciphertexts for a set of attributes and issuing user keys with access\n  policies over these attributes. `CoverCrypt` offers Post-Quantum resistance.\n\n- [Findex](https://github.com/Cosmian/findex) which is a cryptographic protocol designed to securely make search queries on\n  an untrusted cloud server. Thanks to its encrypted indexes, large databases can\n  securely be outsourced without compromising usability.\n\n- [FPE](https://github.com/Cosmian/cloudproof_rust/tree/main/crates/fpe) provides `Format Preserving Encryption` techniques for use in a zero-trust environment. These techniques are based on FPE-FF1 which is described in [NIST:800-38G](https://nvlpubs.nist.gov/nistpubs/specialpublications/nist.sp.800-38g.pdf).\n\n- [Anonymization](https://github.com/Cosmian/cloudproof_rust/tree/main/crates/anonymization): `Data anonymization` is the process of transforming data in such a way that it can no longer be used to identify individuals without the use of additional information. This is often done to protect the privacy of individuals whose data is being collected or processed.\n\n- [KMS](https://github.com/Cosmian/kms): The repository offers an implementation of the **Key Management Services** (server + client) handling the life cycle of all the symmetric and asymmetric keys.\n\n### Cosmian libraries functionalities overview\n\nThe following table presents the current support of the Cosmian cryptographic primitives:\n\n|                      | CoverCrypt | Findex | KMS client | FPE | Anonymization |\n| -------------------- | ---------- | ------ | ---------- | --- | ------------- |\n| `cloudproof_rust`    | ✅         | ✅     | ❌         | ✅  | ✅            |\n| `cloudproof_java`    | ✅         | ✅     | ✅         | ❌  | ❌            |\n| `cloudproof_python`  | ✅         | ✅     | ✅         | ✅  | ✅            |\n| `cloudproof_js`      | ✅         | ✅     | ✅         | ✅  | ✅            |\n| `cloudproof_flutter` | ✅         | ✅     | ❌         | ❌  | ❌            |\n\n## Getting started\n\n### CoverCrypt\n\nCoverCrypt allows to decrypt data previously encrypted with one of our libraries (Java, Python, Rust…).\n\nTo get an example of how to use CoverCrypt, take a look at `test/cover_crypt/cover_crypt_test.dart`.\n\n### Findex\n\nFindex allows to do encrypted search queries on an encrypted index. To use Findex you need a driver which is able to store and update indexes (it could be SQLite, Redis, or any other storage method). You can find in `test/findex_redis_test.dart` and `test/findex_sqlite_test.dart` two example of implementation.\n\nTo search, you need:\n\n1. copy/paste the following lines\n2. replace `TODO_ReplaceThisByTheNameOfYourClassOrTheRawFunction` by the name of your class\n3. implement `fetchEntries` and `fetchChains`\n\n```dart\n  static List\u003cUidAndValue\u003e fetchEntries(Uids uids) async {\n    // Implement me!\n  }\n\n  static List\u003cUidAndValue\u003e fetchChains(Uids uids) async {\n    // Implement me!\n  }\n\n  // --------------------------------------------------\n  // Copy-paste code :AutoGeneratedImplementation\n  // --------------------------------------------------\n    static Future\u003cMap\u003cKeyword, Set\u003cLocation\u003e\u003e\u003e search(Set\u003cKeyword\u003e keywords,\n      {int findexHandle = -1}) async {\n    return await Findex.search(keywords, findexHandle: findexHandle);\n  }\n\n  static int fetchEntriesCallback(\n    Pointer\u003cUint8\u003e outputEntryTableLinesPointer,\n    Pointer\u003cUint32\u003e outputEntryTableLinesLength,\n    Pointer\u003cUint8\u003e uidsPointer,\n    int uidsNumber,\n  ) {\n    return Findex.wrapSyncFetchCallback(\n      TODO_ReplaceThisByTheNameOfYourClassOrTheRawFunction.fetchEntries,\n      outputEntryTableLinesPointer,\n      outputEntryTableLinesLength,\n      uidsPointer,\n      uidsNumber,\n    );\n  }\n\n  static int fetchChainsCallback(\n    Pointer\u003cUint8\u003e outputChainTableLinesPointer,\n    Pointer\u003cUint32\u003e outputChainTableLinesLength,\n    Pointer\u003cUint8\u003e uidsPointer,\n    int uidsNumber,\n  ) {\n    return Findex.wrapSyncFetchCallback(\n      TODO_ReplaceThisByTheNameOfYourClassOrTheRawFunction.fetchChains,\n      outputChainTableLinesPointer,\n      outputChainTableLinesLength,\n      uidsPointer,\n      uidsNumber,\n    );\n  }\n```\n\nTo upsert, you need:\n\n1. copy/paste the following lines\n2. replace `TODO_ReplaceThisByTheNameOfYourClassOrTheRawFunction` by the name of your class\n3. implement `fetchEntries`, `upsertEntries` and `insertChains`\n\n```dart\n  static List\u003cUidAndValue\u003e fetchEntries(Uids uids) async {\n    // Implement me!\n  }\n\n  static List\u003cUidAndValue\u003e upsertEntries(UpsertData entries) {\n    // Implement me!\n  }\n\n  static void insertChains(List\u003cUidAndValue\u003e chains) {\n    // Implement me!\n  }\n\n  // --------------------------------------------------\n  // Copy-paste code :AutoGeneratedImplementation\n  // --------------------------------------------------\n\n  static Future\u003cSet\u003cKeyword\u003e\u003e add(Map\u003cIndexedValue, Set\u003cKeyword\u003e\u003e additions,\n      {int findexHandle = -1}) async {\n    return Findex.add(additions, findexHandle: findexHandle);\n  }\n\n  static int upsertEntriesCallback(\n    Pointer\u003cUint8\u003e outputRejectedEntriesListPointer,\n    Pointer\u003cUint32\u003e outputRejectedEntriesListLength,\n    Pointer\u003cUint8\u003e oldValuesPointer,\n    int oldValuesLength,\n    Pointer\u003cUint8\u003e newValuesPointer,\n    int newValuesLength,\n  ) {\n    return Findex.wrapSyncUpsertEntriesCallback(\n      TODO_ReplaceThisByTheNameOfYourClassOrTheRawFunction.upsertEntries,\n      outputRejectedEntriesListPointer,\n      outputRejectedEntriesListLength,\n      oldValuesPointer,\n      oldValuesLength,\n      newValuesPointer,\n      newValuesLength,\n    );\n  }\n\n  static int insertChainsCallback(\n    Pointer\u003cUint8\u003e chainsListPointer,\n    int chainsListLength,\n  ) {\n    return Findex.wrapSyncInsertChainsCallback(\n      TODO_ReplaceThisByTheNameOfYourClassOrTheRawFunction.insertChains,\n      chainsListPointer,\n      chainsListLength,\n    );\n  }\n```\n\nNote that if you `search` and `add`, the two implementation can share the same callback for `fetchEntries`.\n\nNote that if your callbacks are `async`, you can use `Findex.wrapAsyncFetchCallback`, `wrapAsyncUpsertEntriesCallback` and `wrapAsyncInsertChainsCallback`.\n\nNote that the copy/paste code could be removed in a future version when Dart implements \u003chttps://github.com/dart-lang/language/issues/1482\u003e.\n\n## Installation\n\n```bash\nflutter pub get cloudproof\n```\n\n### Download required native libraries\n\nThe Cloudproof Flutter lib uses FFI to access functions of the following native cryptographic libraries:\n\n- `CoverCrypt`\n- `Findex`\n\nThose libraries must be found in specific subfolders for Android, iOS and PC architectures.\n\n- Android: in `android/src/main/jniLibs/` subfolders:\n  - `arm64-v8a`\n  - `armeabi-v7a`\n  - `x86`\n  - `x86_64`\n- iOS: in `ios/` folder\n- PC: in `resources/` folder\n\nTo download them, please run the following script that will fetch the releases in the public URL [package.cosmian.com](https://package.cosmian.com):\n:\n\n```bash\nflutter pub get\npython3 scripts/get_native_libraries.py\n```\n\nOtherwise, to build those libraries manually, please check the CoverCrypt and Findex projects on Github: their `build` directory contains instructions on how to build the native libraries for your system.\n\n## Example\n\nTo run the example, you need a Redis server configured. Then, update `redisHost` and `redisPort` at the top of the `example/lib/findex_redis_implementation.dart` file.\n\n## Tests\n\nTo run all tests:\n\n```bash\nflutter test\n```\n\nSome tests require a Redis database on localhost (default port).\n\nYou can run the benchmarks with:\n\n```bash\ndart benchmark/cloudproof_benchmark.dart\n```\n\n### WARNINGS\n\n- `fetchEntries`, `fetchChains`, `upsertEntries` and `insertChains` can not be static methods in a class or raw functions but should be static! You cannot put classic methods of an instance here.\n- `fetchEntries`, `fetchChains`, `upsertEntries` and `insertChains` (if async) cannot access the state of the program, they will run in a separate `Isolate` with no data from the main thread (for example static/global variables populated during an initialization phase of your program will not exist). If you need to access some data from the main thread, the only way we think we'll work is to save this information inside a file or a database and read it from the callback. This pattern will slow down the `search` process. If you don't need async in the callbacks (for example the `sqlite` library has sync functions, you can call `*WrapperWithoutIsolate` and keep all the process in the same thread, so you can use your global variables).\n\n### Implementation details\n\n- The `search` and `upsert` methods will call the Rust FFI via native bindings synchronously. If you want to not stop your main thread, please call `compute` to run the search in a different Isolate.\n\n## FFI libs notes\n\nThis project has been first created via:\n\n```bash\nflutter create --org com.example --template=plugin --platforms=android,ios -a kotlin cloudproof\n```\n\n### Generating Dart bindings from `cloudproof.h`\n\nThe `lib/src/generated_bindings.dart` are generated with `ffigen` with the config file `./ffigen_*.yml`:\n\n```bash\nflutter pub run ffigen --config ffigen_cloudproof.yaml\n```\n\n#### iOS WARNING\n\nUse cbindgen, do not forget to remove `str` type in `libcloudproof_cover_crypt.h` (last two lines) for iOS to compile (type `str` unknown in C headers).\n\nThe two `.h` need to be inside the `ios/Classes` folder. Android doesn't need `.h` files.\n\n### Building `.so`, `.a`…\n\n#### Linux\n\nJust copy `.so` file from the Rust projects to the `resources` folder. These `.so` are only useful to run the tests on Linux.\n\n#### Android\n\nDownload artifacts from the Gitlab CI. You should get a `jniLibs` folder to copy to `android/src/main`.\n\nThen:\n\n```bash\ncd example\nflutter pub get\nflutter run\n```\n\n#### iOS\n\nIf building with `cargo lipo` on Linux we only get `aarch64-apple-ios` and `x86_64-apple-ios`.\n\nOn codemagic.io:\n\n- `aarch64-apple-ios` is failing with \"ld: in /Users/builder/clone/ios/libcloudproof_cover_crypt.a(cover_crypt.cover_crypt.aea4b2d2-cgu.0.rcgu.o), building for iOS Simulator, but linking in object file built for iOS, file '/Users/builder/clone/ios/libcloudproof_cover_crypt.a' for architecture arm64\"\n- `x86_64-apple-ios` is failing with \"ld: warning: ignoring file /Users/builder/clone/ios/libcloudproof_cover_crypt.a, building for iOS Simulator-arm64 but attempting to link with file built for iOS Simulator-x86_64\"\n\nTo make the flutter build succeed, 3 prerequisites are needed:\n\n- declaring headers (CoverCrypt and Findex) in CloudproofPlugin.h (concat both headers)\n- call artificially 1 function of each native library in SwiftCloudproofPlugin.swift\n- use universal ios build: copy both .a in `cloudproof_flutter/ios`\n\n### Supported versions\n\n| Linux        | Flutter | Dart   | Android SDK       | NDK | Glibc | LLVM     | Smartphone Virtual Device |\n| ------------ | ------- | ------ | ----------------- | --- | ----- | -------- | ------------------------- |\n| Ubuntu 22.04 | 3.3.4   | 2.18.2 | Chipmunk 2021.2.1 | r25 | 2.35  | 14.0.0-1 | Pixel 5 API 30            |\n| Centos 7     | 3.3.4   | 2.18.2 | Chipmunk 2021.2.1 | r25 | 2.17  | -        | -                         |\n\n| Mac      | Flutter | Dart   | OS       | LLVM   | Xcode | Smartphone Virtual Device |\n| -------- | ------- | ------ | -------- | ------ | ----- | ------------------------- |\n| Catalina | 3.3.4   | 2.18.2 | Catalina | 12.0.0 |       | iPhone 12 PRO MAX         |\n\n#### Downgrade Flutter version with snap installation\n\n```bash\ncd ~/snap/flutter/common/flutter/\ngit checkout 3.3.4\n```\n\n## Cloudproof versions Correspondence\n\nWhen using local encryption and decryption with [CoverCrypt](https://github.com/Cosmian/cover_crypt) native libraries are required.\n\nCheck the main pages of the respective projects to build the native libraries appropriate for your systems. The [resources directory](./resources/) provides pre-built libraries for Linux GLIBC 2.17. These libraries should run fine on a system with a more recent GLIBC version.\n\nThis table shows the minimum versions correspondences between the various components\n\n| Flutter Lib       | CoverCrypt lib    | Findex |\n| ----------------- | ----------------- | ------ |\n| 0.1.0             | 6.0.5             | 0.7.2  |\n| 1.0.0             | 6.0.5             | 0.7.2  |\n| 2.0.0             | 7.1.0             | 0.10.0 |\n| 3.0.0             | 8.0.0             | 0.12.0 |\n| 4.0.0             | 8.0.0             | 1.0.1  |\n| 4.0.1,4.0.2,4.0.3 | 8.0.0,8.0.1,8.0.2 | 2.0.0  |\n| 5.0.0             | 10.0.0            | 2.0.1  |\n| 5.1.0             | 10.0.0            | 2.1.0  |\n\nFrom the version 6.0.0, `cloudproof_flutter` depends on [cloudproof_rust](https://github.com/Cosmian/cloudproof_rust) which wraps the interfaces of `CoverCrypt` and `Findex`.\n\n| Flutter Lib | Cloudproof Rust lib |\n| ----------- | ------------------- |\n| 6.0.0       | 1.0.0               |\n| 6.0.2       | 1.0.1               |\n| 7.0.0       | 2.0.1               |\n| 8.0.0       | 2.4.0               |\n| 8.1.0       | 3.0.0               |\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcosmian%2Fcloudproof_flutter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcosmian%2Fcloudproof_flutter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcosmian%2Fcloudproof_flutter/lists"}