I knew you had to be doing more than just SHA512. That's just a small part of Ed25519, the majority of which is all the elliptic stuff. The majority of the TIME taken is the elliptic multiplication as well. ASN1 is huge too.
You're trying to do this on an MCF51JM128 (or maybe use an MCF51MM256). They run at 50MHz.
Ed25519 is running SHA2-512 and I think Ed25519 is a 256-bit key. It's all set up to run nicely on Gigahertz X64 chips in this decade.
We're running "old ltc/src/ecc/ecc" here with the 128-bit "SECP128R1" key. That's running on a 150MHz MCF5235 (triple your clock rate) with SHA1 running on the MDHA hardware in the chip to make it faster (we wrote that). We're also using "TFM" (tomsfastmaths). Most of the time is in a very inefficient multi-precision multiply (fp_mul and fp_mul_comba). I tried to use the EMAC to speed those up, but couldn't get it work.
It takes our chip about 2.5 SECONDS to encrypt a short symmetric key. That's time when it is locked solid inside the libtomcrypt library, and so the device is unable to execute any other code. Like the loop that pats the watchdog! Yours may be locked up for 20 seconds or more at your clock rate and with that wider encryption scheme. Can your system handle that?
Fortunately, our product has a relatively old ARM core in there as well (800MHz Cortex-A8), and it can do the same thing (also running libtomcrypt) in 28ms. About 1000 times faster!. So the MCF5235 asks the ARM chip to do that work for it. It might even be worth your putting a small ARM chip on your board to offload the encryption work on an SPI or I2C port.
The way we cut LTC down to size was to build with a file like this, which is pulled in before ltc/src/headers/tomcrypt.h:
// LibTomCrypt configuration
#define ENDIAN_BIG
#define ENDIAN_32BITWORD
// Ciphers
#define LTC_NO_CIPHERS
#define LTC_RIJNDAEL
// Modes
#define LTC_NO_MODES
#define LTC_CTR_MODE
#define LTC_GCM_MODE
// Hashes
#define LTC_NO_HASHES
#define LTC_SHA1
#define LTC_HASH_HELPERS
// MACs
#define LTC_NO_MACS
// PRNGs
#define LTC_NO_PRNGS
#define LTC_SPRNG
// PK
#define LTC_NO_PK
#define LTC_MECC
#define LTC_ECC_SHAMIR
#define LTC_NO_ECC_TIMING_RESISTANT
// Other
#define LTC_NO_MISC
#define LTC_NO_PKCS
#define LTC_DER
#define LTC_NO_TEST
#define LTC_NO_FILE
Or you can pass all of the above in on the compiler command line as "-DLTC...", but that makes for a messy makefile.
The above tells it to include nothing (from each of the types) and to then only include the ones we want. You could start off with everything set to "LTC_NO_xxx" and see how big that is.
I've just summed all the Text sizes for the compiled object files. The biggest totals for the ones we're using are AES at 34k, followed by the ASN1 coder at 30k! ASN1 is only used to encode and decode the keys. You might be able to get rid of that. The ECC takes 18k. The "register and search for these things by name" takes 11k.
Tom