Name Date Size #Lines LOC

..--

scripts/H25-Apr-2025-964755

test/H25-Apr-2025-521409

.gitignoreH A D25-Apr-202568 88

LICENSE.txtH A D25-Apr-20251.3 KiB2219

README.mdH A D25-Apr-20255.6 KiB209179

asm_arm.incH A D25-Apr-202573.1 KiB2,4562,217

asm_avr.incH A D25-Apr-2025575.6 KiB22,25221,461

btstack_config_uECC.hH A D25-Apr-2025611 2814

emk_project.pyH A D25-Apr-20254.3 KiB12899

emk_rules.pyH A D25-Apr-202554 42

uECC.cH A D25-Apr-202592.8 KiB2,7862,226

uECC.hH A D25-Apr-202510.4 KiB30677

README.md

1micro-ecc
2==========
3
4A small and fast ECDH and ECDSA implementation for 8-bit, 32-bit, and 64-bit processors.
5
6The old version of micro-ecc can be found in the "old" branch.
7
8Features
9--------
10
11 * Resistant to known side-channel attacks.
12 * Written in C, with optional GCC inline assembly for AVR, ARM and Thumb platforms.
13 * Supports 8, 32, and 64-bit architectures.
14 * Small code size.
15 * No dynamic memory allocation.
16 * Support for 5 standard curves: secp160r1, secp192r1, secp224r1, secp256r1, and secp256k1.
17 * BSD 2-clause license.
18
19Usage Notes
20-----------
21### Point Representation ###
22Compressed points are represented in the standard format as defined in http://www.secg.org/collateral/sec1_final.pdf; uncompressed points are represented in standard format, but without the `0x04` prefix. `uECC_make_key()`, `uECC_shared_secret()`, `uECC_sign()`, and `uECC_verify()` only handle uncompressed points; you can use `uECC_compress()` and `uECC_decompress()` to convert between compressed and uncompressed point representations.
23
24Private keys are represented in the standard format.
25
26### Using the Code ###
27
28I recommend just copying (or symlink) uECC.h, uECC.c, and the appropriate asm\_<arch>\_.inc (if any) into your project. Then just `#include "uECC.h"` to use the micro-ecc functions.
29
30For use with Arduino, you can just create a symlink to the `uECC` directory in your Arduino `libraries` directory. You can then use uECC just like any other Arduino library (uECC should show up in the **Sketch**=>**Import Library** submenu).
31
32See uECC.h for documentation for each function.
33
34### Compilation Notes ###
35
36 * Should compile with any C/C++ compiler that supports stdint.h (this includes Visual Studio 2013).
37 * If you want to change the defaults for `uECC_CURVE` and `uECC_ASM`, you must change them in your Makefile or similar so that uECC.c is compiled with the desired values (ie, compile uECC.c with `-DuECC_CURVE=uECC_secp256r1` or whatever).
38 * When compiling for a Thumb-1 platform with inline assembly enabled (ie, `uECC_ASM` is defined to `uECC_asm_small` or `uECC_asm_fast`), you must use the `-fomit-frame-pointer` GCC option (this is enabled by default when compiling with `-O1` or higher).
39 * When compiling for an ARM/Thumb-2 platform with fast inline assembly enabled (ie, `uECC_ASM` is defined to `uECC_asm_fast`), you must use the `-fomit-frame-pointer` GCC option (this is enabled by default when compiling with `-O1` or higher).
40 * When compiling for AVR with inline assembly enabled, you must have optimizations enabled (compile with `-O1` or higher).
41 * When building for Windows, you will need to link in the `advapi32.lib` system library.
42
43ARM Performance
44---------------
45
46All tests were built using gcc 4.8.2 with `-O3`, and were run on a Raspberry Pi B+. `uECC_ASM` was defined to `uECC_asm_fast` and `ECC_SQUARE_FUNC` was defined to `1` in all cases. All times are in milliseconds.
47
48<table>
49	<tr>
50		<th></th>
51		<th>secp160r1</th>
52		<th>secp192r1</th>
53		<th>secp256r1</th>
54		<th>secp256k1</th>
55	</tr>
56	<tr>
57		<td><em>ECDH:</em></td>
58		<td>2.3</td>
59		<td>2.7</td>
60		<td>7.9</td>
61		<td>6.5</td>
62	</tr>
63	<tr>
64		<td><em>ECDSA sign:</em></td>
65		<td>2.8</td>
66		<td>3.1</td>
67		<td>8.6</td>
68		<td>7.2</td>
69	</tr>
70	<tr>
71		<td><em>ECDSA verify:</em></td>
72		<td>2.7</td>
73		<td>3.2</td>
74		<td>9.2</td>
75		<td>7.0</td>
76	</tr>
77</table>
78
79AVR Performance
80---------------
81
82All tests were built using avr-gcc 4.8.1 with `-Os`, and were run on a 16 MHz ATmega256RFR2. Code size refers to the space used by micro-ecc code and data.
83
84#### ECDH (fast) ####
85
86In these tests, `uECC_ASM` was defined to `uECC_asm_fast` and `ECC_SQUARE_FUNC` was defined to `1` in all cases.
87
88<table>
89	<tr>
90		<th></th>
91		<th>secp160r1</th>
92		<th>secp192r1</th>
93		<th>secp256r1</th>
94		<th>secp256k1</th>
95	</tr>
96	<tr>
97		<td><em>ECDH time (ms):</em></td>
98		<td>470</td>
99		<td>810</td>
100		<td>2220</td>
101		<td>1615</td>
102	</tr>
103	<tr>
104		<td><em>Code size (bytes):</em></td>
105		<td>10768</td>
106		<td>13112</td>
107		<td>20886</td>
108		<td>21126</td>
109	</tr>
110</table>
111
112#### ECDH (small) ####
113
114In these tests, `uECC_ASM` was defined to `uECC_asm_small` and `ECC_SQUARE_FUNC` was defined to `0` in all cases.
115
116<table>
117	<tr>
118		<th></th>
119		<th>secp160r1</th>
120		<th>secp192r1</th>
121		<th>secp256r1</th>
122		<th>secp256k1</th>
123	</tr>
124	<tr>
125		<td><em>ECDH time (ms):</em></td>
126		<td>1250</td>
127		<td>1810</td>
128		<td>4790</td>
129		<td>4700</td>
130	</tr>
131	<tr>
132		<td><em>Code size (bytes):</em></td>
133		<td>3244</td>
134		<td>3400</td>
135		<td>5274</td>
136		<td>3426</td>
137	</tr>
138</table>
139
140#### ECDSA (fast) ####
141
142In these tests, `uECC_ASM` was defined to `uECC_asm_fast` and `ECC_SQUARE_FUNC` was defined to `1` in all cases.
143
144<table>
145	<tr>
146		<th></th>
147		<th>secp160r1</th>
148		<th>secp192r1</th>
149		<th>secp256r1</th>
150		<th>secp256k1</th>
151	</tr>
152	<tr>
153		<td><em>ECDSA sign time (ms):</em></td>
154		<td>555</td>
155		<td>902</td>
156		<td>2386</td>
157		<td>1773</td>
158	</tr>
159	<tr>
160		<td><em>ECDSA verify time (ms):</em></td>
161		<td>590</td>
162		<td>990</td>
163		<td>2650</td>
164		<td>1800</td>
165	</tr>
166	<tr>
167		<td><em>Code size (bytes):</em></td>
168		<td>13246</td>
169		<td>14798</td>
170		<td>22594</td>
171		<td>22826</td>
172	</tr>
173</table>
174
175#### ECDSA (small) ####
176
177In these tests, `uECC_ASM` was defined to `uECC_asm_small` and `ECC_SQUARE_FUNC` was defined to `0` in all cases.
178
179<table>
180	<tr>
181		<th></th>
182		<th>secp160r1</th>
183		<th>secp192r1</th>
184		<th>secp256r1</th>
185		<th>secp256k1</th>
186	</tr>
187	<tr>
188		<td><em>ECDSA sign time (ms):</em></td>
189		<td>1359</td>
190		<td>1931</td>
191		<td>4998</td>
192		<td>4904</td>
193	</tr>
194	<tr>
195		<td><em>ECDSA verify time (ms):</em></td>
196		<td>1515</td>
197		<td>2160</td>
198		<td>5700</td>
199		<td>5220</td>
200	</tr>
201	<tr>
202		<td><em>Code size (bytes):</em></td>
203		<td>5690</td>
204		<td>5054</td>
205		<td>6980</td>
206		<td>5080</td>
207	</tr>
208</table>
209