httk.core.crypto

Ed25519 signing with an optional accelerated backend.

These signing primitives are used by project identity and trust.

All private keys accepted and returned by this module are standard 32-byte Ed25519 seeds. The stdlib implementation follows RFC 8032 and is kept as a portable fallback; cryptography is used automatically when installed.

Functions

ed25519_backend_available([backend])

Return whether backend can perform Ed25519 operations.

ed25519_generate_seed()

Generate a standard 32-byte Ed25519 private seed.

ed25519_public_key(seed, *[, backend])

Derive the public key for a private seed.

ed25519_sign(seed, message, *[, backend])

Return an RFC 8032 Ed25519 signature for message.

ed25519_verify(public_key, message, signature, *[, ...])

Return whether signature is valid, treating malformed input as false.

Module Contents

httk.core.crypto.ed25519_backend_available(backend='cryptography')[source]

Return whether backend can perform Ed25519 operations.

Parameters:

backend (str) – Backend name: "cryptography", "pure", or "stdlib".

Returns:

Whether the selected backend is available.

Raises:

ValueError – If backend is not a supported backend name.

Return type:

bool

httk.core.crypto.ed25519_generate_seed()[source]

Generate a standard 32-byte Ed25519 private seed.

Returns:

A newly generated private seed.

Return type:

bytes

httk.core.crypto.ed25519_public_key(seed, *, backend=None)[source]

Derive the public key for a private seed.

Parameters:
  • seed (bytes) – 32-byte Ed25519 private seed.

  • backend (str | None) – Backend name, "auto", or None to select the accelerated backend when available.

Returns:

The 32-byte Ed25519 public key.

Raises:
  • ValueError – If seed is not exactly 32 bytes or backend is unsupported.

  • ImportError – If the requested cryptography backend is unavailable.

Return type:

bytes

httk.core.crypto.ed25519_sign(seed, message, *, backend=None)[source]

Return an RFC 8032 Ed25519 signature for message.

Parameters:
  • seed (bytes) – 32-byte Ed25519 private seed.

  • message (bytes) – Bytes to sign.

  • backend (str | None) – Backend name, "auto", or None to select the accelerated backend when available.

Returns:

The 64-byte Ed25519 signature.

Raises:
  • ValueError – If seed is not exactly 32 bytes or backend is unsupported.

  • ImportError – If the requested cryptography backend is unavailable.

Return type:

bytes

httk.core.crypto.ed25519_verify(public_key, message, signature, *, backend=None)[source]

Return whether signature is valid, treating malformed input as false.

Parameters:
  • public_key (bytes) – 32-byte Ed25519 public key.

  • message (bytes) – Bytes whose signature is being checked.

  • signature (bytes) – 64-byte Ed25519 signature.

  • backend (str | None) – Backend name, "auto", or None to select the accelerated backend when available.

Returns:

Whether the signature verifies for the public key and message.

Raises:
  • ValueError – If backend is unsupported.

  • ImportError – If the requested cryptography backend is unavailable.

Return type:

bool