Elliptic-Curve Cryptography Library (Implemented by Python)
- Calculation between elliptic curve points
- Elliptic curve:
y^2 = x^3 + ax + b
over FieldK
(char(K) != 2, 3
). - You can choose K from below:
- Complex Field, Rational Field, FiniteField and Extended Finite Field(Irreducible polynomial:
x^2 + 1
orx^2 + x + 1
)
- Complex Field, Rational Field, FiniteField and Extended Finite Field(Irreducible polynomial:
- Elliptic curve:
- Weil/Tate Pairing
- Distortion Map, symmetric-pairing functions
- SSSA-Attack Implementation
- Sample (CTF Challenge Writeup)
- Example Applications
example/id_based_encryption.py
: Implementation of Boneh-Franklin's Identity-based Encryption Schemeexample/boneh_lynn_shacham_short_signature.py
: Implementation of Boneh-Lynn-Shacham's Short Signature Schemeexample/ecdsa.py
: Implementation of ECDSA Signature Scheme
> git clone https://github.com/elliptic-shiho/ecpy && cd ecpy
> pip install --upgrade .
- six
If installed following modules, ecpy
uses that.
gmpy2
primefac
or primefac-fork
ecpy
has a native module. If you want to speed-up ecpy, you can use that.
> cd ecpy/cpp
> make
> sudo make install
The description is here: cpp/README.md
See bench_pairing.py
.
Sat Jan 28 03:55:47 JST 2017 ~/prog/lab/mathematics/ecpy 100%
> time python scripts/bench_pairing.py
[+] found gmpy! use gmpy.is_prime
[+] Found native module!
Point (25 : 5635866983L + 11271733966Lw : 1) on Elliptic Curve y^2 = x^3 + 1 over ExtendedFiniteField(13208557577, "x^2+x+1")
[+] Weil Pairing:
weil: 14744.50 usec/pass
weil: 14842.80 usec/pass
weil: 14626.05 usec/pass
weil: 14773.50 usec/pass
weil: 14582.25 usec/pass
weil: 14560.95 usec/pass
weil: 14622.40 usec/pass
weil: 15073.19 usec/pass
weil: 14874.60 usec/pass
weil: 14695.20 usec/pass
[+] Tate Pairing:
tate: 3079.89 usec/pass
tate: 3083.21 usec/pass
tate: 3079.10 usec/pass
tate: 3072.70 usec/pass
tate: 3069.81 usec/pass
tate: 3089.30 usec/pass
tate: 3077.90 usec/pass
tate: 3116.00 usec/pass
tate: 3095.35 usec/pass
tate: 3193.65 usec/pass
================================================================
weil: 14739.54 usec/pass
tate: 3095.69 usec/pass
real 0m4.293s
user 0m4.256s
sys 0m0.012s
Cybozu Labs Youth (5th, 6th) - http://labs.cybozu.co.jp/youth.html
This software released under MIT License. Please see /LICENSE.