class

Beryl::Crypto::V1::DiffieHellmanOverCurve25519::PrivateKey

Inherits Reference < Object

A private key: 32 secret bytes, clamped as RFC 7748 §5 describes each time they are used.

Constructors

generate

Returns a new private key from Random::Secure.

Source
new(secret : Bytes)

Keeps a copy of secret (32 bytes).

Source

Instance methods

finalize
Source
public_key

Returns the matching public key, X25519(secret, 9).

Source
shared_secret(peer : PublicKey) : Bytes | Nil

Returns the 32-byte shared secret with peer, or nil when it is all zero, which happens only when the peer sent a point of small order (RFC 7748 §6.1; RFC 9846 §7.4.2 requires the check).

Source
to_slice

Returns a copy of the private key's 32 bytes.

Source