ed25519 CI

A crystal lang implementation of the Ed25519 elliptic curve public-key signature system described in RFC 8032.

What is Ed25519?

Ed25519 is a modern implementation of a Schnorr signature system using elliptic curve groups.

Ed25519 provides a 128-bit security level, that is to say, all known attacks take at least 2^128 operations, providing the same security level as AES-128, NIST P-256, and RSA-3072.

Ed25519 Diagram

Ed25519 has a number of unique properties that make it one of the best-in-class digital signature algorithms:

You can read more on Dan Bernstein's Ed25519 site.

Usage


require "ed25519"

# Generate a new random signing key
signing_key = Ed25519::SigningKey.new

# Sign a message with the signing key
message = "example message"
signature = signing_key.sign(message)

# Obtain the verify key for a given signing key
verify_key = signing_key.verify_key

# Check the validity of a signature
verify_key.verify(signature, message)

Serializing Keys

Keys can be serialized as 32-byte binary strings as follows:


signature_key_bytes = signing_key.key_bytes.hexstring
verify_key_bytes = verify_key.key_bytes.hexstring

The binary serialization can be passed directly into the constructor for a given key type


signing_key = Ed25519::SigningKey.new(signature_key_bytes.hexbytes)
verify_key  = Ed25519::VerifyKey.new(verify_key_bytes.hexbytes)

Credit

The original crystal port was done by davidkellis based on the javascript implementation by paulmillr Interface copied from the Ruby implementation by tarcieri