controller

package
v0.6.0-beta.11 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 24, 2023 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const PrimaryAccountName = "primary"

Variables

View Source
var ControllerTypeSystem = schema.MustTypeSystem(
	schema.SpawnStruct("keyShare",
		[]schema.StructField{
			schema.SpawnStructField("bytes", "Bytes", false, false),
			schema.SpawnStructField("name", "String", false, false),
			schema.SpawnStructField("lastUsed", "Int", false, false),
		},
		schema.SpawnStructRepresentationMap(nil),
	),
	schema.SpawnBytes("Bytes"),
	schema.SpawnString("String"),
	schema.SpawnInt("Int"),
)

Functions

func LoadKeySharePubKeyFromConfigBytes

func LoadKeySharePubKeyFromConfigBytes(bytes []byte) (*crypto.PubKey, error)

LoadKeySharePubKeyFromConfigBytes loads KeyShare from a cmp.Config buffer.

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

	// GetAuthInfo creates an AuthInfo for a transaction
	GetAuthInfo(gas sdk.Coins) (*txtypes.AuthInfo, error)

	// ListKeyshares returns a list of keyshares for the account
	ListKeyshares() ([]KeyShare, error)

	// MapKeyshares performs a function on each keyshare of the account
	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)

	// Type returns the type of the account
	Type() string

	// VerificationMethod returns the verification method for the account
	VerificationMethod(controller string) *types.VerificationMethod

	// 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

func NewAccount

func NewAccount(kss []KeyShare, ct crypto.CoinType) Account

NewAccount creates a new account

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
	DidDocument() *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) 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)

	// 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 LoadController

func LoadController(ctx context.Context, credential *crypto.WebauthnCredential, didDoc *types.DidDocument) (Controller, error)

LoadController loads a controller from the given DID document using the underlying IPFS store

func NewController

func NewController(ctx context.Context, credential *crypto.WebauthnCredential) (Controller, error)

type FilterOptions

type FilterOptions struct {
	CoinType    crypto.CoinType
	AccountName *string
	Index       *int
}

! ||--------------------------------------------------------------------------------|| ! || Map & Slice Filtering || ! ||--------------------------------------------------------------------------------||

type Foobar

type Foobar struct {
	Foo string
	Bar string
}

type KeyShare

type KeyShare interface {
	// Base64 returns the base64 of the keyshare file - the marshalled cmp.Config
	Base64() string

	// Bytes returns the bytes of the keyshare file - the marshalled cmp.Config
	Bytes() []byte

	// Config returns the cmp.Config.
	Config() *cmp.Config

	// Did returns the cid of the keyshare
	Did() string

	// PartyID returns the party id based on the keyshare file name
	PartyID() crypto.PartyID

	// PubKey returns the public key of the keyshare
	PubKey() *crypto.PubKey

	// Encrypt checks if the file at current path is encrypted and if not, encrypts it.
	Encrypt(credential *crypto.WebauthnCredential) error

	// Encrypt checks if the file at current path is encrypted and if not, encrypts it.
	Decrypt(credential *crypto.WebauthnCredential) error

	// IsEncrypted checks if the file at current path is encrypted.
	IsEncrypted() bool
}

KeyShare is a type that interacts with a cmp.Config file located on disk.

func LoadKeyshareFromStore

func LoadKeyshareFromStore(key string, value interface{}) (KeyShare, error)

LoadKeyshareFromStore loads a keyshare from a store. The value can be a base64 encoded string or a []byte.

func NewKeyshare

func NewKeyshare(id string, bytes []byte, coinType crypto.CoinType, accName string) (KeyShare, error)

Keyshare name format is a DID did:{coin_type}:{account_address}#ks-{account_name}-{keyshare_name} did:{coin_type}:{account_address}#ks-{account_name}-{keyshare_name}

type KeyShareParseResult

type KeyShareParseResult struct {
	CoinType       crypto.CoinType
	AccountAddress string
	AccountName    string
	KeyShareName   string
}

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}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL