Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add resolving of the metadata on device #23

Merged
merged 1 commit into from
Sep 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 0 additions & 19 deletions lib/default/rddl/src/rddl.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,25 +109,6 @@ bool getSeedFromMnemonic( const char* pMnemonic, size_t len, uint8_t* seedbuffer
return true;
}

int validateSignature() {
const ecdsa_curve *curve = &secp256k1;
uint8_t pub_key[33] = {0};
uint8_t hash[32] = {0};
uint8_t computed_sig[64] = {0};

const char pub_key_str[] = "02F8BC8B413BF803EA1DA9BE0FBFF4ED23FEED17A859187242007544F8535D3457";
const char hash_str[] = "83EC230810630863EEB5C873206F45E60D5FB9EA3F5241EEECFB514F261A57DF";
const char sig_str[] = "F551CDF6156FD2A8CC29428B61FDB9F5224928D5A5937E38F36D2D566C11B1DF13CD12E3BA2DAE6A33F091C549A5ADE537A5F07121AA1F4D4286B51260B228DE";


memcpy(pub_key, fromHexString(pub_key_str), 33);
memcpy(hash, fromHexString(hash_str), 32);
memcpy(computed_sig, fromHexString(sig_str), 64);

int verified = ecdsa_verify_digest(curve, pub_key, computed_sig, hash);
return verified;
}

bool getKeyFromSeed( const uint8_t* seed, uint8_t* priv_key, uint8_t* pub_key, const char* curve_name){
// we expect curve name to be ED25519_NAME or SECP256K1_NAME
HDNode node;
Expand Down
3 changes: 0 additions & 3 deletions lib/default/rddl/src/rddl.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ const char* setSeed( char* pMnemonic, size_t len );
const char* getMnemonicFromSeed( const uint8_t* seed, size_t length );
bool getSeedFromMnemonic( const char* pMnemonic, size_t len, uint8_t* seedbuffer );

int validateSignature();

bool getKeyFromSeed( const uint8_t* seed, uint8_t* priv_key, uint8_t* pub_key, const char* curve_name);

bool SignDataHash(const char* data_str, size_t data_length, char* pubkey_out, char* sig_out, char* hash_out);
Expand All @@ -49,7 +47,6 @@ int SignDataHashWithPrivKey(const uint8_t* digest, const uint8_t* priv_key, char

bool verifyDataHash(const char* sig_str, const char* pub_key_str, const char* hash_str);


bool getMachineIDSignature( uint8_t* priv_key, uint8_t* pub_key, uint8_t* signature, uint8_t* hash);

bool getMachineIDSignaturePublicKey( uint8_t* priv_key, uint8_t* pub_key, uint8_t* signature);
Expand Down
1 change: 1 addition & 0 deletions tasmota/include/i18n.h
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@
#define D_CMND_MACHINECID "MachineCID"
#define D_CMND_RESOLVEID "ResolveCID"
#define D_CMND_BALANCE "Balance"
#define D_CMND_MACHINEDATA "MachineData"
#define D_CMND_GETACCOUNTID "GetAccountID"
#define D_CMND_PLANETMINTDENOM "PlanetmintDenom"
#define D_CMND_PLANETMINTCHAINID "PlanetmintChainID"
Expand Down
22 changes: 20 additions & 2 deletions tasmota/tasmota_support/support_command.ino
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const char kTasmotaCommands[] PROGMEM = "|" // No prefix
D_CMND_TIMEDST "|" D_CMND_ALTITUDE "|" D_CMND_LEDPOWER "|" D_CMND_LEDSTATE "|" D_CMND_LEDMASK "|" D_CMND_LEDPWM_ON "|" D_CMND_LEDPWM_OFF "|" D_CMND_LEDPWM_MODE "|"
D_CMND_WIFIPOWER "|" D_CMND_TEMPOFFSET "|" D_CMND_HUMOFFSET "|" D_CMND_SPEEDUNIT "|" D_CMND_GLOBAL_TEMP "|" D_CMND_GLOBAL_HUM"|" D_CMND_GLOBAL_PRESS "|" D_CMND_SWITCHTEXT "|" D_CMND_WIFISCAN "|" D_CMND_WIFITEST "|"
D_CMND_MNEMONIC "|" D_CMND_PUBLICKEYS "|" D_CMND_ACCOUNTID "|" D_CMND_PLANETMINTAPI "|" D_CMND_CHALLENGERESPONSE "|" D_CMND_MACHINECID "|"
D_CMND_BALANCE "|" D_CMND_GETACCOUNTID "|" D_CMND_RESOLVEID "|" D_CMND_PLANETMINTDENOM "|" D_CMND_PLANETMINTCHAINID "|"
D_CMND_BALANCE "|" D_CMND_GETACCOUNTID "|" D_CMND_RESOLVEID "|" D_CMND_PLANETMINTDENOM "|" D_CMND_PLANETMINTCHAINID "|" D_CMND_MACHINEDATA "|"
#ifdef USE_I2C
D_CMND_I2CSCAN "|" D_CMND_I2CDRIVER "|"
#endif
Expand Down Expand Up @@ -82,7 +82,7 @@ void (* const TasmotaCommand[])(void) PROGMEM = {
&CmndTimeDst, &CmndAltitude, &CmndLedPower, &CmndLedState, &CmndLedMask, &CmndLedPwmOn, &CmndLedPwmOff, &CmndLedPwmMode,
&CmndWifiPower,&CmndTempOffset, &CmndHumOffset, &CmndSpeedUnit, &CmndGlobalTemp, &CmndGlobalHum, &CmndGlobalPress, &CmndSwitchText, &CmndWifiScan, &CmndWifiTest,
&CmndMemonic, &CmndPublicKeys, &CmndAccountID, &CmndPlanetmintAPI, &CmndChallengeResponse, &CmdMachineCid, &CmndBalance,
&CmndGetAccountID, &CmdResolveCid, &CmndPlanetmintDenom, &CmndPlanetmintChainID,
&CmndGetAccountID, &CmdResolveCid, &CmndPlanetmintDenom, &CmndPlanetmintChainID, &CmndMachineData,
#ifdef USE_I2C
&CmndI2cScan, &CmndI2cDriver,
#endif
Expand Down Expand Up @@ -915,6 +915,24 @@ void CmndPlanetmintChainID(void) {
ResponseClear();
}

void CmndMachineData(void) {

getPlntmntKeys();
HTTPClientLight http;
String uri = "/planetmint-go/machine/get_machine_by_public_key/";

uri = getPlanetmintAPI() + uri;
uri = uri + getExtPubKeyPlanetmint() ;
http.begin(uri);
http.addHeader("Content-Type", "application/json");

int httpResponseCode = http.GET();
Response_P( "{ \"%s\": \"%s\" }", D_CMND_MACHINEDATA, http.getString().c_str() );

CmndStatusResponse(31);
ResponseClear();
}

void CmndStatus(void)
{
int32_t payload = XdrvMailbox.payload;
Expand Down