-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsign-ecdsa.ino
62 lines (46 loc) · 1.03 KB
/
sign-ecdsa.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include <uECC.h>
extern "C" {
static int RNG(uint8_t *dest, unsigned size);
}
extern "C" {
static int RNG(uint8_t *dest, unsigned size) {
while (size) {
uint8_t val = 0;
for (unsigned i = 0; i < 8; ++i) {
int init = analogRead(0);
int count = 0;
while (analogRead(0) == init) {
++count;
}
if (count == 0) {
val = (val << 1) | (init & 0x01);
} else {
val = (val << 1) | (count & 0x01);
}
}
*dest = val;
++dest;
--size;
}
return 1;
}
}
void setup() {
Serial.begin(115200);
uECC_set_rng(&RNG);
const struct uECC_Curve_t * curve = uECC_secp256k1();
uint8_t private2[32];
uint8_t public2[64];
uint8_t signature[256];
unsigned long a = micros();
uECC_sign(private2, private2, 2048, signature, curve);
unsigned long b = micros();
Serial.print("Signed in "); Serial.println(b-a);
int counter = 0;
while (1) {
uECC_sign(private2, private2, 2048, signature, curve);
Serial.println(counter++);
}
}
void loop() {
}