Skip to content

ped25519

Ed25519 signing and verification functions implemented in Rust with pgrx.

ped25519 · Ed25519 signing and verification functions implemented in Rust with pgrx.

Overview

IDExtensionPackageVersionCategoryLicenseLanguage
100931ped25519ped255190.1.0SECMITRust

PostgreSQL · 14, 15, 16

Usage

Sources:

ped25519 version 0.1.0 provides Ed25519 signing and verification as in-process Rust functions. The signing function accepts message bytes, a 32-byte public key, and a 32-byte private key; verification accepts message bytes, a 64-byte signature, and the 32-byte public key.

Sign and verify

This uses the fixed example key material published by upstream, not a production key:

CREATE EXTENSION ped25519;

WITH keys AS (
    SELECT
        decode('NZV4l8hck3iUqInENyI+nn5vkW7rqzQg0uiuuZkPnHE=', 'base64') AS public_key,
        decode('eT7qaT8vkIgCl6/9EmEDYYEgxA0oOgHc0P6UYzcQN28=', 'base64') AS private_key
), signed AS (
    SELECT
        convert_to('some data for signing', 'UTF8') AS message,
        public_key,
        ed25519_sign(
            convert_to('some data for signing', 'UTF8'),
            public_key,
            private_key
        ) AS signature
    FROM keys
)
SELECT ed25519_verify(message, signature, public_key)
FROM signed;

The result should be true. ped25519 does not generate keys or provide a key store; key generation, rotation, backup, and access control remain application responsibilities.

Security and compatibility

Never place real private keys in migration files, query text, parameters visible to monitoring, or application logs. Revoke public execution and grant signing only to a narrowly scoped role; verification can usually be granted separately. Prefer signing outside the database when a dedicated key manager or hardware-backed key can be used.

The Rust implementation slices the supplied public and combined key buffers before all length errors can be returned cleanly. Enforce exact input lengths to avoid a panic/error path. The reviewed pgrx build declares PostgreSQL 14 through 16 features and requires superuser installation; validate the package on the exact target major version.

Table reader