Why Nostr? What is Njump?
2023-06-09 12:44:42
in reply to

Rusty Russell [ARCHIVE] on Nostr: 📅 Original date posted:2015-10-02 📝 Original message: Hi all! So, I've pushed ...

📅 Original date posted:2015-10-02
📝 Original message:
Hi all!

So, I've pushed some test onion routing code in an acceptable
format:
https://github.com/ElementsProject/lightning/blob/onion/test/test_onion.c

#define MESSAGE_SIZE 128
#define MAX_HOPS 20

/* Prepend 0x02 to get pubkey for libsecp256k1 */
struct pubkey {
unsigned char u8[32];
};

struct hop {
unsigned char msg[MESSAGE_SIZE];
struct pubkey pubkey;
struct sha256 hmac;
};

struct onion {
struct hop hop[MAX_HOPS];
};

That's a fixed 3840 bytes; each node decrypts and removed the tail
entry, then prepends padding. (Working backwards like that turns out to
be slightly more efficient for generating, see git commits).

There's nothing exotic in here: it's AES128 counter mode, HMAC using
SHA256, and Bitcoin's EC with ECDH. But crypto review particularly
welcome!

Cheers,
Rusty.
Author Public Key
npub1zw7cc8z78v6s3grujfvcv3ckpvg6kr0w7nz9yzvwyglyg0qu5sjsqhkhpx