@@ -32,12 +32,38 @@ curves over prime fields.
32
32
33
33
This library uses only Python and the 'six' package. It is compatible with
34
34
Python 2.6, 2.7 and 3.3+. It also supports execution on the alternative
35
- implementations like pypy and pypy3
35
+ implementations like pypy and pypy3.
36
+
37
+ If ` gmpy2 ` or ` gmpy ` is installed, they will be used for faster arithmetic.
38
+ Either of them can be installed after this library is installed,
39
+ ` python-ecdsa ` will detect their presence on start-up and use them
40
+ automatically.
36
41
37
42
To run the OpenSSL compatibility tests, the 'openssl' tool must be in your
38
43
` PATH ` . This release has been tested successfully against OpenSSL 0.9.8o,
39
44
1.0.0a, 1.0.2f and 1.1.1d (among others).
40
45
46
+
47
+ ## Installation
48
+
49
+ This library is available on PyPI, it's recommended to install it using ` pip ` :
50
+
51
+ ```
52
+ pip install ecdsa
53
+ ```
54
+
55
+ In case higher performance is wanted and using native code is not a problem,
56
+ it's possible to specify installation together with ` gmpy2 ` :
57
+
58
+ ```
59
+ pip install ecdsa[gmpy2]
60
+ ```
61
+
62
+ or (slower, legacy option):
63
+ ```
64
+ pip install ecdsa[gmpy]
65
+ ```
66
+
41
67
## Speed
42
68
43
69
The following table shows how long this library takes to generate keypairs
@@ -53,31 +79,55 @@ On an Intel Core i7 4790K @ 4.0GHz I'm getting the following performance:
53
79
54
80
```
55
81
siglen keygen keygen/s sign sign/s verify verify/s
56
- NIST192p: 48 0.01534s 65.18 0.00833s 120.05 0.01601s 62.48
57
- NIST224p: 56 0.02107s 47.46 0.01153s 86.74 0.02220s 45.05
58
- NIST256p: 64 0.02824s 35.40 0.01523s 65.66 0.02965s 33.73
59
- NIST384p: 96 0.06640s 15.06 0.03572s 27.99 0.06973s 14.34
60
- NIST521p: 132 0.13150s 7.60 0.07094s 14.10 0.13869s 7.21
61
- SECP256k1: 64 0.02807s 35.63 0.01525s 65.58 0.02964s 33.74
62
- BRAINPOOLP160r1: 40 0.01100s 90.88 0.00564s 177.45 0.01053s 94.92
63
- BRAINPOOLP192r1: 48 0.01633s 61.25 0.00833s 120.05 0.01591s 62.84
64
- BRAINPOOLP224r1: 56 0.02261s 44.23 0.01153s 86.76 0.02234s 44.77
65
- BRAINPOOLP256r1: 64 0.02997s 33.36 0.01532s 65.29 0.03084s 32.42
66
- BRAINPOOLP320r1: 80 0.04774s 20.95 0.02447s 40.86 0.04717s 21.20
67
- BRAINPOOLP384r1: 96 0.07007s 14.27 0.03566s 28.04 0.07056s 14.17
68
- BRAINPOOLP512r1: 128 0.13390s 7.47 0.06766s 14.78 0.13425s 7.45
82
+ NIST192p: 48 0.00033s 3062.43 0.00036s 2748.08 0.00062s 1605.66
83
+ NIST224p: 56 0.00041s 2424.07 0.00046s 2196.71 0.00083s 1205.81
84
+ NIST256p: 64 0.00053s 1892.05 0.00058s 1735.23 0.00106s 944.82
85
+ NIST384p: 96 0.00110s 904.98 0.00118s 847.82 0.00217s 460.26
86
+ NIST521p: 132 0.00234s 428.24 0.00245s 408.54 0.00443s 225.95
87
+ SECP256k1: 64 0.00053s 1891.93 0.00058s 1734.46 0.00109s 913.35
88
+ BRAINPOOLP160r1: 40 0.00025s 3982.49 0.00029s 3490.15 0.00053s 1878.51
89
+ BRAINPOOLP192r1: 48 0.00032s 3086.07 0.00036s 2761.68 0.00063s 1578.22
90
+ BRAINPOOLP224r1: 56 0.00041s 2412.41 0.00046s 2185.52 0.00076s 1311.65
91
+ BRAINPOOLP256r1: 64 0.00054s 1866.84 0.00058s 1719.45 0.00110s 906.85
92
+ BRAINPOOLP320r1: 80 0.00077s 1306.97 0.00083s 1201.59 0.00158s 632.82
93
+ BRAINPOOLP384r1: 96 0.00112s 892.44 0.00119s 841.48 0.00229s 436.71
94
+ BRAINPOOLP512r1: 128 0.00214s 467.05 0.00226s 441.64 0.00422s 237.13
69
95
```
96
+ To test performance with ` gmpy2 ` loaded, use ` tox -e speedgmpy2 ` .
97
+ On the same machine I'm getting the following performance with ` gmpy2 ` :
98
+ ```
99
+ siglen keygen keygen/s sign sign/s verify verify/s
100
+ NIST192p: 48 0.00016s 6180.12 0.00017s 5846.30 0.00033s 3029.51
101
+ NIST224p: 56 0.00021s 4861.86 0.00021s 4662.63 0.00042s 2366.47
102
+ NIST256p: 64 0.00023s 4343.93 0.00024s 4152.79 0.00047s 2148.83
103
+ NIST384p: 96 0.00040s 2507.97 0.00041s 2435.99 0.00079s 1260.01
104
+ NIST521p: 132 0.00088s 1135.13 0.00089s 1121.94 0.00139s 721.07
105
+ SECP256k1: 64 0.00023s 4360.83 0.00024s 4147.61 0.00044s 2254.53
106
+ BRAINPOOLP160r1: 40 0.00014s 7261.37 0.00015s 6824.47 0.00031s 3248.21
107
+ BRAINPOOLP192r1: 48 0.00016s 6219.18 0.00017s 5862.93 0.00034s 2933.74
108
+ BRAINPOOLP224r1: 56 0.00021s 4876.48 0.00022s 4640.40 0.00041s 2413.48
109
+ BRAINPOOLP256r1: 64 0.00023s 4397.89 0.00024s 4178.48 0.00044s 2272.76
110
+ BRAINPOOLP320r1: 80 0.00031s 3246.64 0.00032s 3138.38 0.00063s 1593.14
111
+ BRAINPOOLP384r1: 96 0.00040s 2491.04 0.00041s 2421.67 0.00079s 1262.64
112
+ BRAINPOOLP512r1: 128 0.00062s 1618.30 0.00063s 1577.42 0.00125s 799.29
113
+ ```
114
+
115
+ (there's also ` gmpy ` version, execute it using ` tox -e speedgmpy ` )
70
116
71
117
For comparison, a highly optimised implementation (including curve-specific
72
- assemply) like OpenSSL provides following performance numbers on the same
73
- machine. Run ` openssl speed ` to reproduce it:
118
+ assembly for some curves), like the one in OpenSSL, provides following
119
+ performance numbers on the same machine.
120
+ Run ` openssl speed ecdsa ` to reproduce it:
74
121
```
75
122
sign verify sign/s verify/s
76
123
192 bits ecdsa (nistp192) 0.0002s 0.0002s 4785.6 5380.7
77
124
224 bits ecdsa (nistp224) 0.0000s 0.0001s 22475.6 9822.0
78
125
256 bits ecdsa (nistp256) 0.0000s 0.0001s 45069.6 14166.6
79
126
384 bits ecdsa (nistp384) 0.0008s 0.0006s 1265.6 1648.1
80
127
521 bits ecdsa (nistp521) 0.0003s 0.0005s 3753.1 1819.5
128
+ 256 bits ecdsa (brainpoolP256r1) 0.0003s 0.0003s 2983.5 3333.2
129
+ 384 bits ecdsa (brainpoolP384r1) 0.0008s 0.0007s 1258.8 1528.1
130
+ 512 bits ecdsa (brainpoolP512r1) 0.0015s 0.0012s 675.1 860.1
81
131
```
82
132
83
133
Keys and signature can be serialized in different ways (see Usage, below).
@@ -94,7 +144,9 @@ following lengths (in bytes):
94
144
In 2006, Peter Pearson announced his pure-python implementation of ECDSA in a
95
145
[ message to sci.crypt] [ 1 ] , available from his [ download site] [ 2 ] . In 2010,
96
146
Brian Warner wrote a wrapper around this code, to make it a bit easier and
97
- safer to use. You are looking at the README for this wrapper.
147
+ safer to use. Hubert Kario then included an implementation of elliptic curve
148
+ cryptography that uses Jacobian coordinates internally, improving performance
149
+ about 20-fold. You are looking at the README for this wrapper.
98
150
99
151
[ 1 ] : http://www.derkeiler.com/Newsgroups/sci.crypt/2006-01/msg00651.html
100
152
[ 2 ] : http://webpages.charter.net/curryfans/peter/downloads.html
@@ -105,7 +157,7 @@ To run the full test suite, do this:
105
157
106
158
tox -e coverage
107
159
108
- On an Intel Core i7 4790K @ 4.0GHz, the tests take about 150 seconds to execute.
160
+ On an Intel Core i7 4790K @ 4.0GHz, the tests take about 16 seconds to execute.
109
161
The test suite uses
110
162
[ ` hypothesis ` ] ( https://github.com/HypothesisWorks/hypothesis ) so there is some
111
163
inherent variability in the test suite execution time.
0 commit comments