mcl_core_identity (mcl_core v1.0.0)
View SourceIdentity, seed and realm resolution for the mesh pool mcl_core_sup supervises alongside this gen_server.
11.x model (the PQ port): the service identity is a macula_node_keys node key (purpose identity, pq_hybrid, puzzle-hardened at the fleet's difficulty) — the same thing a station or pool identity is. The 10.x Ed25519 keypair and the realm-signed service cert are gone with the 11.x wire: realm membership is what the D25 authorization records and the pool's realm_trust keys attest, not a TLS cert chain.
Seeds must carry the station node ids they expect: the 11.x peering layer refuses a client dial without an expected_node_id pin (D5). MACULA_STATION_SEEDS (comma-separated hosts, ports default 4433) pairs index-for-index with MACULA_STATION_NODE_IDS (comma-separated 64-hex node ids); a seed without a matching pin is refused at boot — a silent unpinned seed would be a dial that can never connect.
Connect-degradation: with no seeds configured, mcl_core_sup never starts a mesh pool child at all, and macula_client/0 returns {error, no_client} forever — consumers fall back to no-op behaviour. The service stays up either way.
UNLESS THE SERVICE SAYS THE MESH IS REQUIRED. {mesh, required} (the mcl_service template sets it; the library default is optional) means the service exists to answer on the mesh, so booting it without its realm, its realm key or its pinned seeds is refused, naming every missing setting at once: {mcl_core_mesh_unconfigured, #{missing => [<<"MCL_REALM">>, ...]}}. A value relx expanded to nothing, or left unexpanded, counts as missing. Whatever the mode, a realm that is set but is neither 32 bytes nor 64 hex is refused by name.
ON A LAN MEMBER THE MESH IS THE BRIDGE'S (mcl-core#7). A node whose mcl_core_bridge:role/0 is member runs no pool, so {mesh, required} asks nothing of it: the bridge node is the one that must be configured.
The pool itself is not this gen_server's state: it is an ordinary supervised sibling (mcl_core_sup, restart => permanent), started by mcl_core_bridge:start_mesh_pool/0 strictly after this gen_server has loaded the key, so identity_key/0 is read back rather than re-loaded.
Summary
Functions
Whether Org can be a service's org: a wire segment, the Org in Org/Name. Refused: _ (what org/0 answers when none is configured), empty, an environment variable relx left unexpanded ("${MCL_ORG}"), and anything else a procedure name cannot start with. mcl_core:boot/2 refuses to boot a service on the refusal.
The service's stable signing node key, {error, no_identity_key} when running on an ephemeral identity, or {error, not_booted} when called before this gen_server has started.
The mesh pool handle, or {error, no_client} when this node runs none (mcl_core_bridge:macula_client/0).
This service's org name (the <org> segment of its procedure URIs). Always a binary — <<"_">> both when unconfigured and when called before this gen_server has started.
The 32-byte realm tag, {error, no_realm} when unset, or {error, not_booted} when called before this gen_server has started.
Functions
Whether Org can be a service's org: a wire segment, the Org in Org/Name. Refused: _ (what org/0 answers when none is configured), empty, an environment variable relx left unexpanded ("${MCL_ORG}"), and anything else a procedure name cannot start with. mcl_core:boot/2 refuses to boot a service on the refusal.
-spec identity_key() -> {ok, macula_node_keys:node_key()} | {error, no_identity_key | not_booted}.
The service's stable signing node key, {error, no_identity_key} when running on an ephemeral identity, or {error, not_booted} when called before this gen_server has started.
-spec macula_client() -> {ok, pid()} | {error, no_client}.
The mesh pool handle, or {error, no_client} when this node runs none (mcl_core_bridge:macula_client/0).
-spec node_key_from({ok, file:filename_all()} | undefined) -> macula_node_keys:node_key() | undefined | {error, {identity_key_unloadable, file:filename_all(), term()}} | {error, {identity_key_unsaveable, file:filename_all(), term()}}.
-spec org() -> binary().
This service's org name (the <org> segment of its procedure URIs). Always a binary — <<"_">> both when unconfigured and when called before this gen_server has started.
-spec realm() -> {ok, <<_:256>>} | {error, no_realm | not_booted}.
The 32-byte realm tag, {error, no_realm} when unset, or {error, not_booted} when called before this gen_server has started.