class

OpenSSL::PKey::EC

Inherits OpenSSL::PKey::PKey < Reference < Object

Constructors

new(key : String)
Source
new(io : IO)
Source
new(size : Int32)
Source

Class methods

compute_shared_secret(private_key : OpenSSL::PKey::EC, peer_public_key : OpenSSL::PKey::EC) : Bytes

ECDH using EVP_PKEY_derive (works on OpenSSL 1.0.2+) Returns the raw ECDH shared secret (no KDF). Feed this into HKDF, etc.

Source
from_private_bytes(bytes : Bytes, curve : String = "P-256")

Create EC key from raw private key bytes For P-256, expects 32 bytes; for P-384, expects 48 bytes, etc.

Source
from_public_bytes(bytes : Bytes, curve : String = "P-256")

Create public key from raw bytes (uncompressed format: 0x04 + x + y)

Source
generate(size : Int32)
Source
generate(type : String)
Source
generate_by_curve_name(curve_name : String)

Generate EC key by curve name (supports non-NIST curves like secp256k1)

Source

Instance methods

ec_sign(data)
Source
ec_verify(digest, signature)
Source
group
Source
group_degree
Source
private_key_bytes

Export private key as raw bytes (zero-padded to curve size)

Source
public_key
Source
public_key_bytes

Export public key as raw bytes (uncompressed format: 0x04 + x + y)

Source
to_der(io)
Source
to_pem(io)
Source
to_text
Source

Nested types