{"id":13566308,"url":"https://github.com/mortendahl/rust-paillier","last_synced_at":"2025-04-08T06:36:54.730Z","repository":{"id":49036785,"uuid":"134954048","full_name":"mortendahl/rust-paillier","owner":"mortendahl","description":"A pure-Rust implementation of the Paillier encryption scheme","archived":false,"fork":false,"pushed_at":"2024-11-25T21:13:34.000Z","size":287,"stargazers_count":116,"open_issues_count":21,"forks_count":75,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-01T04:53:25.925Z","etag":null,"topics":["cryptography","homomorphic-encryption","paillier","secure-computation","zero-knowledge"],"latest_commit_sha":null,"homepage":"","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/mortendahl.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}},"created_at":"2018-05-26T11:04:02.000Z","updated_at":"2025-02-04T20:02:46.000Z","dependencies_parsed_at":"2024-12-14T00:06:46.383Z","dependency_job_id":"392f7c69-e1ad-4fc0-87e7-0d78dd6a3869","html_url":"https://github.com/mortendahl/rust-paillier","commit_stats":{"total_commits":111,"total_committers":9,"mean_commits":"12.333333333333334","dds":0.5855855855855856,"last_synced_commit":"6c1a29a19d964c6a1c990d5f8f88c051a4a76039"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mortendahl%2Frust-paillier","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mortendahl%2Frust-paillier/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mortendahl%2Frust-paillier/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mortendahl%2Frust-paillier/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mortendahl","download_url":"https://codeload.github.com/mortendahl/rust-paillier/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247792892,"owners_count":20996891,"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":["cryptography","homomorphic-encryption","paillier","secure-computation","zero-knowledge"],"created_at":"2024-08-01T13:02:06.750Z","updated_at":"2025-04-08T06:36:54.711Z","avatar_url":"https://github.com/mortendahl.png","language":"Rust","funding_links":[],"categories":["Rust"],"sub_categories":[],"readme":"# Paillier\n\n[![Build Status](https://travis-ci.org/mortendahl/rust-paillier.svg)](https://travis-ci.org/mortendahl/rust-paillier)\n[![Latest version](https://img.shields.io/crates/v/paillier.svg)](https://img.shields.io/crates/v/paillier.svg)\n[![License: MIT/Apache2](https://img.shields.io/badge/license-MIT%2fApache2-blue.svg)](https://img.shields.io/badge/license-MIT%2fApache2-blue.svg)\n\nEfficient pure-Rust library for the [Paillier](https://en.wikipedia.org/wiki/Paillier_cryptosystem) partially homomorphic encryption scheme, offering also packed encoding for encrypting several values together as well as several zero-knowledge proofs related to typical use-cases.\nSupports several underlying arbitrary precision libraries, including [RAMP](https://github.com/Aatch/ramp) and [GMP](https://github.com/fizyk20/rust-gmp).\n\nSeveral companies have invested resources in the development of this library, including [Snips](https://snips.ai/) who implemented the [original version](https://github.com/snipsco/rust-paillier) for use in their privacy-preserving analytics system, and [KZen networks](https://github.com/KZen-networks) who contributed with implementations of many zero-knowledge proofs. See [contributions](#contributions) below for more details.\n\n**Important**: while we have followed recommendations regarding the scheme itself, some parts of this library have not yet been harden against non-cryptographic attacks such as side-channel attacks.\n\n\n```rust\nextern crate paillier;\nuse paillier::*;\n\nfn main() {\n\n  // generate a fresh keypair and extract encryption and decryption keys\n  let (ek, dk) = Paillier::keypair().keys();\n\n  // encrypt four values\n  let c1 = Paillier::encrypt(\u0026ek, 10);\n  let c2 = Paillier::encrypt(\u0026ek, 20);\n  let c3 = Paillier::encrypt(\u0026ek, 30);\n  let c4 = Paillier::encrypt(\u0026ek, 40);\n\n  // add all of them together\n  let c = Paillier::add(\u0026ek,\n    \u0026Paillier::add(\u0026ek, \u0026c1, \u0026c2),\n    \u0026Paillier::add(\u0026ek, \u0026c3, \u0026c4)\n  );\n\n  // multiply the sum by 2\n  let d = Paillier::mul(\u0026ek, \u0026c, 2);\n\n  // decrypt final result\n  let m: u64 = Paillier::decrypt(\u0026dk, \u0026d);\n  println!(\"decrypted total sum is {}\", m);\n\n}\n```\n\n# Installation\n\nSome features are optional yet currently included by default. See [Features](#features) below for more details. Note that the nightly toolchain is currently needed to build the library.\n\n## Using cargo\n```toml\n[dependencies]\npaillier = { version=\"0.2\" }\n```\n\n## From source\n```bash\ngit clone https://github.com/mortendahl/rust-paillier\ncd rust-paillier\ncargo build --release\n```\n\n## Features\n\nThe library supports the following features. The default compilation is equivalent to\n```\ncargo build --release --no-default-features --features \"usegmp keygen proofs\"\n```\nusing GMP and including both key generation and zero-knowledge proofs.\n\n### Underlying arithmetic\n\nThe choice of underlying arithmetic library may be changed using features `usegmp` (default) and `useramp`. GMP generally offers [slightly better performance](https://medium.com/snips-ai/benchmarking-paillier-encryption-15631a0b5ad8) but may be unavailable on some platforms or for some applications. Note that `useramp` does currently *not* support proofs, i.e. features `useramp` and `proofs` cannot be used together.\n\n### Key generation\n\nKey generation feature `keygen` is included by default but if unneeded may safely be excluded to avoid extra dependencies.\n\n```rust\nextern crate paillier;\nuse paillier::*;\n\nfn main() {\n\n  // generate a fresh keypair and extract encryption and decryption keys\n  let (ek, dk) = Paillier::keypair().keys();\n\n  ...\n\n}\n```\n\n### Zero-knowledge proofs\n\nFeature `proofs` includes various zero-knowledge proofs related to the typical use of Paillier encryption. Turned on by default but may safely be excluded if unneeded.\n\n# Benchmarks\n\nSeveral benches are included, testing both the underlying arithmetic libraries as well as the operations of the scheme. All may be run using\n```\ncargo bench\n```\nand including either several arithmetic libraries and key generation as discussed [above](#building).\n\n# License\n\nForked from [`snipsco/rust-paillier`](https://github.com/snipsco/rust-paillier) with additional functionality. Licensed under either of\n\n * Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)\n * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)\n\nat your option.\n\nUnless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.\n\n\n# Contributions\n\nSeveral people have had a significant impact in the development of this library (in alphabetical order):\n- [Mario Cornejo](https://github.com/mcornejo) (while at Snips)\n- [Mathieu Poumeyrol](https://github.com/kali) (Snips)\n\n[Snips](https://github.com/snipsco) sponsored implementation of the original version\n\n## Reported uses\n\n- [Snips](https://github.com/snipsco): privacy-preserving analytics\n- [KZen networks](https://github.com/KZen-networks): multi-party signatures\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmortendahl%2Frust-paillier","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmortendahl%2Frust-paillier","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmortendahl%2Frust-paillier/lists"}