Arduino Cryptography Library
Classes | Static Public Member Functions | List of all members
Ed25519 Class Reference

Digital signatures based on the elliptic curve modulo 2^255 - 19. More...

#include <Ed25519.h>

Static Public Member Functions

static void sign (uint8_t signature[64], const uint8_t privateKey[32], const uint8_t publicKey[32], const void *message, size_t len)
 Signs a message using a specific Ed25519 private key. More...
 
static bool verify (const uint8_t signature[64], const uint8_t publicKey[32], const void *message, size_t len)
 Verifies a signature using a specific Ed25519 public key. More...
 
static void generatePrivateKey (uint8_t privateKey[32])
 Generates a private key for Ed25519 signing operations. More...
 
static void derivePublicKey (uint8_t publicKey[32], const uint8_t privateKey[32])
 Derives the public key from a private key. More...
 

Detailed Description

Digital signatures based on the elliptic curve modulo 2^255 - 19.

The first step in creating a digital signature with Ed25519 is to generate a key pair:

uint8_t privateKey[32];
uint8_t publicKey[32];
Ed25519::derivePublicKey(publicKey, privateKey);
static void derivePublicKey(uint8_t publicKey[32], const uint8_t privateKey[32])
Derives the public key from a private key.
Definition: Ed25519.cpp:256
static void generatePrivateKey(uint8_t privateKey[32])
Generates a private key for Ed25519 signing operations.
Definition: Ed25519.cpp:243

The application can store both the private and public key for later signing operations. Or it can store just the private key and then derive the public key at the point where signing is to occur.

Message signing produces a 64-byte signature as follows:

uint8_t message[N];
uint8_t signature[64];
Ed25519::sign(signature, privateKey, publicKey, message, N);
static void sign(uint8_t signature[64], const uint8_t privateKey[32], const uint8_t publicKey[32], const void *message, size_t len)
Signs a message using a specific Ed25519 private key.
Definition: Ed25519.cpp:127

And then to verify the signature:

if (!Ed25519::verify(signature, publicKey, message, N)) {
// The signature is invalid.
...
}
static bool verify(const uint8_t signature[64], const uint8_t publicKey[32], const void *message, size_t len)
Verifies a signature using a specific Ed25519 public key.
Definition: Ed25519.cpp:189
Note
The public functions in this class need a substantial amount of stack space to store intermediate results while the curve function is being evaluated. About 1.5k of free stack space is recommended for safety.

References: https://tools.ietf.org/html/draft-irtf-cfrg-eddsa-05

See also
Curve25519

Definition at line 29 of file Ed25519.h.

Member Function Documentation

◆ derivePublicKey()

void Ed25519::derivePublicKey ( uint8_t  publicKey[32],
const uint8_t  privateKey[32] 
)
static

Derives the public key from a private key.

Parameters
publicKeyThe public key.
privateKeyThe private key.
See also
generatePrivateKey()

Definition at line 256 of file Ed25519.cpp.

◆ generatePrivateKey()

void Ed25519::generatePrivateKey ( uint8_t  privateKey[32])
static

Generates a private key for Ed25519 signing operations.

Parameters
privateKeyThe resulting private key.

The private key is generated with RNG.rand(). It is the caller's responsibility to ensure that the global random number pool has sufficient entropy to generate the 32 bytes of the key safely before calling this function.

See also
derivePublicKey()

Definition at line 243 of file Ed25519.cpp.

◆ sign()

void Ed25519::sign ( uint8_t  signature[64],
const uint8_t  privateKey[32],
const uint8_t  publicKey[32],
const void *  message,
size_t  len 
)
static

Signs a message using a specific Ed25519 private key.

Parameters
signatureThe signature value.
privateKeyThe private key to use to sign the message.
publicKeyThe public key corresponding to privateKey.
messagePoints to the message to be signed.
lenThe length of the message to be signed.
See also
verify(), derivePublicKey()

Definition at line 127 of file Ed25519.cpp.

◆ verify()

bool Ed25519::verify ( const uint8_t  signature[64],
const uint8_t  publicKey[32],
const void *  message,
size_t  len 
)
static

Verifies a signature using a specific Ed25519 public key.

Parameters
signatureThe signature value to be verified.
publicKeyThe public key to use to verify the signature.
messageThe message whose signature is to be verified.
lenThe length of the message to be verified.
Returns
Returns true if the signature is valid for message; or false if the signature is not valid.
See also
sign()

Definition at line 189 of file Ed25519.cpp.


The documentation for this class was generated from the following files: