- vendor orlp/ed25519 (lib/ed25519, MIT — the exact lib MeshCore uses) for Curve25519 ECDH key exchange; switch identity/advert signing to it (same seed -> same pubkey, so peers still recognise us; sigs are byte-identical) - store pubkeys from heard MeshCore adverts (contacts table) so a DM's 1-byte src_hash can be resolved to a full sender key - decode PAYLOAD_TYPE_TXT_MSG: ECDH shared secret, HMAC-SHA256 MAC check, AES-128-ECB decrypt, parse timestamp+text, drive the message modal - verified end-to-end: real MeshCore node -> "hello from HP Pro Desk" decoded Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
42 lines
1.4 KiB
C
42 lines
1.4 KiB
C
#ifndef ED25519_H
|
|
#define ED25519_H
|
|
|
|
// Nightcracker's Ed25519 - https://github.com/orlp/ed25519
|
|
|
|
#include <stddef.h>
|
|
|
|
#if defined(_WIN32)
|
|
#if defined(ED25519_BUILD_DLL)
|
|
#define ED25519_DECLSPEC __declspec(dllexport)
|
|
#elif defined(ED25519_DLL)
|
|
#define ED25519_DECLSPEC __declspec(dllimport)
|
|
#else
|
|
#define ED25519_DECLSPEC
|
|
#endif
|
|
#else
|
|
#define ED25519_DECLSPEC
|
|
#endif
|
|
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
#ifndef ED25519_NO_SEED
|
|
int ED25519_DECLSPEC ed25519_create_seed(unsigned char *seed);
|
|
#endif
|
|
|
|
void ED25519_DECLSPEC ed25519_create_keypair(unsigned char *public_key, unsigned char *private_key, const unsigned char *seed);
|
|
void ED25519_DECLSPEC ed25519_derive_pub(unsigned char *public_key, const unsigned char *private_key);
|
|
void ED25519_DECLSPEC ed25519_sign(unsigned char *signature, const unsigned char *message, size_t message_len, const unsigned char *public_key, const unsigned char *private_key);
|
|
int ED25519_DECLSPEC ed25519_verify(const unsigned char *signature, const unsigned char *message, size_t message_len, const unsigned char *public_key);
|
|
void ED25519_DECLSPEC ed25519_add_scalar(unsigned char *public_key, unsigned char *private_key, const unsigned char *scalar);
|
|
void ED25519_DECLSPEC ed25519_key_exchange(unsigned char *shared_secret, const unsigned char *public_key, const unsigned char *private_key);
|
|
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif
|