keys

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2022 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package keys provides key management functions.

Index

Constants

View Source
const (
	AccountKeyTypeLocal     = "local"
	AccountKeyTypeGoogleKMS = "google_kms"
	AccountKeyTypeAWSKMS    = "aws_kms"
)

Variables

View Source
var ErrAdminProposalKeyCountMismatch = errors.New("admin-proposal-key count mismatch")

Functions

This section is empty.

Types

type Authorizer

type Authorizer struct {
	Address flow.Address
	Key     *flow.AccountKey
	Signer  crypto.Signer
}

Authorizer groups the necessary items for transaction signing.

func (*Authorizer) Equals

func (a *Authorizer) Equals(t Authorizer) bool

type GormStore

type GormStore struct {
	// contains filtered or unexported fields
}

func (*GormStore) AccountKey

func (s *GormStore) AccountKey(address string) (Storable, error)

func (*GormStore) DeleteAllProposalKeys

func (s *GormStore) DeleteAllProposalKeys() error

func (*GormStore) InsertProposalKey

func (s *GormStore) InsertProposalKey(p ProposalKey) error

func (*GormStore) ProposalKeyCount added in v0.9.0

func (s *GormStore) ProposalKeyCount() (int64, error)

func (*GormStore) ProposalKeyIndex added in v0.9.0

func (s *GormStore) ProposalKeyIndex(limitKeyCount int) (int, error)

type Manager

type Manager interface {
	// Generate generates a new Key using provided key index and weight.
	Generate(ctx context.Context, keyIndex, weight int) (*flow.AccountKey, *Private, error)
	// GenerateDefault generates a new Key using application defaults.
	GenerateDefault(context.Context) (*flow.AccountKey, *Private, error)
	// Save is responsible for converting an "in flight" key to a storable key.
	Save(Private) (Storable, error)
	// Load is responsible for converting a storable key to an "in flight" key.
	Load(Storable) (Private, error)
	// AdminAuthorizer returns an Authorizer for the applications admin account.
	AdminAuthorizer(context.Context) (Authorizer, error)
	// UserAuthorizer returns an Authorizer for the given address.
	UserAuthorizer(ctx context.Context, address flow.Address) (Authorizer, error)
	// CheckAdminProposalKeyCount checks if admin proposal keys have been correctly initiated (counts match).
	CheckAdminProposalKeyCount(ctx context.Context) error
	// InitAdminProposalKeys will init the admin proposal keys in the database
	// and return current count.
	InitAdminProposalKeys(ctx context.Context) (uint16, error)
	// AdminProposalKey returns Authorizer to be used as proposer.
	AdminProposalKey(ctx context.Context) (Authorizer, error)
}

Manager provides the functions needed for key management.

type Private

type Private struct {
	Index    int                       `json:"index"`
	Type     string                    `json:"type"`
	Value    string                    `json:"-"`
	SignAlgo crypto.SignatureAlgorithm `json:"-"`
	HashAlgo crypto.HashAlgorithm      `json:"-"`
}

Private is an "in flight" account private key meaning its Value should be the actual private key or resource id (unencrypted).

type ProposalKey

type ProposalKey struct {
	ID        int `json:"-" gorm:"primaryKey"`
	KeyIndex  int `gorm:"unique"`
	CreatedAt time.Time
	UpdatedAt time.Time
}

func (ProposalKey) TableName

func (ProposalKey) TableName() string

type Storable

type Storable struct {
	ID             int            `json:"-" gorm:"primaryKey"`
	AccountAddress string         `json:"-" gorm:"index"`
	Index          int            `json:"index" gorm:"index"`
	Type           string         `json:"type"`
	Value          []byte         `json:"-"`
	PublicKey      string         `json:"publicKey"`
	SignAlgo       string         `json:"signAlgo"`
	HashAlgo       string         `json:"hashAlgo"`
	CreatedAt      time.Time      `json:"createdAt"`
	UpdatedAt      time.Time      `json:"updatedAt"`
	DeletedAt      gorm.DeletedAt `json:"-" gorm:"index"`
}

Storable struct represents a storable account private key. Storable.Value is an encrypted byte representation of the actual private key when using local key management or resource id when using a remote key management system (e.g. Google KMS).

func (Storable) TableName

func (Storable) TableName() string

Rename the database table to improve database readability

type Store

type Store interface {
	AccountKey(address string) (Storable, error)
	ProposalKeyIndex(limitKeyCount int) (int, error)
	ProposalKeyCount() (int64, error)
	InsertProposalKey(proposalKey ProposalKey) error
	DeleteAllProposalKeys() error
}

Store is the interface required by key manager for data storage.

func NewGormStore

func NewGormStore(db *gorm.DB) Store

Directories

Path Synopsis
Package aws provides functions for key and signer generation in AWS KMS.
Package aws provides functions for key and signer generation in AWS KMS.
Package basic provides straightforward implementation for key management.
Package basic provides straightforward implementation for key management.
Package encryption provides encryption and decryption.
Package encryption provides encryption and decryption.
Package google provides functions for key and signer generation in Google KMS.
Package google provides functions for key and signer generation in Google KMS.
Package local provides functions for local key and signer generation.
Package local provides functions for local key and signer generation.

Jump to

Keyboard shortcuts

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