ECNet - Easy Encrypted Communications

Started by PG231, Mar 22, 2020, 01:28 AM

Previous topic - Next topic

PG231

This is my attempt at making a simple API for sending secret messages. It uses 168-bit elliptic curves for key exchange and ChaCha20/8 + SipHash-2-4 for authenticated encryption. You can send authenticated encrypted messages between computers by knowing their "address" string and its interface is similar to that of modem.

Example
Instead of using computer IDs, you use a long address for identification. Here's an example:
-- Sending a message
local ecnet = require("ecnet")
local modem = peripheral.find("modem")
local s_modem = ecnet.wrap(modem)
s_modem.connect("33c2:7172:35a0:abdf:d066", 3) -- Try to connect for 3 seconds
s_modem.send("33c2:7172:35a0:abdf:d066", "hello")
-- Receiving a message
local ecnet = require("ecnet")
local modem = peripheral.find("modem")
local s_modem = ecnet.wrap(modem)
local sender, message = s_modem.receive()

Download
You can look at the code here: https://github.com/migeyel/ecnet/
Or download the minified version here: https://gist.githubusercontent.com/migeyel/278f77628248ea991719f0376979b525/
Or using wget:
wget https://gist.githubusercontent.com/migeyel/278f77628248ea991719f0376979b525/raw/ecnet.min.lua ecnet.lua