7

I'm exploring the IoT side of the EVM. I've programmed Arduinos and ESP8266s to interact with a Geth JSON RPC. I'm trying to be minimalistic and avoid NodeJS on the Geth JSON server side. Currently the ESP8266 just unlocks the accounts via the Personal.sendTransaction function. I know this is poor security if someone infiltrated my wifi LAN (my Geth node is running on my wifi Router OpenWrt) I've seen examples of ethereumjs-utils being used to sign transactions offline. Is there a LIGHTWEIGHT (under 500k) C++ version of this, at least the ECDSA secp256k1 keccak256 algorithms?? Ideally the microcontroller would sign the transaction, then broadcast the the raw transaction. The only way a thief could get access to the IoT wallet would be physical access to the device, dump the flash ROM, reverse engineer the binary to extract the private key. Any suggestions?? Here is working example of ESP8266 ESP-01 pushing and pulling temperature data to the Rinkeby blockchain, the majority of the code being the JSON parsing https://github.com/gusgorman402/ESP8266_Geth

  • I'm looking into Espruino, javascript for microcontrollers. But I'd prefer a C++ way – GusGorman402 Oct 29 '17 at 23:19
  • You have libsecp256k1 for the elliptic curve, tiny-keccak for keccak (there's a pull request to add Ethereum's keccak256 version), the missing piece is a library to serialize transactions using Ethereum's RLP. – Ismael Oct 30 '17 at 4:16
  • 1
    I found this github github.com/kvhnuke/Ethereum-Arduino/blob/master/… – GusGorman402 Oct 31 '17 at 18:40
  • I'm also looking at this. I started writing my own RLP encoding class, got halfway through, the example linked above is very helpful. I also started looking at pulling in the relevant files from the cpp-ethereum project, but its a large project and I only need to sign local transactions and call contract methods. – Adamski Jan 21 '18 at 11:09
  • I made YouTube video about using ESP8266 , but the signing happens on the node hackaday.com/2017/11/09/iot-with-the-ethereum-blockchain – GusGorman402 Jan 21 '18 at 21:27
6

You can use our Firefly Hardware Wallet (https://firefly.city) for the ATmega328 to do:

  • secp256k1 signing
  • RLP decoding transactions
  • keccak256
  • generating checksum addresses (or raw addresses)

Signing requires in the neighbourhood of around 700 bytes of free memory, I believe, but everything else requires a fairly slim memory footprint.

If you require an OLED display, the Firefly source code also includes our zero-memory video driver.

Here is a link to the library: https://github.com/firefly/wallet/tree/master/source/libs/ethers

Also, all the code is BSD/MIT licensed, so should be fairly easy for any project to incorporate.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.