{"id":29171906,"url":"https://github.com/zama-ai/concrete-ml-extensions","last_synced_at":"2025-10-28T02:03:53.332Z","repository":{"id":290781633,"uuid":"832716120","full_name":"zama-ai/concrete-ml-extensions","owner":"zama-ai","description":"Concrete ML Rust toolkit and Client SDK for Swift and WASM","archived":false,"fork":false,"pushed_at":"2025-06-06T15:20:30.000Z","size":394,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":7,"default_branch":"main","last_synced_at":"2025-07-01T13:09:01.082Z","etag":null,"topics":["fhe","machine-learning","rust"],"latest_commit_sha":null,"homepage":"https://zama.ai","language":"Rust","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/zama-ai.png","metadata":{"files":{"readme":"README.md","changelog":null,"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,"zenodo":null}},"created_at":"2024-07-23T15:20:23.000Z","updated_at":"2025-06-06T15:20:04.000Z","dependencies_parsed_at":"2025-06-08T02:16:14.683Z","dependency_job_id":null,"html_url":"https://github.com/zama-ai/concrete-ml-extensions","commit_stats":null,"previous_names":["zama-ai/concrete-ml-extensions"],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/zama-ai/concrete-ml-extensions","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zama-ai%2Fconcrete-ml-extensions","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zama-ai%2Fconcrete-ml-extensions/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zama-ai%2Fconcrete-ml-extensions/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zama-ai%2Fconcrete-ml-extensions/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zama-ai","download_url":"https://codeload.github.com/zama-ai/concrete-ml-extensions/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zama-ai%2Fconcrete-ml-extensions/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":281371793,"owners_count":26489526,"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","status":"online","status_checked_at":"2025-10-28T02:00:06.022Z","response_time":60,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["fhe","machine-learning","rust"],"created_at":"2025-07-01T13:08:59.218Z","updated_at":"2025-10-28T02:03:53.302Z","avatar_url":"https://github.com/zama-ai.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n\u003c!-- product name logo --\u003e\n\u003cpicture\u003e\n  \u003csource media=\"(prefers-color-scheme: dark)\" srcset=\"https://github.com/user-attachments/assets/75a78517-d423-4a28-8db3-1f50e7d86925\"\u003e\n  \u003csource media=\"(prefers-color-scheme: light)\" srcset=\"https://github.com/user-attachments/assets/674c368f-8030-4407-985b-417a09e1fe87\"\u003e\n  \u003cimg width=600 alt=\"Zama Concrete ML\"\u003e\n\u003c/picture\u003e\n\u003c/p\u003e\n\n\u003chr\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://docs.zama.ai/concrete-ml\"\u003e 📒 Documentation\u003c/a\u003e | \u003ca href=\"https://zama.ai/community\"\u003e 💛 Community support\u003c/a\u003e | \u003ca href=\"https://github.com/zama-ai/awesome-zama\"\u003e 📚 FHE resources by Zama\u003c/a\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://github.com/zama-ai/concrete-ml-extensions/releases\"\u003e\u003cimg src=\"https://img.shields.io/github/v/release/zama-ai/concrete-ml-extensions?style=flat-square\"\u003e\u003c/a\u003e\n  \u003ca href=\"LICENSE\"\u003e\u003cimg src=\"https://img.shields.io/badge/License-BSD--3--Clause--Clear-%23ffb243?style=flat-square\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://github.com/zama-ai/bounty-program\"\u003e\u003cimg src=\"https://img.shields.io/badge/Contribute-Zama%20Bounty%20Program-%23ffd208?style=flat-square\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://slsa.dev\"\u003e\u003cimg alt=\"SLSA 3\" src=\"https://slsa.dev/images/gh-badge-level3.svg\" /\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n## About\n\n### What is Concrete ML Extensions\n\nConcrete ML Extensions by [Zama](https://github.com/zama-ai) is a helper package that helps developers build applications based on **Concrete ML**. It implements low-level cryptographic functions using Fully Homomorphic Encryption (FHE). \n\u003cbr\u003e\u003c/br\u003e\n\n### Main features\n\n- **Fast encrypt-clear matrix multiplication**: This library implements a matrix product between encrypted matrices and clear matrices.\n- **Python and Swift bindings for matrix multiplication client applications**: This library contains bindings that help developers build client applications on various platforms, including iOS.\n- **Encryption/Decryption to [TFHE-rs](https://docs.zama.ai/concrete-ml) ciphertexts**: To provide interoperability with TFHE-rs ciphertexts, Concrete ML Extensions offers encryption and decryption functions that are used in Concrete ML.\n\n*Learn more about Concrete ML Extensions features in the [documentation](https://docs.zama.ai/concrete-ml).*\n\u003cbr\u003e\u003c/br\u003e\n\n## Table of Contents\n\n- **[Installation](#installation)**\n- **[Resources](#resources)**\n  - [Demos](#demos)\n  - [Tutorials](#tutorials)\n  - [Documentation](#documentation)\n- **[Working with Concrete ML Extensions](#working-with-concrete-ml-extensions)**\n  - [Citations](#citations)\n  - [Contributing](#contributing)\n  - [License](#license)\n- **[Support](#support)**\n  \u003cbr\u003e\u003c/br\u003e\n\n\n## Installation\n\nDepending on your OS, Concrete ML Extensions may have GPU support.\n\n|                 OS / HW                 | Available  | Has GPU support |\n| :-------------------------------------: | :-----------------: | :--------------: |\n|                  Linux x86              |         Yes         |       Yes        |\n|                 Windows                 |         No         |        N/A        |\n|            macOS 11+ (Intel)            |         Yes         |       No        |\n| macOS 11+ (Apple Silicon: M1, M2, etc.) |     Yes     |       No        |\n\n\u003e[!Note]\n\u003eConcrete ML Extensions only supports Python `3.8`, `3.9`, `3.10`, `3.11` and `3.12`.\n\n### Pip\n\nConcrete ML Extensions is installed automatically when installing Concrete ML. To install manually from PyPi, run the following:\n\n```\npip install concrete-ml-extensions\n```\n\nTo use the GPU, a CUDA-enabled GPU with support for CUDA \u003e=11.2 should be available on the target machine.\n\n### From Source For Python\n\nThis repository leverages `pyo3` to interface TFHE-rs code in python. First, setup the virtual environment. \nInstall the build tool `maturin` and the rust compiler. \n\n```\nmake install_rs_build_toolchain\npoetry install\npip install maturin\n```\n\nNext, using `maturin` in the virtual environment, build the wheel and install it to the virtual\nenvironment. Build the wheel in release mode so that tfhe-rs is built in release as well.\n\nTo compile for GPU, a CUDA-toolkit version \u003e= 11.2 should be installed on the machine, along with \na compatible `gcc` version (the package compilation is tested with gcc 11.4).  \n\nTo build with CUDA support, use:\n```\nsource .venv/bin/activate\nmaturin develop --release --features cuda\n```\n\nTo build without CUDA (CPU only):\n```\nmaturin develop --release --no-default-features --features \"python_bindings\"\n```\n\n### From Source for iOS\n\nYou can also use Concrete ML Extensions in iOS projects. To do so:\n\n1. Compile the library for both iOS and iOS simulator targets (produces two `.a` static libs).\n2. Generate Swift bindings (produces `.h`, `.modulemap` and `.swift` wrapper).\n3. Package everything into an `.xcframework` (produces `.xcframework`).\n4. Use the `.xcframework` in your iOS project.\n\n##### 1. Compile the library\n```shell\n    cargo build --no-default-features --features \"use_lib2\" --lib --release --target aarch64-apple-ios\n    cargo build --no-default-features --features \"use_lib2\" --lib --release --target aarch64-apple-ios-sim\n```\n\nYou may need to install 2 additional target architectures.\n\n```shell\n    rustup target add aarch64-apple-ios aarch64-apple-ios-sim\n```\n\n##### 2. Generate Swift bindings\n```shell\n    cargo run \\\n        --bin uniffi-bindgen \\\n        --no-default-features \\\n        --features \"uniffi/cli swift_bindings\" \\\n        generate --library target/aarch64-apple-ios/release/libconcrete_ml_extensions.dylib \\\n        --language swift \\\n        --out-dir GENERATED/\n```\n\nNow, three files have been generated in the `GENERATED` subdirectory:\n- `concrete_ml_extensionsFFI.h`\n- `concrete_ml_extensionsFFI.modulemap`.\n- `concrete_ml_extensions.swift`\n\nThe two `*FFI` files compose the low-level C FFI layer: The C header file (`.h`) declares the low-level structs and functions for calling into Rust, and the `.modulemap` exposes them to Swift. We'll create a *first* module with these (called concrete_ml_extensions).\n\nThis is enough to call the Rust library from Swift, but in a very verbose way. Instead, you want to use a higher-level Swift API, using the `*.swift` wrapper. This wrapper is uncompiled swift source code; to use it you can:\n- Either drag and drop it as source in your app codebase (simpler)\n- Or compile it in a second module of its own, and use it as compiled code (more complex)\nYou can read more about why UniFFI split things that way: https://mozilla.github.io/uniffi-rs/0.27/swift/overview.html\n\nNext steps:\n1. Move .h and .module in an include folder, and rename `\u003cname\u003e.modulemap` to `module.modulemap` (.xcframework and Xcode expect this name).\n```shell\n    mkdir -p GENERATED/include\n    mv GENERATED/concrete_ml_extensionsFFI.modulemap GENERATED/include/module.modulemap\n    mv GENERATED/concrete_ml_extensionsFFI.h GENERATED/include/concrete_ml_extensionsFFI.h\n```\n\n##### 3. Create an `.xcframework` package\n\n```shell\n    xcodebuild -create-xcframework \\\n        -library target/aarch64-apple-ios/release/libconcrete_ml_extensions.a \\\n        -headers GENERATED/include/ \\\n        -library target/aarch64-apple-ios-sim/release/libconcrete_ml_extensions.a \\\n        -headers GENERATED/include/ \\\n        -output GENERATED/ConcreteMLExtensions.xcframework\n```\n\n##### 4. Use the `.xcframework` in your iOS project\nFollow the steps below: \n1. Copy .xcframework into your project\n2. Add it to `Target \u003e General \u003e Frameworks, Libraries, and Embedded Content`\n3. Select `Do Not Embed` (it's a static lib)\n4. Copy `concrete_ml_extensions.swift` (as source code) in project\n\n##### Troubleshooting:\n*Error message*:\n\n```\n   \"failed to get iphoneos SDK path: SDK \"iphoneos\" cannot be located\"\n```    \nSolution: Ensure Xcode.app/Settings/Locations/Command Line Tools is set to the right version.\n\n*Error message*:\n\n```\n   Multiple commands produce '...Xcode/DerivedData/Workspace-ejeewzlcxbwwtbbihtdvnvgjkysh/Build/Products/Debug/include/module.modulemap'\n```\n\nTo fix, a workaround [suggested here](https://github.com/jessegrosjean/module-map-error) is to wrap the .h and .modulemap in a subfolder:\n\n```shell\n    mkdir -p GENERATED/ConcreteMLExtensions.xcframework/ios-arm64/Headers/concreteHeaders\n    mkdir -p GENERATED/ConcreteMLExtensions.xcframework/ios-arm64-simulator/Headers/concreteHeaders\n    mv GENERATED/ConcreteMLExtensions.xcframework/ios-arm64/Headers/concrete_ml_extensionsFFI.h \\\n        GENERATED/ConcreteMLExtensions.xcframework/ios-arm64/Headers/module.modulemap \\\n        GENERATED/ConcreteMLExtensions.xcframework/ios-arm64/Headers/concreteHeaders\n    mv GENERATED/ConcreteMLExtensions.xcframework/ios-arm64-simulator/Headers/concrete_ml_extensionsFFI.h \\\n        GENERATED/ConcreteMLExtensions.xcframework/ios-arm64-simulator/Headers/module.modulemap \\\n        GENERATED/ConcreteMLExtensions.xcframework/ios-arm64-simulator/Headers/concreteHeaders\n```\n\n\u003cp align=\"right\"\u003e\n  \u003ca href=\"#about\" \u003e ↑ Back to top \u003c/a\u003e\n\u003c/p\u003e\n\n\u003e \\[!Note\\]\n\u003e **Zama 5-Question Developer Survey**\n\u003e\n\u003e We want to hear from you! Take 1 minute to share your thoughts and helping us enhance our documentation and libraries. 👉 **[Click here](https://www.zama.ai/developer-survey)** to participate.\n\n## Resources\n\n### Demos\n\n- [Encrypted LLM fine-tuning](https://github.com/zama-ai/concrete-ml/tree/main/use_case_examples/lora_finetuning): This demo shows\nhow to fine-tune a LLM using the Low Rank Approximation approach. It leverages the Concrete ML Extensions package to perform the fine-tuning\non encrypted data. \n\n*If you have built awesome projects using Concrete ML that leverages the Concrete ML Extensions package, please let us know and we will be happy to showcase them here!*\n\u003cbr\u003e\u003c/br\u003e\n\n### Tutorials\n\nComing soon.\n\n*Explore more useful resources in [Awesome Zama repo](https://github.com/zama-ai/awesome-zama)*\n\u003cbr\u003e\u003c/br\u003e\n\n### Documentation\n\nFull, comprehensive documentation is available here: [https://docs.zama.ai/concrete-ml](https://docs.zama.ai/concrete-ml).\n\n\u003cp align=\"right\"\u003e\n  \u003ca href=\"#about\" \u003e ↑ Back to top \u003c/a\u003e\n\u003c/p\u003e\n\n## Working with Concrete ML Extensions\n\n### Citations\n\nTo cite Concrete ML Extensions in academic papers, please use the following entry:\n\n```text\n@Misc{ConcreteML,\n  title={Concrete {ML}: a Privacy-Preserving Machine Learning Library using Fully Homomorphic Encryption for Data Scientists},\n  author={Zama},\n  year={2022},\n  note={\\url{https://github.com/zama-ai/concrete-ml}},\n}\n```\n\n### Contributing\n\nTo contribute to Concrete ML Extensions, please refer to [this section of the documentation](docs/developer/contributing.md).\n\u003cbr\u003e\u003c/br\u003e\n\n### License\n\nThis software is distributed under the **BSD-3-Clause-Clear** license. Read [this](LICENSE) for more details.\n\n#### FAQ\n\n**Is Zama’s technology free to use?**\n\n\u003e Zama’s libraries are free to use under the BSD 3-Clause Clear license only for development, research, prototyping, and experimentation purposes. However, for any commercial use of Zama's open source code, companies must purchase Zama’s commercial patent license.\n\u003e\n\u003e All our work is open source and we strive for full transparency about Zama's IP strategy. To know more about what this means for Zama product users, read about how we monetize our open source products in [this blog post](https://www.zama.ai/post/open-source).\n\n**What do I need to do if I want to use Zama’s technology for commercial purposes?**\n\n\u003e To commercially use Zama’s technology you need to be granted Zama’s patent license. Please contact us at hello@zama.ai for more information.\n\n**Do you file IP on your technology?**\n\n\u003e Yes, all of Zama’s technologies are patented.\n\n**Can you customize a solution for my specific use case?**\n\n\u003e We are open to collaborating and advancing the FHE space with our partners. If you have specific needs, please email us at hello@zama.ai.\n\n\u003cp align=\"right\"\u003e\n  \u003ca href=\"#about\" \u003e ↑ Back to top \u003c/a\u003e\n\u003c/p\u003e\n\n## Support\n\n\u003ca target=\"_blank\" href=\"https://zama.ai/community-channels\"\u003e\n\u003cpicture\u003e\n  \u003csource media=\"(prefers-color-scheme: dark)\" srcset=\"https://github.com/zama-ai/concrete-ml/assets/157474013/86502167-4ea4-49e9-a881-0cf97d141818\"\u003e\n  \u003csource media=\"(prefers-color-scheme: light)\" srcset=\"https://github.com/zama-ai/concrete-ml/assets/157474013/3dcf41e2-1c00-471b-be53-2c804879b8cb\"\u003e\n  \u003cimg alt=\"Support\"\u003e\n\u003c/picture\u003e\n\u003c/a\u003e\n\n🌟 If you find this project helpful or interesting, please consider giving it a star on GitHub! Your support helps to grow the community and motivates further development.\n\n\u003cp align=\"right\"\u003e\n  \u003ca href=\"#about\" \u003e ↑ Back to top \u003c/a\u003e\n\u003c/p\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzama-ai%2Fconcrete-ml-extensions","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzama-ai%2Fconcrete-ml-extensions","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzama-ai%2Fconcrete-ml-extensions/lists"}