{"id":22432983,"url":"https://github.com/lapets/pailliers","last_synced_at":"2026-02-06T02:04:01.750Z","repository":{"id":262259007,"uuid":"803409906","full_name":"lapets/pailliers","owner":"lapets","description":"Minimal pure-Python implementation of Paillier's additively homomorphic cryptosystem.","archived":false,"fork":false,"pushed_at":"2025-12-22T04:41:23.000Z","size":54,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-12-23T16:06:30.060Z","etag":null,"topics":["cryptography","cryptography-library","homomorphic-cryptography-scheme","homomorphic-encryption","homomorphic-encryption-library","paillier","paillier-cryptosystem","partially-homomorphic"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/pailliers","language":"Python","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/lapets.png","metadata":{"files":{"readme":"README.rst","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,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-05-20T17:05:56.000Z","updated_at":"2025-12-20T03:22:48.000Z","dependencies_parsed_at":"2024-11-11T13:38:52.592Z","dependency_job_id":"a9f70b01-80df-4c67-b513-261e0a7542d8","html_url":"https://github.com/lapets/pailliers","commit_stats":null,"previous_names":["lapets/paillier"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/lapets/pailliers","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lapets%2Fpailliers","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lapets%2Fpailliers/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lapets%2Fpailliers/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lapets%2Fpailliers/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lapets","download_url":"https://codeload.github.com/lapets/pailliers/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lapets%2Fpailliers/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29145565,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-06T01:13:33.096Z","status":"online","status_checked_at":"2026-02-06T02:00:08.092Z","response_time":59,"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":["cryptography","cryptography-library","homomorphic-cryptography-scheme","homomorphic-encryption","homomorphic-encryption-library","paillier","paillier-cryptosystem","partially-homomorphic"],"created_at":"2024-12-05T22:13:19.997Z","updated_at":"2026-02-06T02:04:01.743Z","avatar_url":"https://github.com/lapets.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"=========\npailliers\n=========\n\nMinimal pure-Python implementation of `Paillier's additively homomorphic cryptosystem \u003chttps://en.wikipedia.org/wiki/Paillier_cryptosystem\u003e`__.\n\n|pypi| |readthedocs| |actions| |coveralls|\n\n.. |pypi| image:: https://badge.fury.io/py/pailliers.svg#\n   :target: https://badge.fury.io/py/pailliers\n   :alt: PyPI version and link.\n\n.. |readthedocs| image:: https://readthedocs.org/projects/pailliers/badge/?version=latest\n   :target: https://pailliers.readthedocs.io/en/latest/?badge=latest\n   :alt: Read the Docs documentation status.\n\n.. |actions| image:: https://github.com/lapets/pailliers/workflows/lint-test-cover-docs/badge.svg#\n   :target: https://github.com/lapets/pailliers/actions/workflows/lint-test-cover-docs.yml\n   :alt: GitHub Actions status.\n\n.. |coveralls| image:: https://coveralls.io/repos/github/lapets/pailliers/badge.svg?branch=main\n   :target: https://coveralls.io/github/lapets/pailliers?branch=main\n   :alt: Coveralls test coverage summary.\n\nInstallation and Usage\n----------------------\nThis library is available as a `package on PyPI \u003chttps://pypi.org/project/pailliers\u003e`__:\n\n.. code-block:: bash\n\n    python -m pip install pailliers\n\nThe library can be imported in the usual manner:\n\n.. code-block:: python\n\n    from pailliers import *\n\nExamples\n^^^^^^^^\n\n.. |secret| replace:: ``secret``\n.. _secret: https://pailliers.readthedocs.io/en/0.3.1/_source/pailliers.html#pailliers.pailliers.secret\n\n.. |public| replace:: ``public``\n.. _public: https://pailliers.readthedocs.io/en/0.3.1/_source/pailliers.html#pailliers.pailliers.public\n\n.. |encrypt| replace:: ``encrypt``\n.. _encrypt: https://pailliers.readthedocs.io/en/0.3.1/_source/pailliers.html#pailliers.pailliers.encrypt\n\n.. |decrypt| replace:: ``decrypt``\n.. _decrypt: https://pailliers.readthedocs.io/en/0.3.1/_source/pailliers.html#pailliers.pailliers.decrypt\n\n\nThis library supports the creation of |secret|_ keys, derivation of |public|_ keys from |secret|_ keys, encryption of integers into ciphertexts using public keys via |encrypt|_, and decryption of ciphertexts into integers using |secret|_ keys via |decrypt|_:\n\n.. code-block:: python\n\n    \u003e\u003e\u003e secret_key = secret(2048)\n    \u003e\u003e\u003e public_key = public(secret_key)\n    \u003e\u003e\u003e c = encrypt(public_key, 123)\n    \u003e\u003e\u003e int(decrypt(secret_key, c))\n    123\n\n.. |cipher| replace:: ``cipher``\n.. _cipher: https://pailliers.readthedocs.io/en/0.3.1/_source/pailliers.html#pailliers.pailliers.cipher\n\n.. |int| replace:: ``int``\n.. _int: https://docs.python.org/3/library/functions.html#int\n\n.. |special_add| replace:: ``__add__``\n.. _special_add: https://pailliers.readthedocs.io/en/0.3.1/_source/pailliers.html#pailliers.pailliers.cipher.__add__\n\n.. |special_mul| replace:: ``__mul__``\n.. _special_mul: https://pailliers.readthedocs.io/en/0.3.1/_source/pailliers.html#pailliers.pailliers.cipher.__mul__\n\nThe |encrypt|_ function returns instances of the |cipher|_ class (which is `derived \u003chttps://docs.python.org/3/tutorial/classes.html#inheritance\u003e`__ from the built-in |int|_ type) that represent ciphertexts. Because the |cipher|_ class includes definitions of special methods (such as |special_add|_ and |special_mul|_) corresponding to Python's built-in addition and multiplication operators, these operators can be used to add two ciphertexts and to multiply a ciphertext by an integer scalar:\n\n.. code-block:: python\n\n    \u003e\u003e\u003e c = encrypt(public_key, 123)\n    \u003e\u003e\u003e d = encrypt(public_key, 456)\n    \u003e\u003e\u003e r = (c * 2) + d\n    \u003e\u003e\u003e int(decrypt(secret_key, r))\n    702\n\n.. |special_iadd| replace:: ``__iadd__``\n.. _special_iadd: https://pailliers.readthedocs.io/en/0.3.1/_source/pailliers.html#pailliers.pailliers.cipher.__iadd__\n\n.. |special_imul| replace:: ``__imul__``\n.. _special_imul: https://pailliers.readthedocs.io/en/0.3.1/_source/pailliers.html#pailliers.pailliers.cipher.__imul__\n\n.. |special_radd| replace:: ``__radd__``\n.. _special_radd: https://pailliers.readthedocs.io/en/0.3.1/_source/pailliers.html#pailliers.pailliers.cipher.__radd__\n\n.. |sum| replace:: ``sum``\n.. _sum: https://docs.python.org/3/library/functions.html#sum\n\nOther special methods make it possible to use a single variable to accumulate iteratively (via |special_iadd|_ and |special_imul|_) and to use the built-in |sum|_ function (via |special_radd|_):\n\n.. code-block:: python\n\n    \u003e\u003e\u003e b = 0\n    \u003e\u003e\u003e b += encrypt(public_key, 1)\n    \u003e\u003e\u003e b += encrypt(public_key, 2)\n    \u003e\u003e\u003e b += encrypt(public_key, 3)\n    \u003e\u003e\u003e b *= 2\n    \u003e\u003e\u003e b = sum([b, b, b])\n    \u003e\u003e\u003e int(decrypt(secret_key, b))\n    36\n\n.. |add| replace:: ``add``\n.. _add: https://pailliers.readthedocs.io/en/0.3.1/_source/pailliers.html#pailliers.pailliers.add\n\n.. |mul| replace:: ``mul``\n.. _mul: https://pailliers.readthedocs.io/en/0.3.1/_source/pailliers.html#pailliers.pailliers.mul\n\nAddition will only work on two or more instances of the |cipher|_ class. To facilitate the use of |cipher|_ instances that do not all maintain internal copies of the same public key (*e.g.*, in cases where memory constraints are an issue or ciphertexts are stored/communicated separately from key information), the |add|_ and |mul|_ functions are also provided. The public key must be supplied explicitly to these functions:\n\n.. code-block:: python\n\n    \u003e\u003e\u003e c = int(encrypt(public_key, 123))\n    \u003e\u003e\u003e d = int(encrypt(public_key, 456))\n    \u003e\u003e\u003e r = mul(public_key, cipher(c), 2)\n    \u003e\u003e\u003e s = add(public_key, r, cipher(d))\n    \u003e\u003e\u003e int(decrypt(secret_key, s))\n    702\n\nAn alternative to the above is to instantiate |cipher|_ instances using explicit ciphertext values and the public key used to encrypt them:\n\n.. code-block:: python\n\n    \u003e\u003e\u003e c = int(encrypt(public_key, 123))\n    \u003e\u003e\u003e d = int(encrypt(public_key, 456))\n    \u003e\u003e\u003e c = cipher(c, public_key)\n    \u003e\u003e\u003e d = cipher(d, public_key)\n    \u003e\u003e\u003e s = (2 * c) + d\n    \u003e\u003e\u003e int(decrypt(secret_key, s))\n    702\n\nDevelopment\n-----------\nAll installation and development dependencies are fully specified in ``pyproject.toml``. The ``project.optional-dependencies`` object is used to `specify optional requirements \u003chttps://peps.python.org/pep-0621\u003e`__ for various development tasks. This makes it possible to specify additional options (such as ``docs``, ``lint``, and so on) when performing installation using `pip \u003chttps://pypi.org/project/pip\u003e`__:\n\n.. code-block:: bash\n\n    python -m pip install \".[docs,lint]\"\n\nDocumentation\n^^^^^^^^^^^^^\nThe documentation can be generated automatically from the source files using `Sphinx \u003chttps://www.sphinx-doc.org\u003e`__:\n\n.. code-block:: bash\n\n    python -m pip install \".[docs]\"\n    cd docs\n    sphinx-apidoc -f -E --templatedir=_templates -o _source .. \u0026\u0026 make html\n\nTesting and Conventions\n^^^^^^^^^^^^^^^^^^^^^^^\nAll unit tests are executed and their coverage is measured when using `pytest \u003chttps://docs.pytest.org\u003e`__ (see the ``pyproject.toml`` file for configuration details):\n\n.. code-block:: bash\n\n    python -m pip install \".[test]\"\n    python -m pytest\n\nAlternatively, all unit tests are included in the module itself and can be executed using `doctest \u003chttps://docs.python.org/3/library/doctest.html\u003e`__:\n\n.. code-block:: bash\n\n    python src/pailliers/pailliers.py -v\n\nStyle conventions are enforced using `Pylint \u003chttps://pylint.readthedocs.io\u003e`__:\n\n.. code-block:: bash\n\n    python -m pip install \".[lint]\"\n    python -m pylint src/pailliers\n\nContributions\n^^^^^^^^^^^^^\nIn order to contribute to the source code, open an issue or submit a pull request on the `GitHub page \u003chttps://github.com/lapets/pailliers\u003e`__ for this library.\n\nVersioning\n^^^^^^^^^^\nThe version number format for this library and the changes to the library associated with version number increments conform with `Semantic Versioning 2.0.0 \u003chttps://semver.org/#semantic-versioning-200\u003e`__.\n\nPublishing\n^^^^^^^^^^\nThis library can be published as a `package on PyPI \u003chttps://pypi.org/project/pailliers\u003e`__ via the GitHub Actions workflow found in ``.github/workflows/build-publish-sign-release.yml`` that follows the `recommendations found in the Python Packaging User Guide \u003chttps://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/\u003e`__.\n\nEnsure that the correct version number appears in ``pyproject.toml``, and that any links in this README document to the Read the Docs documentation of this package (or its dependencies) have appropriate version numbers. Also ensure that the Read the Docs project for this library has an `automation rule \u003chttps://docs.readthedocs.io/en/stable/automation-rules.html\u003e`__ that activates and sets as the default all tagged versions.\n\nTo publish the package, create and push a tag for the version being published (replacing ``?.?.?`` with the version number):\n\n.. code-block:: bash\n\n    git tag ?.?.?\n    git push origin ?.?.?\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flapets%2Fpailliers","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flapets%2Fpailliers","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flapets%2Fpailliers/lists"}