/
sign_anything.ino
58 lines (43 loc) · 1.49 KB
/
sign_anything.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
#include <Arduino.h>
#include <ESP8266WiFiMulti.h>
#include <byteduino.h>
#if defined (ESP32)
#include <WiFiMulti.h>
WiFiMulti WiFiMulti;
#endif
#if defined (ESP8266)
#include <ESP8266WiFiMulti.h>
ESP8266WiFiMulti WiFiMulti;
#endif
void onSignatureRequest(const char signedTxt[], const char* JsonDigest) {
Serial.println("Going to sign: ");
Serial.println(JsonDigest);
if (!confirmSignature(signedTxt)) {
Serial.println(F("Couldn't confirm this signature"));
};
//mind that parameters will be deleted after function ends, if you need to copy them then do it by value
}
void setup() {
setDeviceName("Byteduino");
setHub("obyte.org/bb");
//don't forget to change the keys below, you will get troubles if more than 1 device is connected using the same keys
setPrivateKeyM1("lgVGw/OfKKK4NqtK9fmJjbLCkLv7BGLetrdvsKAngWY=");
setExtPubKey("xpub6Chxqf8hRQoLRJFS8mhFCDv5yzUNC7rhhh36qqqt1WtAZcmCNhS5pPndqhx8RmgwFhGPa9FYq3iTXNBkYdkrAKJxa7qnahnAvCzKW5dnfJn");
setPrivateKeyM4400("qA1CxKyzvpKX9+IRhLH8OjLYY06H3RLl+zqc3lT86aI=");
setCbSignatureToConfirm(&onSignatureRequest);
Serial.begin(115200);
while (!Serial)
continue;
//we don't need an access point
WiFi.softAPdisconnect(true);
//set your wifi credentials here
WiFiMulti.addAP("you_wifi_SSID", "your_wifi_password");
while (WiFiMulti.run() != WL_CONNECTED) {
delay(100);
Serial.println(F("Not connected to wifi yet"));
}
}
void loop() {
// put your main code here, to run repeatedly:
byteduino_loop();
}