createRangeProof
Creates a "range proof" demonstrating that a secret value (value) lies within a specific minimum (minValue) and maximum (maxValue) range, without revealing the value itself.
For example, this is the cryptographic way of saying, "My device's temperature reading is between 20 and 30 degrees, but I won't tell you the exact value."
Parameters
| Parameter | Type | Description |
|---|---|---|
value | int64_t | The secret value whose range is to be proven. |
minValue | int64_t | The minimum allowed value (inclusive). |
maxValue | int64_t | The maximum allowed value (inclusive). |
secret | const String& | A secret key used to secure the proof. |
outProof | RangeProof& | Output: A RangeProof structure containing the generated proof data. |
Return Value
bool: Returnstrueif the proof was created successfully,falseotherwise.
Example Code (main.cpp)
#include <Arduino.h>
#include "Infratic-lib.h" // Assume RangeProof struct is defined here
// This function does not require network connectivity.
Infratic solana(""); // RPC URL not needed
void setup() {
Serial.begin(115200);
delay(1000);
Serial.println("\n=== createRangeProof Example ===");
int64_t secretValue = 42;
int64_t minRange = 0;
int64_t maxRange = 100;
String mySecret = "rangeProofSecret123";
RangeProof proof; // This struct is defined in Infratic-lib.h
Serial.print("Creating proof that secret value (42) is within [0, 100]...");
if (solana.createRangeProof(secretValue, minRange, maxRange, mySecret, proof)) {
Serial.println("\n✅ Range proof created successfully!");
// The 'proof' object can now be verified using 'verifyRangeProof'.
} else {
Serial.println("\n❌ Failed to create range proof.");
}
}
void loop() {
// Can be left empty
}