signMessageFromBase58
Signs a given message (byte vector) using the Ed25519 algorithm with a private key provided in Base58 format. This is used to prove ownership of a wallet (for off-chain authentication) or to sign Solana transactions.
The function first decodes the Base58 key into its raw byte format and then performs the signing operation.
Parameters
| Parameter | Type | Description |
|---|---|---|
message | const std::vector<uint8_t>& | The byte vector containing the data to be signed. |
privateKeyBase58 | const String& | The 64-byte private key, encoded as a Base58 string. |
outSignature | uint8_t[64] | An output parameter. This is a byte array where the resulting 64-byte signature will be stored. |
Return Value
bool: Returnstrueif signing was successful,falseif the private key format is invalid.
Example Code (main.cpp)
#include <Arduino.h>
#include "Infratic-lib.h"
// --- Settings ---
const String SOLANA_RPC_URL = "[https://api.devnet.solana.com](https://api.devnet.solana.com)";
const String MY_PRIVATE_KEY_BASE58 = "YOUR_PRIVATE_KEY_BASE58";
Infratic solana(SOLANA_RPC_URL);
void setup() {
Serial.begin(115200);
delay(1000);
Serial.println("\n=== Sign Message (from Base58) Example ===");
// Message to be signed
std::string message_str = "This message was signed by Infratic.";
std::vector<uint8_t> message(message_str.begin(), message_str.end());
uint8_t signature[64]; // 64-byte buffer for the signature
if (solana.signMessageFromBase58(message, MY_PRIVATE_KEY_BASE58, signature)) {
Serial.println("✅ Message signed successfully!");
Serial.print(" -> Signature (hex): ");
for (int i = 0; i < 64; i++) {
if (signature[i] < 16) Serial.print("0");
Serial.print(signature[i], HEX);
}
Serial.println();
} else {
Serial.println("❌ Failed to sign message. Check the private key format.");
}
}
void loop() {
// Can be left empty
}