Zero-Trust IoT Swarms Secured by TinyML, Cryptography, and Web3 Staking.
🌐 Live Dashboard Demo: Launch Sensensus Mission Control
In industries spanning supply chain logistics, high-value asset insurance, and remote equipment monitoring, IoT data is traditionally treated as the absolute ground truth. However, hardware sensors represent a massive vulnerability in both traditional systems and modern Web3 architectures. This is known as the "Oracle Problem."
Spoofing an IoT sensor is trivial. If a bad actor physically compromises a single sensor, alters its calibration, or injects fake network packets into the data stream, they can trigger fraudulent insurance claims, hide equipment damage, or disrupt global logistics. Traditional centralized networks blindly trust the data source, creating a massive single point of failure that cannot be solved by software alone.
Sensensus is a zero-trust cyber-physical system built to eliminate blind trust in edge devices. We solve the Oracle Problem by mathematically decoupling physical event detection from event verification. When an IoT node detects an anomaly, it cannot simply declare it as fact—it must prove the claim to a decentralized, staked swarm of peer verifier nodes.
If a node is caught lying, deviating, or hallucinating data, the smart contract:
- Automatically slashes its funds
- Permanently damages its on-chain reputation
This creates a cryptoeconomic truth layer for physical sensor events.
- Zero-Trust Hardware: Raw sensor data is locally inferred using a 1D Convolutional Neural Network before ever touching the internet.
- Cryptographic Sybil Resistance: Every node signs its data beacons using ECDSA (secp256r1) elliptic curves to prevent node spoofing and man-in-the-middle attacks.
- HTTP x402 Data Tolls: A unique implementation of the
402 Payment Requiredprotocol to prevent network spam and monetize hardware data buffering. - Immutable Settlement: Flow blockchain smart contracts handle all consensus logic, economic slashing, and ledger settlements autonomously.
- Code Status: Protocol Labs — Fresh Code (built entirely during the hackathon)
- Swarm coordination frameworks
- Verifiable AI
- x402 agent-to-agent machine payment tolls
- DePIN sensor network
- Novel economic slashing and governance
- Contributor rewards for environmental or infrastructure data
- Zero-trust verification for biometric and neurological edge sensors
- Prevention of spoofed human-computer interface inputs
- Swarm decision tools for real-time distributed consensus
- Securing the physical data layer for a decentralized internet
- Flow: Core consensus logic, escrow management, and economic slashing via the
SwarmVerifierV4.cdcCadence smart contract - Storacha: Decentralized immutable IPFS storage for verified machine learning CSV payloads post-consensus
- NEAR Protocol: Integration for best new/continued project
Every detected anomaly undergoes a rigorous 4-stage "Race to Quorum" before being written to the immutable ledger.
Figure 1: The 4-phase lifecycle of an anomaly on the Flow blockchain.
Our network is divided into two distinct roles: The Transporter (the physical asset being tracked) and The Auditor Swarm (the decentralized verification network).
- The Transporter (a Raspberry Pi Pico 2 W) samples a high-precision BNO085 IMU (accelerometer and quaternions) at a constant 50Hz.
- An onboard TensorFlow Lite Micro 1D-CNN model continuously runs inference on the data buffer at 1Hz, looking for specific shock signatures.
- If a physical drop is detected with a confidence rating of
>= 0.85, the node shifts fromSTATE_IDLEtoSTATE_ANOMALY.
Once in an anomaly state, the Transporter must alert the network without relying on a centralized broker. It generates an ECDSA signature of the event timestamp and broadcasts a UDP multicast beacon to the local network.
Figure 2: Data flows from the Hardware Edge, through the Auditor Swarm, and settles On-Chain.
- Python-based Auditor nodes intercept this beacon and verify the public key signature to ensure the Transporter is a registered, staked network participant.
- Auditors submit bids (in Flow tokens) to verify the data. The Transporter selects a quorum based on the Auditors' available stake and their historical reputation scores.
- Selected Auditors pay a dummy HTTP 402 Payment Required toll to unlock a 1.5-second CSV buffer of the raw drop data from the Transporter's memory allocation.
- Auditors run the CSV through a secondary, independent Machine Learning model (e.g., a Random Forest classifier via scikit-learn) to mathematically cross-check the hardware's claim.
- The raw data and ML verification logs are encrypted and uploaded to Storacha (Filecoin/IPFS) for immutable storage, generating a globally verifiable CID.
Auditors submit their final ML verdict (Drop vs. Normal) to the Flow blockchain via a signed transaction. The SwarmVerifierV4.cdc Cadence smart contract waits for the quorum to finish, then executes the Incentive Matrix:
Figure 3: The Game Theory and economic incentive matrix governed by SwarmVerifier.cdc.
- Aligned Auditors: If an auditor's verdict matches the Swarm Consensus (
cswarm), they are rewarded with their deposit back, plus the bid price payout, and a reputation boost. - Deviated/Malicious Nodes: If a node contradicts the mathematical consensus (either due to a faulty ML model or malicious intent), its stake is slashed and its reputation drops. If reputation drops below
-50.0, the node is permanently blacklisted and evicted from the network.
Sensensus is designed to withstand several attack vectors common to IoT networks:
- Hardware Tampering / Spoofing: If an attacker hits a sensor with a hammer to simulate a drop, the raw IMU data signature will differ from a true free-fall impact. The Auditor Swarm's independent ML models will flag the data as anomalous and slash the Transporter.
- Sybil Attacks: An attacker cannot spin up thousands of fake Transporters or Auditors. Every node must be registered on the Flow blockchain with an active financial stake.
- Network Spam / DDoS: Transporters protect their limited memory buffers by requiring an HTTP 402 payment before releasing data, making DDoS attacks financially unviable.
Edge Hardware & Firmware
- Raspberry Pi Pico 2W (RP2350)
- BNO085 9-DOF IMU (I2C/Serial)
- C++ / PlatformIO
- lwIP UDP Multicast & HTTP Server
Machine Learning
- TensorFlow Lite Micro (C++ execution on Edge)
- scikit-learn (Python execution on Auditor Nodes)
- 1D Convolutional Neural Networks & Random Forest Classifiers
Blockchain & Storage
- Flow Testnet
- Cadence Smart Contracts (
SwarmVerifierV4.cdc) - Storacha (IPFS CID generation for immutable data proofs)
Frontend Dashboard
- React.js + Vite
- Custom CSS (Zero-Trust Mission Control UI)
- Flow FCL (Flow Client Library)
Sensensus/
├── Transporter_Pico/ # Hardware edge node (Transporter)
│ ├── src/
│ │ ├── main.cpp # Main state machine (Idle, Anomaly, Delivering)
│ │ ├── inference.cpp # TensorFlow Lite 1D-CNN execution
│ │ ├── crypto.cpp # ECDSA secp256r1 signature generation
│ │ ├── network.cpp # UDP Multicast, x402 HTTP Server
│ │ └── flow_tx.cpp # Native Flow blockchain transaction construction
│ └── platformio.ini # Hardware build configuration
├── Auditor/ # Auditor Swarm (Python)
│ ├── auditor_node.py # P2P Node daemon, x402 client, Flow SDK bridge
│ ├── models/ # Scikit-learn Random Forest serialized models
│ └── requirements.txt # Python dependencies
├── dashboard/ # React Frontend (Mission Control)
│ ├── src/
│ │ ├── components/ # UI components (IMU Cube, Ledger Table)
│ │ └── App.jsx # Main dashboard view
│ └── package.json # Node dependencies
└── contracts/ # Smart Contracts
└── SwarmVerifierV4.cdc # Core Cadence consensus & escrow logic
To run the full end-to-end system, you will need to flash the edge hardware and spin up the local auditor swarm.
- PlatformIO installed via VSCode.
- Flow CLI installed on your host machine.
- Node.js v18+ and npm.
- Python 3.9+ with
scikit-learnandrequestsinstalled.
- Wiring the BNO085 to the Pico 2W:
VIN➔3.3V (OUT)GND➔GNDSDA➔GPIO 4SCL➔GPIO 5
- Open the
Transporter_Picodirectory in PlatformIO - Navigate to
platformio.iniand update the following definitions
WIFI_SSIDandWIFI_PASS(must be on the same network as your laptop)PICO_PRIV_KEY_HEX(generate a random 64-character hex string for the Pico's identity)
- Navigate to
src/config.hand tweak the values as required. (Refer to the configuration section of the Readme) - Build and upload the firmware via USB
pio run --target upload
- Open the Serial Monitor at 115200 baud. You should see the Pico connect to Wi-Fi and register itself as a node on the Flow testnet.
<<<<<<< HEAD
To simulate a decentralized swarm on a single laptop, we need to run multiple auditor instances on different local UDP ports to prevent port collisions.
- Navigate to the
Auditordirectory and install the required ML and cryptography dependencies:
cd Auditor
pip install -r requirements.txt
# (Installs ecdsa, flow-py-sdk, numpy, pandas, scikit-learn, requests, python-dotenv, joblib)
- Create a
.envfile in theAuditordirectory with your Flow credentials:
FLOW_ACCOUNT_ADDR=0xYourFlowAccountAddress
FLOW_ACCOUNT_KEY=YourFlowPrivateKeyHex
FLOW_CONTRACT_ADDR=0xfcd23c8d1553708a
- Open two separate terminal windows to launch two independent auditors. The script will automatically generate unique identity PEM files for each port:
# Terminal 1: Start Auditor A
python auditor_node.py --key-file ../Identities/1.pem --port 5011 --flow-enabled --model models/choose_your_model
# Terminal 2: Start Auditor B
python auditor_node.py --key-file ../Identities/2.pem --port 5012 --flow-enabled --model models/choose_your_model
- Navigate to the
Dashboarddirectory:
cd Dashboard
npm install
- Start the Vite development server:
npm run dev
- Open your browser to
http://localhost:5173/
With the entire stack running, it's time to test the swarm:
- Look at your Pico Serial Monitor (or the Dashboard log view). It should say
STATE_IDLEand be sampling at 50Hz. - Physically drop or agressively shake the Raspberry Pi Pico
- Watch the terminal cascades:
- Pico: Detects the anomaly via TinyML (
conf >= 0.85), transitions toSTATE_ANOMALY, and broadcasts the UDPPKT_ANOMALYbeacon. - Auditor Terminals: Intercept the beacon, verify the ECDSA signature, and fire back a
PKT_BIDto the Pico. - Pico: Collects the bids, selects the quorum, and sends
PKT_QUORUM. - Auditor Terminals: Execute the x402 HTTP fetch, download the CSV, run the Random Forest ML verification, and submit their final signed verdict to the Flow testnet.
- Dashboard: Watch the UI update in real-time as the Flow blockchain tallies the votes, settles the transaction, rewards the honest auditors, and uploads the final cryptographic proof to Storacha IPFS.
| Macro | Description |
|---|---|
| WIFI_SSID | The local 2.4GHz network for the Pico and Auditors. |
| FLOW_CONTRACT_ADDR | The testnet address where SwarmVerifierV4 is deployed. |
| PICO_PRIV_KEY_HEX | A 64-character hex string acting as the Transporter's identity. |
| ANOMALY_CONFIDENCE_THRESHOLD | TinyML threshold to trigger an event (Default: 0.85). |
| DEPOSIT_AMOUNT | The FLOW token toll required for auditors to unlock data. |
| Variable | Description |
|---|---|
| FLOW_ACCOUNT_ADDR | The Flow testnet address paying gas for the auditor. |
| FLOW_ACCOUNT_KEY | The private key for the auditor's Flow account. |
| FLOW_CONTRACT_ADDR | Must match the Transporter's contract address. |
| ======= |
Start your auditor nodes in separate terminal windows(use different identity files and ports to avoid issues) to simulate the decentralized swarm. If a physical transporter node isnt available, you can make use of the mock_transporter in the Transporter_Python folder to simulate anomalies.
cd auditors
python auditor_node.py --key-file ../Identities/"YOUR_IDENTITY_FILE.pem" --flow-enabled --model /path/to/your/model --port 5011
python auditor_node.py --key-file ../Identities/"YOUR_IDENTITY_FILE1.pem" --flow-enabled --model /path/to/your/model --port 5012cd Transporter_Python
python mock_transporter.pyUse the Dashboard to visualize network consensus, reputation, and slashing events in real-time. Alternatively, run the dashboard on localhost to visualize IMU data on the dashboard using WebSerial API.(Use Chromium based browser)
cd dashboard
npm install
npm run devOnce the network is live, physically drop the hardware. Watch the React Dashboard visualize the network consensus, intercept the UDP packets, process the x402 payment, and trigger the Flow slashing event in real-time.
4823568f8382802abbb4125032a81543e8cbd3f8


