In 2014/2015 I implemented Ed25519-SHA-512 for a commercial software. I want to share notes with you, I took during the implementation. It might help you to implement EdDSA/Curve25519 yourself.
Software using Curve25519
See the wonderful list by ianix.com.
- A digital signature scheme (DSA) using Edwards curves (Ed). The specific curve and hash algorithm to use is unspecified.
- The Montgomery curve
- EdDSA using the Twisted Edwards curve which is birationally equivalent to Curve25519
- Ed25519 with the hash algorithm SHA-512
|Daniel J Bernstein, Chitchanok Chuengsatiansup, Tanja Lange||“Curve41417: Karatsuba revisited”||2014|
|Daniel J Bernstein, Niels Duif, Tanja Lange, Peter Schwabe, Bo-Yin Yang||“High-speed high-security signatures”||2011|
|Huseyin Hisil, Kenneth Koon-Ho Wong, Gary Carter, Ed Dawson||“Twisted Edwards Curves Revisited”||2008|
|Daniel J Bernstein, Peter Birkner, Marc Joye, Tanja Lange, Christiane Peters||“Twisted Edwards Curves”||2008|
The 2014 paper is not relevant for EdDSA, but listed here, because EdDSA is mostly implemented because of its performance. This paper introduces an even faster Curve41417 (formerly known as Curve3617).
The protocol itself
This digital signature scheme is defined in the 2011 paper.
Key pair generation
Given random bytes , we initialize:
- The private key is given as
- The public key is given as
Given a message as sequence of bytes. Let underline denote the little-endian -bit encoding of a point meaning that index contains the LSB of the y-coordinate and index contains the MSB of y, but set the highest bit if and only if the lower bit of x is set.
Accept if and only if
If you are still wondering about the steps, this Ed25519 article by Brian Warner should give you a good start for your implementation.
Notes & resources
- An informal cheatsheet for Curve25519 and Ed25519
- My cheatsheet “Elliptic Curves, birational equivalence and EdDSA” featuring
- theoretical background
- additional test vectors
- sage and python source snippets
- A tool to simplify work with byte arrays
- A commented version of ed25519.py with example output
- Sagemath worksheets