Skip to content
Juvix imports

module arch.node.engines.commitment;

import prelude open;
import arch.node.types.engine open;
import arch.node.engines.commitment_config open public;
import arch.node.engines.commitment_messages open public;
import arch.node.engines.commitment_environment open public;
import arch.node.engines.commitment_behaviour open public;
import arch.node.types.anoma as Anoma open;

open commitment_config_example;
open commitment_environment_example;

Commitment Engine

The Commitment Engine provides digital signature services for a specific identity within Anoma. It acts as a secure mediator that can generate cryptographic signatures (see Commitment) when given data to sign (Signable), while keeping the signing keys secure and unexposed.

When users request a signature through the engine (via a MsgCommitmentRequest message), it validates their authorisation and returns a cryptographic signature (via a MsgCommitmentResponse message) that proves the identity authorised that specific data.

In Anoma, Commitment Engines are only spawned by Identity Management Engines during identity creation or connection, and only users with the engine reference can request signatures. This controlled access ensures that signatures can only be generated by authorised parties while maintaining the security of the underlying signing keys.

Components

The type for a commitment engine

CommitmentEngine : Type :=
Engine
CommitmentCfg
CommitmentLocalState
CommitmentMailboxState
CommitmentTimerHandle
CommitmentActionArguments
Anoma.Msg
Anoma.Cfg
Anoma.Env;

Example of a commitment engine

exampleCommitmentEngine : CommitmentEngine :=
mkEngine@{
cfg := commitmentCfg;
env := commitmentEnv;
behaviour := commitmentBehaviour;
};

where commitmentCfg is defined as follows:

commitmentCfg : EngineCfg CommitmentCfg :=
mkEngineCfg@{
node := Curve25519PubKey "0xabcd1234";
name := "commitment";
cfg :=
mkCommitmentCfg@{
signer :=
mkSigner@{
sign := \{_ x := Ed25519Signature "0xabcd1234"};
};
backend := BackendLocalMemory;
};
};

commitmentEnv is defined as follows:

axiom dummyExternalIdentity : ExternalIdentity;

axiom dummyIDBackend : Backend;

axiom dummySigningKey : SigningKey;

commitmentEnv : CommitmentEnv :=
mkEngineEnv@{
localState := unit;
mailboxCluster := Map.empty;
acquaintances := Set.empty;
timers := [];
};

and commitmentBehaviour is defined as follows:

commitmentBehaviour : CommitmentBehaviour :=
mkEngineBehaviour@{
guards := First [commitGuard];
};