Runic.Identity (Runic v0.1.0-alpha.10)

Copy Markdown View Source

A versioned, domain-separated content identity.

Identities contain the complete scheme and domain alongside the digest. Two equal digest byte strings in different domains are therefore different keys. Use digest/2 for canonical identity documents and derive/2 for identities derived from ordered causal coordinates.

Summary

Types

A registered identity domain.

t()

Functions

Derives an identity from an ordered collection of identities and scalars.

Builds a SHA-256 identity from a canonical identity document.

Builds an identity from bytes already encoded with the canonical codec.

Returns the registered identity domains.

Builds an identity from a value's explicit portable projection.

Returns a bounded display string. It must not be used for lookup.

Returns the compact binary form used inside canonical identity documents.

Returns the full tagged text representation of an identity.

Verifies that an identity document reproduces the expected identity.

Verifies an identity document, raising on mismatch.

Types

domain()

@type domain() ::
  :component_definition
  | :node_occurrence
  | :connection_definition
  | :workflow_artifact
  | :payload
  | :fact_content
  | :fact_occurrence
  | :execution
  | :input_command
  | :activation
  | :attempt
  | :transaction
  | :event
  | :event_data
  | :snapshot
  | :segment

A registered identity domain.

t()

@type t() :: %Runic.Identity{
  digest: <<_::256>>,
  domain: domain(),
  scheme: :sha256,
  version: 1
}

Functions

derive(domain, coordinates)

@spec derive(domain(), term()) :: t()

Derives an identity from an ordered collection of identities and scalars.

digest(domain, identity_document)

@spec digest(domain(), term()) :: t()

Builds a SHA-256 identity from a canonical identity document.

digest_bytes(domain, canonical_bytes)

@spec digest_bytes(domain(), binary()) :: t()

Builds an identity from bytes already encoded with the canonical codec.

domains()

@spec domains() :: [domain()]

Returns the registered identity domains.

project(domain, value)

@spec project(domain(), term()) :: t()

Builds an identity from a value's explicit portable projection.

short_string(identity, length \\ 20)

@spec short_string(t(), pos_integer()) :: String.t()

Returns a bounded display string. It must not be used for lookup.

to_binary(identity)

@spec to_binary(t()) :: binary()

Returns the compact binary form used inside canonical identity documents.

to_string(identity)

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

Returns the full tagged text representation of an identity.

verify(expected, identity_document)

@spec verify(t(), term()) :: :ok | {:error, Runic.Identity.IntegrityError.t()}

Verifies that an identity document reproduces the expected identity.

verify!(expected, identity_document)

@spec verify!(t(), term()) :: :ok

Verifies an identity document, raising on mismatch.