elliptic-shiho / ecpy Goto Github PK
View Code? Open in Web Editor NEWA pairing library of elliptic curve
License: MIT License
A pairing library of elliptic curve
License: MIT License
from ecpy import *
F, E, G, n = EllipticCurveRepository('secp224k1')
print G * n
Sun Mar 26 21:27:57 JST 2017 ~/prog/lab/mathematics/ecpy/scripts 93%
> python issue_3.py
Point (2662552069424839940829238116501617128533613759701004695707473099760 : 15996838278203546540884017352821306960302774013401163842202920884487 : 1) on Elliptic Curve y^2 = x^3 + 5 over FiniteField(26959946667150639794667015087019630673637144422540572481099315275117)
must be n * G == Inifinity
Reference: http://www.secg.org/sec2-v2.pdf
Parameter
In the file "https://github.com/elliptic-shiho/ecpy/blob/master/examples/boneh_lynn_shacham_short_signature.py", I would like to know why you have all those parameters please?
In your "https://github.com/elliptic-shiho/ecpy/blob/master/ecpy/elliptic_curve/EllipticCurveRepository.py" nor https://safecurves.cr.yp.to has that specific number (p, l, etc.). I even did not found them on Google.
MapToPoint
I tried to replace all those parameter with yours (for example: (F, E, G, n) = EllipticCurveRepository("secp521r1")).
In addition, I tried to replace FiniteField with ExtendedFiniteField + both possible functions.
None of those works with MapToPoint.
Case FiniteField:
MapToPoint(E, E.field(12313))
Traceback (most recent call last):
File "", line 1, in
File "/usr/local/lib/python2.7/site-packages/ecpy/elliptic_curve/pairing.py", line 116, in MapToPoint
x = cubic_root(y**2 - 1)
File "/usr/local/lib/python2.7/site-packages/ecpy/utils/root.py", line 183, in cubic_root
rho = F(random.randint(1, p - 1), random.randint(1, p - 1))
File "/usr/local/lib/python2.7/site-packages/ecpy/rings/Ring.py", line 12, in call
return s.element_class(s, *x)
TypeError: init() takes exactly 3 arguments (4 given)
Case ExtendedFiniteField:
MapToPoint(E, E.field(hash_ID))
Traceback (most recent call last):
File "", line 1, in
File "/usr/local/lib/python3.7/site-packages/ecpy/elliptic_curve/pairing.py", line 117, in MapToPoint
Q = E(x, y)
File "/usr/local/lib/python3.7/site-packages/ecpy/elliptic_curve/EllipticCurve.py", line 78, in call
return s.element_class(s, *x)
File "/usr/local/lib/python3.7/site-packages/ecpy/elliptic_curve/EllipticCurve.py", line 354, in init
raise ArithmeticError("Invalid Point: (%s, %s, %s)" % (s.x, s.y, s.z))
ArithmeticError: Invalid Point: (mpz(37625453826780433377388048957201879362379477227012885069949001701454994121997751017162539005563127226988793675695228), mpz(12847647103851729428361901244548237337583883889892318731641379765076369134081500062657316972842886439414859445286270), 1)
Hi there,
Trying to get a random point on the elliptic curve raises an OverflowError
in fields/FractionField
for a 1536 bit p
.
At lines 17-18 division must be done with //
resulting in an int
, that fixes the problem in my case.
I am using python 3.8 and reading your comment here #11 (comment) I guess ecpy
was designed for python 2 at start but should work with python 3 too.
p = int(1641994227143377578153959399792871920054683918885673627721570851196750119415869674552942116832787561034894051277808905393148828520318225610178038512107187213731502506665338175685440485362224276062335386653431331251385091624504002080671595682282775620734083404790580129809073016308980466457936622480862655461693371423143228641053476783371900991044809670840439812478238543038118782100267663731306103046856471371034228707099062234903458075497898386216130191035140731)
F = FiniteField(p)
E = EllipticCurve(F, 0, 1)
P_pr = E.random_point()
Hope it helps.
Is it possible to make compatible with python3?
I keep running into errors due to the hashing and message printing.
F_2
, F_{2^k}
fields
F_3
, F_{3^k}
fields
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.