Skip to main content

verifyTimestampedProof

Verifies a timestamped proof created by createTimestampedProof.

This function recalculates the proof hash using the provided data and timestamp and checks if it matches the original proof. The blockhash serves as an external anchor (which should ideally be verified against a block explorer) to confirm the overall validity in time.

Parameters

ParameterTypeDescription
dataconst String&The original data to verify.
proofconst String&The original proof hash.
timestampuint64_tThe original timestamp.
blockhashconst String&The original Solana blockhash anchor.

Return Value

  • bool: Returns true if the recalculated hash matches the provided proof.

Example Code (main.cpp)

#include <Arduino.h>
#include "Infratic-lib.h"

// This function does not require network connectivity.
Infratic solana(""); // RPC URL not needed

void setup() {
Serial.begin(115200);
delay(1000);

Serial.println("\n=== verifyTimestampedProof Example ===");

// Assume these values were obtained from a previous call to 'createTimestampedProof'
String originalData = "This document was created on 10/10/2025.";
String originalProof = "c1a2b3d4e5f6... (hash) ...c1a2b3d4e5f6";
uint64_t originalTimestamp = 1760000000;
String originalBlockhash = "9a8b7c6d... (blockhash) ...9a8b7c6d";

Serial.println("Test 1: Verifying with original data...");
if (solana.verifyTimestampedProof(originalData, originalProof, originalTimestamp, originalBlockhash)) {
Serial.println("✅ SUCCESS: Proof matches data and timestamp!");
} else {
Serial.println("❌ ERROR: Proof does not match.");
}

Serial.println("\nTest 2: Verifying with tampered data...");
String tamperedData = "This document was created on 11/10/2025.";
if (solana.verifyTimestampedProof(tamperedData, originalProof, originalTimestamp, originalBlockhash)) {
Serial.println("❌ ERROR: Tampered data should not have verified!");
} else {
Serial.println("✅ SUCCESS: Tampered data was correctly rejected.");
}
}

void loop() {
// Can be left empty
}