Skip to content

pg_ed25519

Ed25519 signing and signature-verification functions for PostgreSQL

pg_ed25519 · Ed25519 signing and signature-verification functions for PostgreSQL

Overview

IDExtensionPackageVersionCategoryLicenseLanguage
100180pg_ed25519pg_ed255190.2SECMITC

PostgreSQL · 10, 11, 12, 13, 14, 15, 16, 17, 18

Usage

Sources:

pg_ed25519 0.2 adds Ed25519 signing and verification functions in the fixed ed25519 schema. It accepts raw 32-byte public and private keys and produces 64-byte signatures. It provides cryptographic operations only, not key generation, storage, rotation, or access control.

Core Workflow

Generate keys outside PostgreSQL, retain the raw 32-byte key material described by upstream, and pass it as bound bytea parameters rather than SQL literals.

CREATE EXTENSION pg_ed25519;

PREPARE sign_message(bytea, bytea, bytea) AS
SELECT ed25519.sign($1, $2, $3);

PREPARE verify_message(bytea, bytea, bytea) AS
SELECT ed25519.verify($1, $2, $3);

The signing parameter order is message, public key, private key. Verification takes message, signature, public key.

Function Index

  • ed25519.sign(bytea, bytea, bytea) and its text-message overload return a 64-byte signature.
  • ed25519.verify(bytea, bytea, bytea) and its text-message overload return boolean.
  • The functions are immutable, strict, and parallel-safe. Invalid key or signature lengths raise errors.

Security and Interoperability

  • Private key bytes cross the SQL boundary. Protect them from query text, logs, statistics, tracing, result capture, and roles that can inspect sessions; prefer application-side signing when that exposure is unacceptable.
  • Text overloads sign the exact server-encoded text bytes. Use bytea with an explicitly canonicalized encoding when other systems must reproduce signatures.
  • The extension is installed into the fixed ed25519 schema and is not relocatable. Schema-qualify calls and tightly control EXECUTE privileges.

Table reader