Meter Payload
Last updated
Last updated
The core data unit in the protocol is a JSON payload sent from the smart meter, which includes energy consumption data along with cryptographic elements to ensure authenticity. This payload is carefully structured in the following order:
Data: A stringified array that contains:
Nonce: A sequential integer that serves as a unique identifier for each message, helping to prevent replay attacks.
Voltage: The average voltage measurement, recorded in volts (V), with a precision of two decimal places. This value is typically averaged over a one-minute interval.
Current: The average current reading, in amps (A), also recorded over a one-minute interval and to two decimal places.
Energy: The computed energy usage, in kilowatt-hours (kWh), calculated based on the voltage and current readings over the same interval. This value is highly precise, recorded to seven decimal places.
Signature: A Base64-encoded cryptographic signature of the data above, generated by the smart meter’s hardware. This signature verifies that the data originates from an authenticated meter and has not been tampered with.
Public Key: The Base64-encoded public key of the meter hardware that signed the data. This key uniquely associates the payload with a specific meter and allows external systems to validate its authenticity.
The signature and public key within the payload are encoded using Base64. This encoding allows binary data to be easily represented as ASCII text, simplifying transmission across systems that may be resource constrained such as microprocessors in the smart metering hardware, and communication networks such as LoRaWAN.
Paying close attention to the exact structure and order of each meter payload is essential, as any change could result in misinterpreted data, incorrect energy balance calculations, or even invalidation of the cryptographic signatures. Each payload array is organized in a specific sequence: it begins with a nonce, followed by voltage, current, and the computed energy reading. This sequence of values is then converted into a single string and placed in an outer array alongside two additional components: the signature string (which is the cryptographic signature of the data string) and the meter’s public key. Maintaining this structure precisely as shown ensures the protocol’s reliability and integrity.
In this example:
The signed data string is "[2, 213.7, 0.38, 0.007420]"
, where 2 is the nonce, 213.7 is the voltage, 0.38 is the current, and 0.007420 is the computed energy.
The signature and public key fields are Base64-encoded strings representing signature and public key, respectively.
To ensure data integrity and authenticity, the M3tering Protocol employs the Ed25519 digital signature scheme. This scheme is a well-regarded cryptographic method known for its high performance and strong security guarantees. Each payload is signed by the meter’s private key, which, in conjunction with the associated public key, ensures that data can be verified and trusted by external systems or entities receiving it.
Simplicity: Ed25519 is simpler and easier to implement than ECDSA, which is a considerable benefit for IoT devices with limited resources.
Performance: Ed25519 provides faster signature generation and verification, which is crucial for IoT devices operating in real-time environments. The reduced computational load can lead to significant power savings and memory efficiency, which can significantly improve the overall performance of our devices and the M3tering Protocol as a whole.
Compatibility: While secp256k1 is widely used in the blockchain space, curve25519 is gaining traction due to its compatibility with various platforms and libraries. This compatibility simplifies integration efforts and ensures a seamless experience for developers working with our devices.
Compact Signatures: Ed25519 generates smaller signature sizes, which is crucial for IoT devices with constrained data transmission capabilities. The efficiency gains could lead to reduced transmission times and enhanced device responsiveness.
Long-term Viability: It's designed with long-term security in mind, making it a reliable choice for the future.
you can learn more about ED25519 and other comparable schemes here The blog also provides a rational for our adoption of the ED25519 signature scheme.
The M3ter NFT contract on the EVM also serve as a key registry for each hardware smart meter. During the initial setup, each hardware meter generates its own ED25519 key pair and it posts the public key to this M3ter contract in a registration event, binding it to a specific tokenId that represents this particular hardware device. To authenticate any subsistent data from the smart meter, the public key stored in the M3ter contract can be used to verify the digital signature attached to the payload.
This setup provides a secure and tamper-resistant method for linking each data point to its specific device, ensuring the integrity and traceability of the data stream from the physical meter to its digital representation as an NFT on-chain.