Spectre.Definition.Ref (Spectre v0.3.0)

Copy Markdown View Source

Content-addressed identity of one canonical Spectre Definition.

A Ref proves integrity of canonical bytes. It does not prove publisher identity, trust, approval, or current authority.

Summary

Functions

Builds the Ref for a canonical Definition.

Parses the stable sha256:<hex> representation.

Returns the stable textual representation of a Ref.

Checks the shape and supported algorithm of a Definition Ref.

Verifies that a Ref addresses the supplied canonical Definition.

Types

t()

@type t() :: %Spectre.Definition.Ref{
  algorithm: :sha256,
  canonicalization_version: pos_integer(),
  contract_version: pos_integer(),
  digest: String.t()
}

Functions

new(canonical)

@spec new(Spectre.Definition.Canonical.t()) :: t()

Builds the Ref for a canonical Definition.

parse(value, opts \\ [])

@spec parse(
  String.t(),
  keyword()
) :: {:ok, t()} | {:error, term()}

Parses the stable sha256:<hex> representation.

to_string(ref)

@spec to_string(t()) :: String.t()

Returns the stable textual representation of a Ref.

valid?(ref)

@spec valid?(term()) :: boolean()

Checks the shape and supported algorithm of a Definition Ref.

verify(expected, canonical)

@spec verify(t(), Spectre.Definition.Canonical.t()) :: :ok | {:error, term()}

Verifies that a Ref addresses the supplied canonical Definition.