Documentation
¶
Index ¶
- Variables
- func LoadKeySharePubKeyFromConfigBytes(bytes []byte) (*crypto.PubKey, error)
- func NewController(ctx context.Context, options ...Option) (Controller, Account, error)
- func ValidateWebauthnCredential(credential *crypto.WebauthnCredential) (*crypto.WebauthnCredential, error)
- type Account
- type Controller
- type FilterOptions
- type Foobar
- type KeyShare
- type KeyShareParseResult
- type Option
- type Options
Constants ¶
This section is empty.
Variables ¶
var PrimaryAccountName string = "primary"
Functions ¶
func LoadKeySharePubKeyFromConfigBytes ¶
LoadKeySharePubKeyFromConfigBytes loads KeyShare from a cmp.Config buffer.
func NewController ¶
func ValidateWebauthnCredential ¶
func ValidateWebauthnCredential(credential *crypto.WebauthnCredential) (*crypto.WebauthnCredential, error)
Types ¶
type Account ¶
type Account interface {
// Address returns the address of the account based on the coin type
Address() string
// CoinType returns the coin type of the account
CoinType() crypto.CoinType
// DID returns the DID of the account
Did() string
// Get the controller's DID document
DidDocument(controller string) *types.DidDocument
// GetAuthInfo creates an AuthInfo for a transaction
GetAuthInfo(gas sdk.Coins) (*txtypes.AuthInfo, error)
ListKeyshares() ([]KeyShare, error)
MapKeyshares(f func(KeyShare) error) error
// Name returns the name of the account
Name() string
// PartyIDs returns the party IDs of the account
PartyIDs() []crypto.PartyID
// Nonce returns the nonce of the account
Nonce() uint64
// IncrementNonce increments the nonce of the account
IncrementNonce()
// PubKey returns secp256k1 public key
PubKey() *crypto.PubKey
// Signs a message
Sign(bz []byte) ([]byte, error)
// ToProto returns the proto representation of the account
ToProto() *v1.Account
// ToStore returns the store representation of the account
ToStore() (string, []string)
// Type returns the type of the account
Type() string
// Verifies a signature
Verify(bz []byte, sig []byte) (bool, error)
// Lock locks the account
Lock(c *crypto.WebauthnCredential, rootDir string) error
// Unlock unlocks the account
Unlock(c *crypto.WebauthnCredential, rootDir string) error
}
Account is an interface for an account in the wallet
type Controller ¶
type Controller interface {
// Address returns the controller's address
Address() string
// Get the controller's DID
Did() string
// Get the controller's DID document
PrimaryIdentity() *types.DidDocument
// Blockchain returns the controller's blockchain identities
BlockchainIdentities() []*types.DidDocument
// Authorize the client to access the controller's account
Authorize(cred *crypto.WebauthnCredential) error
// CreateAccount creates a new account for the controller
CreateAccount(name string, coinType crypto.CoinType) (Account, error)
// GetAccount returns the controller's account
GetAccount(name string, coinType crypto.CoinType) (Account, error)
// ListAccounts returns the controller's accounts
ListAccounts(ct crypto.CoinType) ([]Account, error)
// ListLocalAccounts returns the controller's local accounts (WARNING: this is not secure)
ListLocalAccounts() []Account
// Sign signs a message with the controller's account
Sign(name string, coinType crypto.CoinType, msg []byte) ([]byte, error)
// Verify verifies a signature with the controller's account
Verify(name string, coinType crypto.CoinType, msg []byte, sig []byte) (bool, error)
}
func AuthorizeController ¶
func AuthorizeController(ctx context.Context, didDoc *types.DidDocument) (Controller, error)
AuthorizeController loads a controller from the given DID document using the underlying IPFS store
type FilterOptions ¶
! ||--------------------------------------------------------------------------------|| ! || Map & Slice Filtering || ! ||--------------------------------------------------------------------------------||
type KeyShare ¶
type KeyShare interface {
AccountName() string
Bytes() []byte
CoinType() crypto.CoinType
Config() *cmp.Config
Did() string
KeyShareName() string
PartyID() crypto.PartyID
PubKey() *crypto.PubKey
Encrypt(credential *crypto.WebauthnCredential) error
Decrypt(credential *crypto.WebauthnCredential) error
IsEncrypted() bool
}
KeyShare is a type that interacts with a cmp.Config file located on disk.
func LoadKeyshareFromStore ¶
LoadKeyshareFromStore loads a keyshare from a store. The value can be a base64 encoded string or a []byte.
type KeyShareParseResult ¶
type KeyShareParseResult struct {
}
func ParseKeyShareDid ¶
func ParseKeyShareDid(name string) (*KeyShareParseResult, error)
ParseKeyShareDid parses a keyshare DID into its components. The DID format is: did:{coin_type}:{account_address}#ks-{account_name}-{keyshare_name}
type Option ¶
type Option func(*Options)
func WithConfigHandlers ¶
func WithConfigHandlers(handlers ...mpc.OnConfigGenerated) Option
func WithInitialAccounts ¶
func WithWebauthnCredential ¶
func WithWebauthnCredential(cred *crypto.WebauthnCredential) Option
type Options ¶
type Options struct {
// The controller's DID document
GenerateInitialAccounts []string
// The controller's on config generated handler
OnConfigGenerated []mpc.OnConfigGenerated
// Credential to authorize the controller
WebauthnCredential *crypto.WebauthnCredential
}