Notary Module#
- exception rizemind.authentication.notary.model.mod.MissingConfigNotaryModError[source]#
Bases:
RizemindExceptionRaised when the configuration for the notary mod is missing from the context.
This error indicates that the notary mod was initialized or executed without its required configuration being available in the context.
- rizemind.authentication.notary.model.mod.model_notary_mod(msg: Message, ctx: Context, call_next: Callable[[Message, Context], Message]) Message[source]#
Flower client mod for model parameter authentication and signing.
This mod intercepts TRAIN messages to verify incoming model parameters and sign outgoing model parameters using EIP-712 signatures. It ensures that models can be authenticated given the swarm’s aggregator registry.
- Parameters:
msg – The Flower message containing the model parameters and metadata.
ctx – The Flower context containing configuration for authentication,
SwarmConfig (including)
Web3Config
AccountConfig. (and)
call_next – The next callable in the chain to process the message.
- Raises:
MissingConfigNotaryModError – When required configuration (SwarmConfig,
Web3Config, or AccountConfig) is not found in the context. –
RizemindException – When the recovered signer is not a valid aggregator
for the given round. –
- Returns:
- The processed message with signed parameters for TRAIN messages.
For non-TRAIN messages, returns the unmodified reply from call_next.
Notes
- On incoming TRAIN messages, verifies the model signature and checks
if the signer is a valid aggregator. This signer must be the aggregator sending the parameters.
- On outgoing TRAIN responses, signs the model parameters with the
client’s account and includes the signature in the metrics.
Logs warnings when verification fails and errors when signing fails.
Non-TRAIN messages pass through without modification.