Skip to content
pguecc

pguecc

pg_ecdsa : uECC bindings for Postgres

Overview

ID Extension Package Version Category License Language
4460
pguecc
pg_ecdsa
1.0
UTIL
BSD-2-Clause
C
Attribute Has Binary Has Library Need Load Has DDL Relocatable Trusted
--s-d-r
No
Yes
No
Yes
yes
no
Relationships
See Also
pgsodium
pgcrypto
shacrypt
cryptint
pgcryptokey
pgsmcrypto
pg_oidc_validator
sslutils
sslinfo
hashlib

Packages

Type Repo Version PG Major Compatibility Package Pattern Dependencies
EXT
PIGSTY
1.0
18
17
16
15
14
pg_ecdsa -
RPM
PIGSTY
1.0
18
17
16
15
14
pg_ecdsa_$v -
DEB
PIGSTY
1.0
18
17
16
15
14
postgresql-$v-pg-ecdsa -
Linux / PG PG18 PG17 PG16 PG15 PG14
el8.x86_64
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
el8.aarch64
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
el9.x86_64
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
el9.aarch64
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
el10.x86_64
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
el10.aarch64
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
d12.x86_64
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
d12.aarch64
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
d13.x86_64
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
d13.aarch64
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
u22.x86_64
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
u22.aarch64
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
u24.x86_64
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
u24.aarch64
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
u26.x86_64
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
u26.aarch64
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
PIGSTY 1.0
Package Version OS ORG SIZE File URL
pg_ecdsa_18 1.0 el8.x86_64 pigsty 27.8 KiB pg_ecdsa_18-1.0-1PIGSTY.el8.x86_64.rpm
pg_ecdsa_18 1.0 el8.aarch64 pigsty 27.3 KiB pg_ecdsa_18-1.0-1PIGSTY.el8.aarch64.rpm
pg_ecdsa_18 1.0 el9.x86_64 pigsty 25.4 KiB pg_ecdsa_18-1.0-1PIGSTY.el9.x86_64.rpm
pg_ecdsa_18 1.0 el9.aarch64 pigsty 25.0 KiB pg_ecdsa_18-1.0-1PIGSTY.el9.aarch64.rpm
pg_ecdsa_18 1.0 el10.x86_64 pigsty 25.9 KiB pg_ecdsa_18-1.0-1PIGSTY.el10.x86_64.rpm
pg_ecdsa_18 1.0 el10.aarch64 pigsty 25.0 KiB pg_ecdsa_18-1.0-1PIGSTY.el10.aarch64.rpm
postgresql-18-pg-ecdsa 1.0 d12.x86_64 pigsty 64.7 KiB postgresql-18-pg-ecdsa_1.0-1PIGSTY~bookworm_amd64.deb
postgresql-18-pg-ecdsa 1.0 d12.aarch64 pigsty 63.6 KiB postgresql-18-pg-ecdsa_1.0-1PIGSTY~bookworm_arm64.deb
postgresql-18-pg-ecdsa 1.0 d13.x86_64 pigsty 65.5 KiB postgresql-18-pg-ecdsa_1.0-1PIGSTY~trixie_amd64.deb
postgresql-18-pg-ecdsa 1.0 d13.aarch64 pigsty 64.0 KiB postgresql-18-pg-ecdsa_1.0-1PIGSTY~trixie_arm64.deb
postgresql-18-pg-ecdsa 1.0 u22.x86_64 pigsty 66.3 KiB postgresql-18-pg-ecdsa_1.0-1PIGSTY~jammy_amd64.deb
postgresql-18-pg-ecdsa 1.0 u22.aarch64 pigsty 65.1 KiB postgresql-18-pg-ecdsa_1.0-1PIGSTY~jammy_arm64.deb
postgresql-18-pg-ecdsa 1.0 u24.x86_64 pigsty 66.2 KiB postgresql-18-pg-ecdsa_1.0-1PIGSTY~noble_amd64.deb
postgresql-18-pg-ecdsa 1.0 u24.aarch64 pigsty 64.9 KiB postgresql-18-pg-ecdsa_1.0-1PIGSTY~noble_arm64.deb
postgresql-18-pg-ecdsa 1.0 u26.x86_64 pigsty 65.1 KiB postgresql-18-pg-ecdsa_1.0-1PIGSTY~resolute_amd64.deb
postgresql-18-pg-ecdsa 1.0 u26.aarch64 pigsty 64.0 KiB postgresql-18-pg-ecdsa_1.0-1PIGSTY~resolute_arm64.deb

Source

pig build pkg pg_ecdsa;		# build rpm/deb

Install

Make sure PGDG and PIGSTY repo available:

pig repo add pgsql -u   # add both repo and update cache

Install this extension with pig:

pig install pg_ecdsa;		# install via package name, for the active PG version
pig install pguecc;		# install by extension name, for the current active PG version

pig install pguecc -v 18;   # install for PG 18
pig install pguecc -v 17;   # install for PG 17
pig install pguecc -v 16;   # install for PG 16
pig install pguecc -v 15;   # install for PG 15
pig install pguecc -v 14;   # install for PG 14

Create this extension with:

CREATE EXTENSION pguecc;

Usage

pguecc: Elliptic curve cryptography (micro-ecc bindings) for PostgreSQL

Requires the pgcrypto extension.

Generate Key Pair

SELECT ecdsa_make_key('secp256k1');
-- (public_key_hex, private_key_hex)

Sign Data

SELECT ecdsa_sign(
    '000000000000000000000000000000000000000000',  -- private key (hex)
    '1234',                                          -- data to sign
    'sha256',                                        -- hash function
    'secp160r1'                                      -- curve name
);

Verify Signature

SELECT ecdsa_verify(
    '<public_key_hex>',
    'hello, world',
    '<signature_hex>',
    'sha256',
    'secp256k1'
);
-- t

Key Validation

SELECT ecdsa_is_valid_public_key('<public_key_hex>', 'secp256k1');
SELECT ecdsa_is_valid_private_key('<private_key_hex>', 'secp256k1');
SELECT ecdsa_is_valid_curve('secp256k1');  -- true

Supported Curves

secp160r1, secp192r1, secp224r1, secp256r1, secp256k1

Raw API

For direct signing without hashing (use with caution):

SELECT ecdsa_sign_raw(private_key_bytea, hash_bytea, 'secp256k1');
SELECT ecdsa_verify_raw(public_key_bytea, hash_bytea, signature_bytea, 'secp256k1');
Last updated on