GithubHelp home page GithubHelp logo

lc6chang / ecc-pycrypto Goto Github PK

View Code? Open in Web Editor NEW
35.0 35.0 13.0 68 KB

A Python package for ECC and ElGamal elliptic curve encryption.

License: MIT License

Python 100.00%
elgamal elliptic-curve-cryptography elliptic-curves

ecc-pycrypto's Issues

Additive Homomorphism for ElGamal

I have tried to check if this implementation can be used for Additive homomorphism available in ElGamal.

For example, to achieve sometime like this this
ADD(X,Y) = Enc(plain_text_1+plain_text_2)

where

X=(C1, C2)
Y=(C3, C4)
pri_key, pub_key = gen_keypair(Curve25519)
cipher_elg = ElGamal(Curve25519)
plain_text_1 = bytes([3])
plain_text_2 = bytes([4])
X=C1, C2 = cipher_elg.encrypt(plain_text_1, pub_key)
Y=C3, C4 = cipher_elg.encrypt(plain_text_2, pub_key)
C5 = Curve25519.add_point(C1,C3)
C6 = Curve25519.add_point(C2,C4)
result = cipher_elg.decrypt(pri_key, C5, C6)

Then the output is expected to be 7.

Seems cipher_elg.decrypt(pri_key, C5, C6) will not work.
Maybe it can be done as future improvements.

Please publish a package on pypi

I'm using your (awesome) library and I'd like to include it in a project. It would be so much easier if I could just pip install it.

Thank you!

'modular inverse does not exist' when doubling a point on the x axis

When doubling a point on x axis (i.e. y=0), the expected result is the Point at infinity but now it raises 'modular inverse does not exist' exception.

>>> from ecc.curve import Curve25519
>>> from ecc.curve import Point
>>> P = Point(x=0, y=0, curve=Curve25519)
>>> P + P
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/chang/ecc-pycrypto/ecc/curve.py", line 40, in __add__
    return self.curve.add_point(self, other)
  File "/Users/chang/ecc-pycrypto/ecc/curve.py", line 104, in add_point
    return self._double_point(P)
  File "/Users/chang/ecc-pycrypto/ecc/curve.py", line 255, in _double_point
    s = up * modinv(down, self.p)
  File "/Users/chang/ecc-pycrypto/ecc/math_utils/mod_inverse.py", line 16, in modinv
    raise Exception("modular inverse does not exist")
Exception: modular inverse does not exist

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.