Module ED

Ed25519 signature scheme (ED)

This module provides algorithms and functions for an elliptic curve signature scheme.

It uses the Elliptic Curve Ed25519. Ed25519 is an elliptic curve used in elliptic-curve cryptography (ECC) designed for use with the Elliptic-curve Diffie–Hellman (ECDH) key agreement scheme. It is based on asymmetric public/private key encryption technologies.

Public key size = 256 bit (64 byte),

Secret key size = 256 bit (64 byte),

Sign size = 512 bit (128 byte) provided by the hash function SHA-512

ED Functions

secgen () Generate a secret key for the digital signature based on the Elliptic Curve Ed25519.
pubgen (sk) Deterministic algorithm that generates a public key for the digital signature based on the Elliptic Curve Ed25519.
sign (sk, m) Sign a message m using a secret key sk generated by ED.secgen().
verify (pk, sign, m) Verify if the signature (sign) of a message (m) is correct.


ED Functions

secgen ()
Generate a secret key for the digital signature based on the Elliptic Curve Ed25519. Does not require an input.

Returns:

    sk, an octet of 64 bytes

Usage:

    ED = require("ed")
    sk = ED.secgen()
    print(sk:hex())		-- print the secret key in hexadecimal notation
pubgen (sk)
Deterministic algorithm that generates a public key for the digital signature based on the Elliptic Curve Ed25519.

Parameters:

  • sk , required a secret key generated by the previous function

Returns:

    pk, an octet of 64 bytes

Usage:

    ED = require("ed")
    sk = ED.secgen()
    pk = ED.pubgen(sk)
    print(pk:hex())			-- print the public key in hexadecimal notation
sign (sk, m)
Sign a message m using a secret key sk generated by ED.secgen().

Parameters:

  • sk
  • m

Returns:

    an octet of 128 bytes, the digital signature

Usage:

    ED = require("ed")
    random_message_length = 1
    m = OCTET.new(random_message_length)
    sk = ED.secgen()
    sign = ED.sign(sk,m)
    print(sign:hex())
verify (pk, sign, m)
Verify if the signature (sign) of a message (m) is correct.

Parameters:

  • pk
  • sign
  • m

Returns:

    a boolean: true if the signature is correct, false otherwise

Usage:

    random_message_length = 1
    m = OCTET.new(random_message_length)
    sk = ED.secgen()
    pk = ED.pubgen(sk)
    sign = ED.sign(sk,m)
    bool = ED.verify(pk, sign, m)
    if bool then print("true")
    else print("false")
    end
generated by LDoc 1.5.0 Last updated 2025-03-25 10:43:18