Skip to content

Commit

Permalink
edwards instead of twisted edwards
Browse files Browse the repository at this point in the history
  • Loading branch information
serengil committed Jan 1, 2025
1 parent 2d42c32 commit dff2365
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

<p align="center"><img src="https://raw.githubusercontent.com/serengil/LightPHE/master/icons/phi.png" width="200" height="240"></p>

LightPHE is a lightweight partially homomorphic encryption library for python. It is a hybrid homomoprhic encryption library wrapping many schemes such as [`RSA`](https://sefiks.com/2023/03/06/a-step-by-step-partially-homomorphic-encryption-example-with-rsa-in-python/), [`ElGamal`](https://sefiks.com/2023/03/27/a-step-by-step-partially-homomorphic-encryption-example-with-elgamal-in-python/), [`Exponential ElGamal`](https://sefiks.com/2023/03/27/a-step-by-step-partially-homomorphic-encryption-example-with-elgamal-in-python/), [`Elliptic Curve ElGamal`](https://sefiks.com/2018/08/21/elliptic-curve-elgamal-encryption/), [`Paillier`](https://sefiks.com/2023/04/03/a-step-by-step-partially-homomorphic-encryption-example-with-paillier-in-python/), [`Damgard-Jurik`](https://sefiks.com/2023/10/20/a-step-by-step-partially-homomorphic-encryption-example-with-damgard-jurik-in-python/), [`Okamoto–Uchiyama`](https://sefiks.com/2023/10/20/a-step-by-step-partially-homomorphic-encryption-example-with-okamoto-uchiyama-in-python/), [`Benaloh`](https://sefiks.com/2023/10/06/a-step-by-step-partially-homomorphic-encryption-example-with-benaloh-in-python-from-scratch/), [`Naccache–Stern`](https://sefiks.com/2023/10/26/a-step-by-step-partially-homomorphic-encryption-example-with-naccache-stern-in-python/), [`Goldwasser–Micali`](https://sefiks.com/2023/10/27/a-step-by-step-partially-homomorphic-encryption-example-with-goldwasser-micali-in-python/).
LightPHE is a lightweight partially homomorphic encryption library for python. It is a hybrid homomoprhic encryption library wrapping many schemes such as [`RSA`](https://sefiks.com/2023/03/06/a-step-by-step-partially-homomorphic-encryption-example-with-rsa-in-python/), [`ElGamal`](https://sefiks.com/2023/03/27/a-step-by-step-partially-homomorphic-encryption-example-with-elgamal-in-python/), [`Exponential ElGamal`](https://sefiks.com/2023/03/27/a-step-by-step-partially-homomorphic-encryption-example-with-elgamal-in-python/), [`Elliptic Curve ElGamal`](https://sefiks.com/2018/08/21/elliptic-curve-elgamal-encryption/) ([`Weierstrass`](https://sefiks.com/2016/03/13/the-math-behind-elliptic-curve-cryptography/), [`Koblitz`](https://sefiks.com/2016/03/13/the-math-behind-elliptic-curves-over-binary-field/) and [`Edwards`](https://sefiks.com/2018/12/19/a-gentle-introduction-to-edwards-curves/) forms) [`Paillier`](https://sefiks.com/2023/04/03/a-step-by-step-partially-homomorphic-encryption-example-with-paillier-in-python/), [`Damgard-Jurik`](https://sefiks.com/2023/10/20/a-step-by-step-partially-homomorphic-encryption-example-with-damgard-jurik-in-python/), [`Okamoto–Uchiyama`](https://sefiks.com/2023/10/20/a-step-by-step-partially-homomorphic-encryption-example-with-okamoto-uchiyama-in-python/), [`Benaloh`](https://sefiks.com/2023/10/06/a-step-by-step-partially-homomorphic-encryption-example-with-benaloh-in-python-from-scratch/), [`Naccache–Stern`](https://sefiks.com/2023/10/26/a-step-by-step-partially-homomorphic-encryption-example-with-naccache-stern-in-python/), [`Goldwasser–Micali`](https://sefiks.com/2023/10/27/a-step-by-step-partially-homomorphic-encryption-example-with-goldwasser-micali-in-python/).

# Partially vs Fully Homomorphic Encryption

Expand Down
4 changes: 2 additions & 2 deletions lightphe/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def __init__(
key_size (int): key size in bits
precision (int): precision for homomorphic operations on tensors
form (str): specifies the form of the elliptic curve.
Options: 'weierstrass' (default), 'edwards', 'twisted-edwards', 'koblitz'.
Options: 'weierstrass' (default), 'edwards', 'koblitz'.
This parameter is only used if `algorithm_name` is 'EllipticCurve-ElGamal'.
"""
self.algorithm_name = algorithm_name
Expand Down Expand Up @@ -83,7 +83,7 @@ def __build_cryptosystem(
key_file (str): if keys are exported, you can load them into cryptosystem
key_size (int): key size in bits
form (str): specifies the form of the elliptic curve.
Options: 'weierstrass' (default), 'edwards', 'twisted-edwards', 'koblitz'.
Options: 'weierstrass' (default), 'edwards', 'koblitz'.
This parameter is only used if `algorithm_name` is 'EllipticCurve-ElGamal'.
Returns
cryptosystem
Expand Down
4 changes: 2 additions & 2 deletions lightphe/cryptosystems/EllipticCurveElGamal.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ def __init__(self, keys: Optional[dict] = None, key_size: Optional[int] = None,
key_size (int): key size in bits. default is 160.
this is equivalent to 1024 bit RSA.
form (str): specifies the elliptic curve form.
Options are 'weierstrass' (default), 'koblitz', 'edwards', 'twisted-edwards'.
Options are 'weierstrass' (default), 'koblitz', 'edwards'.
"""
if form is None or form == "weierstrass":
self.curve = Weierstrass()
elif form == "twisted-edwards":
elif form in "edwards":
self.curve = TwistedEdwards()
else:
raise ValueError(f"unimplemented curve form - {form}")
Expand Down
6 changes: 4 additions & 2 deletions lightphe/elliptic_curve_forms/edwards.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@

class TwistedEdwards(EllipticCurve):
"""
Builds twisted edwards curves
Ref: https://sefiks.com/2018/12/26/twisted-edwards-curves/
Builds (twisted) edwards curves
Refs:
[1] https://sefiks.com/2018/12/19/a-gentle-introduction-to-edwards-curves/
[2] https://sefiks.com/2018/12/26/twisted-edwards-curves/
"""
def __init__(self, curve="ed25519"):

Expand Down
2 changes: 1 addition & 1 deletion tests/test_ellipticcurveelgamal.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

logger = Logger(module="tests/test_ellipticcurveelgamal.py")

FORMS = ["weierstrass", "twisted-edwards"]
FORMS = ["weierstrass", "edwards"]


def test_elliptic_curve_elgamal():
Expand Down

0 comments on commit dff2365

Please sign in to comment.