Skip to content

Commit

Permalink
Add purpose section to README; update package descriptions and docstr…
Browse files Browse the repository at this point in the history
…ings.
  • Loading branch information
lapets committed Nov 22, 2023
1 parent 9c27325 commit 2a689e3
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
6 changes: 5 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
sophiegermain
=============

Pure-Python library that provides a selection of `Sophie Germain primes <https://en.wikipedia.org/wiki/Safe_and_Sophie_Germain_primes>`__.
Pure-Python library that provides a selection of `Sophie Germain primes <https://en.wikipedia.org/wiki/Safe_and_Sophie_Germain_primes>`__ that are organized by representation size.

|pypi| |readthedocs| |actions| |coveralls|

Expand All @@ -22,6 +22,10 @@ Pure-Python library that provides a selection of `Sophie Germain primes <https:/
:target: https://coveralls.io/github/nillion-oss/sophiegermain?branch=main
:alt: Coveralls test coverage summary.

Purpose
-------
Some cryptographic protocols involve the use of `Sophie Germain and safe primes <https://en.wikipedia.org/wiki/Safe_and_Sophie_Germain_primes>`__. In such cases, it is often useful to choose a Sophie Germain or safe prime based on the range of values (*i.e.*, `congruence classes of integers <https://en.wikipedia.org/wiki/Modular_arithmetic>`__ or `finite field <https://en.wikipedia.org/wiki/Finite_field>`__ elements) that an instantiation of a protocol must accommodate. This library provides immediate access to the smallest Sophie Germain prime for each possible binary representation length (up to and including 1025 bits).

Installation and Usage
----------------------
This library is available as a `package on PyPI <https://pypi.org/project/sophiegermain>`__:
Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
name = "sophiegermain"
version = "0.1.0"
description = """\
Pure-Python library that provides a selection of Sophie Germain primes.
Pure-Python library that provides a selection of Sophie Germain primes
that are organized by representation size.
"""
license = {text = "MIT"}
authors = [
Expand Down
12 changes: 7 additions & 5 deletions src/sophiegermain/sophiegermain.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""
Pure-Python library that provides a selection of Sophie Germain primes.
Pure-Python library that provides a selection of Sophie Germain primes
that are organized by representation size.
"""
# pylint: disable=too-many-lines
from __future__ import annotations
Expand Down Expand Up @@ -1036,8 +1037,9 @@

def sophiegermain(bit_length: int) -> int:
"""
Return the smallest Sophie Germain prime that can be represented using
the specified number of bits.
Return the smallest
`Sophie Germain prime <https://en.wikipedia.org/wiki/Safe_and_Sophie_Germain_primes>`__
the representation of which requires the specified number of bits.
>>> sophiegermain(2)
2
Expand All @@ -1052,8 +1054,8 @@ def sophiegermain(bit_length: int) -> int:
>>> sophiegermain(1025).bit_length()
1025
The result returned by :obj:`sophiegermain` can always be represented
using the specified number of bits.
The result returned by :obj:`sophiegermain` can be represented using the
specified number of bits.
>>> all([sophiegermain(k).bit_length() == k for k in range(2, 1026)])
True
Expand Down

0 comments on commit 2a689e3

Please sign in to comment.