AshHooks.Custody.PublicKey (AshHooks v3.3.0)

Copy Markdown View Source

A pinned sender public key with its host-selected asymmetric algorithm.

Unlike AshHooks.Custody.Key, this value contains public verification material and never calls a custodian. Providers receive this struct rather than untyped bytes. HMAC verifiers refuse it with KeyKindMismatch.

new/2 validates the key before a source is created or updated. Kinds are {:standard_webhooks, :v1a} for a whpk_ Ed25519 key, :ed25519, :rsa_pkcs1_sha256, :rsa_pkcs1_sha384, :rsa_pkcs1_sha512, :rsa_pss_sha256, :rsa_pss_sha384, :rsa_pss_sha512, :ecdsa_p256_sha256, and :ecdsa_p384_sha384. The kind pins the digest, RSA padding, and ECDSA curve as well as the key family.

Summary

Functions

Validates public verification material for one of the supported asymmetric kinds listed in the module contract. Returns {:ok, public_key} or {:error, %AshHooks.Errors.Invalid.KeyKindMismatch{}} when the kind or material is invalid or does not match.

Types

kind()

@type kind() ::
  {:standard_webhooks, :v1a}
  | :ed25519
  | :rsa_pkcs1_sha256
  | :rsa_pkcs1_sha384
  | :rsa_pkcs1_sha512
  | :rsa_pss_sha256
  | :rsa_pss_sha384
  | :rsa_pss_sha512
  | :ecdsa_p256_sha256
  | :ecdsa_p384_sha384

t()

@type t() :: %AshHooks.Custody.PublicKey{key: term(), kind: kind()}

Functions

new(key, kind)

@spec new(term(), term()) :: {:ok, t()} | {:error, struct()}

Validates public verification material for one of the supported asymmetric kinds listed in the module contract. Returns {:ok, public_key} or {:error, %AshHooks.Errors.Invalid.KeyKindMismatch{}} when the kind or material is invalid or does not match.