x/warden
Overview
The x/warden
module is a Cosmos SDK module allowing users to create and manage their Spaces and request Keychains to sign payloads.
This module implements Warden's core concepts, which you can find in our Glossary:
Concepts
Space
A Space is a collection of users (owners) that share a common set of Rules:
- Admin Rule: It's a applied to all admin operations such as adding or removing Space owners.
- Signing Rule: It's applied to all signature operations such as requesting a new key or signature.
- Default Rule: It's applied if no Rule is specified, allowing any operation if at least 1 of the Space owners approves it.
See also Glossary: Space.
Key
A Key is the public part of a key pair, which is stored on-chain. Every Key belongs to a certain Space.
Keys have unique identifiers used to refer to them when requesting a Keychain to sign a payload.
See also Glossary: Key.
Keychain
A Keychain fulfills key requests and signature requests from users. Optionally, it can set a fee for each request.
Keychains can be registered on-chain. Each Keychain has the following:
- A list of admins that can update the Keychain information
- A list of Writers – the only addresses authorized to send updates to requests
See also Glossary: Keychain, Request flow.
Analyzer
An Analyzer is a CosmWasm contract that can intercept a payload before it's signed by a Keychain. Using Analyzers allows Keychains to receive the final payload without the need to have any knowledge of its content.
This is what Analyzers can do:
- Extract payload metadata, which then can be referenced in Rule expressions
- Manipulate the payload before it's signed — for example, hash it following a specific algorithm
To illustrate this, it's possible to write an Ethereum Analyzer that will do the following:
- Extract information: the value being sent and the destination address
- Hash the payload using Ethereum's Keccak256 algorithm
You can learn more in the Analyzers section of this article.
State
The x/warden
module keeps the state of the following primary objects:
- Spaces
- Keys
- Keychains
- KeyRequests
- SignRequests
To manage this state, the module also keeps the following indexes:
- Keys by Space ID
- Spaces by owner address
Rules
The x/warden
module provides the following variables to be used in Rules:
warden.space.owners
: The list of Space ownerswarden.analyzers.<addr>.<name>
: The Analyzer name and address
Messages
MsgNewSpace
Creates a new Space, optionally specifying the following:
- The Admin Rule
- The Signing Rule
- Additional owners
Note: If not specified, both the Admin and Signing Rules are set to the default Rule allowing any operation if at least 1 of the Space owners approves it.
This message is expected to fail in the following cases:
- An owner is specified twice.
MsgNewKeychain
Creates a new Keychain, specifying the following:
- A human-readable description
- A key request fee (optionally)
- A signature request fee (optionally)
Note: The Keychain creator will be its first admin.
This message is expected to fail in the following cases:
- The description is empty.