keystore

package
v2.9.1-libocrbump-2024... Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2024 License: MIT Imports: 34 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrLocked      = errors.New("Keystore is locked")
	ErrKeyNotFound = errors.New("Key not found")
	ErrKeyExists   = errors.New("Key already exists")
)
View Source
var ErrCSAKeyExists = errors.New("can only have 1 CSA key")

ErrCSAKeyExists describes the error when the CSA key already exists

View Source
var (
	ErrMissingVRFKey = errors.New("unable to find VRF key")
)
View Source
var (
	ErrNoP2PKey = errors.New("no p2p keys exist")
)

Functions

func GetFieldNameForKey

func GetFieldNameForKey(unknownKey Key) (string, error)

func NewInMemory added in v2.7.0

func NewInMemory(db *sqlx.DB, scryptParams utils.ScryptParams, lggr logger.Logger, cfg pg.QConfig) *master

NewInMemory sets up a keystore which NOOPs attempts to access the `encrypted_key_rings` table. Accessing `evm.key_states` will still hit the DB.

func NewORM

func NewORM(db *sqlx.DB, lggr logger.Logger, cfg pg.QConfig) ksORM

Types

type CSA

type CSA interface {
	Get(id string) (csakey.KeyV2, error)
	GetAll() ([]csakey.KeyV2, error)
	Create() (csakey.KeyV2, error)
	Add(key csakey.KeyV2) error
	Delete(id string) (csakey.KeyV2, error)
	Import(keyJSON []byte, password string) (csakey.KeyV2, error)
	Export(id string, password string) ([]byte, error)
	EnsureKey() error
}

type CSAKeystoreInterface interface {

type Cosmos

type Cosmos interface {
	Get(id string) (cosmoskey.Key, error)
	GetAll() ([]cosmoskey.Key, error)
	Create() (cosmoskey.Key, error)
	Add(key cosmoskey.Key) error
	Delete(id string) (cosmoskey.Key, error)
	Import(keyJSON []byte, password string) (cosmoskey.Key, error)
	Export(id string, password string) ([]byte, error)
	EnsureKey() error
}

type CosmosLoopKeystore added in v2.6.0

type CosmosLoopKeystore struct {
	Cosmos
}

CosmosLoopKeystore implements the github.com/smartcontractkit/chainlink-common/pkg/loop.Keystore interface and handles signing for Cosmos messages.

func (*CosmosLoopKeystore) Accounts added in v2.6.0

func (lk *CosmosLoopKeystore) Accounts(ctx context.Context) ([]string, error)

func (*CosmosLoopKeystore) Sign added in v2.6.0

func (lk *CosmosLoopKeystore) Sign(ctx context.Context, id string, hash []byte) ([]byte, error)

type DKGEncrypt

type DKGEncrypt interface {
	Get(id string) (dkgencryptkey.Key, error)
	GetAll() ([]dkgencryptkey.Key, error)
	Create() (dkgencryptkey.Key, error)
	Add(key dkgencryptkey.Key) error
	Delete(id string) (dkgencryptkey.Key, error)
	Import(keyJSON []byte, password string) (dkgencryptkey.Key, error)
	Export(id string, password string) ([]byte, error)
	EnsureKey() error
}

DKGEncrypt provides encryption keys for the DKG.

type DKGSign

type DKGSign interface {
	Get(id string) (dkgsignkey.Key, error)
	GetAll() ([]dkgsignkey.Key, error)
	Create() (dkgsignkey.Key, error)
	Add(key dkgsignkey.Key) error
	Delete(id string) (dkgsignkey.Key, error)
	Import(keyJSON []byte, password string) (dkgsignkey.Key, error)
	Export(id string, password string) ([]byte, error)
	EnsureKey() error
}

DKGSign provides signing keys for the DKG.

type DefaultEVMChainIDFunc

type DefaultEVMChainIDFunc func() (defaultEVMChainID *big.Int, err error)

DefaultEVMChainIDFunc is a func for getting a default evm chain ID - necessary because it is lazily evaluated

type Eth

type Eth interface {
	Get(id string) (ethkey.KeyV2, error)
	GetAll() ([]ethkey.KeyV2, error)
	Create(chainIDs ...*big.Int) (ethkey.KeyV2, error)
	Delete(id string) (ethkey.KeyV2, error)
	Import(keyJSON []byte, password string, chainIDs ...*big.Int) (ethkey.KeyV2, error)
	Export(id string, password string) ([]byte, error)

	Enable(address common.Address, chainID *big.Int, qopts ...pg.QOpt) error
	Disable(address common.Address, chainID *big.Int, qopts ...pg.QOpt) error
	Add(address common.Address, chainID *big.Int, qopts ...pg.QOpt) error

	EnsureKeys(chainIDs ...*big.Int) error
	SubscribeToKeyChanges() (ch chan struct{}, unsub func())

	SignTx(fromAddress common.Address, tx *types.Transaction, chainID *big.Int) (*types.Transaction, error)

	EnabledKeysForChain(chainID *big.Int) (keys []ethkey.KeyV2, err error)
	GetRoundRobinAddress(chainID *big.Int, addresses ...common.Address) (address common.Address, err error)
	CheckEnabled(address common.Address, chainID *big.Int) error

	GetState(id string, chainID *big.Int) (ethkey.State, error)
	GetStatesForKeys([]ethkey.KeyV2) ([]ethkey.State, error)
	GetStateForKey(ethkey.KeyV2) (ethkey.State, error)
	GetStatesForChain(chainID *big.Int) ([]ethkey.State, error)
	EnabledAddressesForChain(chainID *big.Int) (addresses []common.Address, err error)

	XXXTestingOnlySetState(ethkey.State)
	XXXTestingOnlyAdd(key ethkey.KeyV2)
}

Eth is the external interface for EthKeyStore

type Key

type Key interface {
	ID() string
}

type KeyNotFoundError

type KeyNotFoundError struct {
	ID      string
	KeyType string
}

KeyNotFoundError is returned when we don't find a requested key

func (KeyNotFoundError) Error

func (e KeyNotFoundError) Error() string

type LegacyKeyStorage

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

func (*LegacyKeyStorage) StoreUnsupported

func (k *LegacyKeyStorage) StoreUnsupported(allRawKeysJson []byte, keyRing *keyRing) error

StoreUnsupported will store the raw keys that no longer have support in the node it will check if raw json contains keys that have not been added to the key ring and stores them internally

func (*LegacyKeyStorage) UnloadUnsupported

func (k *LegacyKeyStorage) UnloadUnsupported(supportedRawKeyRingJson []byte) ([]byte, error)

UnloadUnsupported will inject the unsupported keys into the raw key ring json

type Master

type Master interface {
	CSA() CSA
	DKGSign() DKGSign
	DKGEncrypt() DKGEncrypt
	Eth() Eth
	OCR() OCR
	OCR2() OCR2
	P2P() P2P
	Solana() Solana
	Cosmos() Cosmos
	StarkNet() StarkNet
	VRF() VRF
	Unlock(password string) error
	IsEmpty() (bool, error)
}

func New

func New(db *sqlx.DB, scryptParams utils.ScryptParams, lggr logger.Logger, cfg pg.QConfig) Master

type OCR

type OCR interface {
	Get(id string) (ocrkey.KeyV2, error)
	GetAll() ([]ocrkey.KeyV2, error)
	Create() (ocrkey.KeyV2, error)
	Add(key ocrkey.KeyV2) error
	Delete(id string) (ocrkey.KeyV2, error)
	Import(keyJSON []byte, password string) (ocrkey.KeyV2, error)
	Export(id string, password string) ([]byte, error)
	EnsureKey() error
}

type OCR2

type OCR2 interface {
	Get(id string) (ocr2key.KeyBundle, error)
	GetAll() ([]ocr2key.KeyBundle, error)
	GetAllOfType(chaintype.ChainType) ([]ocr2key.KeyBundle, error)
	Create(chaintype.ChainType) (ocr2key.KeyBundle, error)
	Add(key ocr2key.KeyBundle) error
	Delete(id string) error
	Import(keyJSON []byte, password string) (ocr2key.KeyBundle, error)
	Export(id string, password string) ([]byte, error)
	EnsureKeys(enabledChains ...chaintype.ChainType) error
}

type ORM added in v2.7.0

type ORM interface {
	// contains filtered or unexported methods
}

type P2P

type P2P interface {
	Get(id p2pkey.PeerID) (p2pkey.KeyV2, error)
	GetAll() ([]p2pkey.KeyV2, error)
	Create() (p2pkey.KeyV2, error)
	Add(key p2pkey.KeyV2) error
	Delete(id p2pkey.PeerID) (p2pkey.KeyV2, error)
	Import(keyJSON []byte, password string) (p2pkey.KeyV2, error)
	Export(id p2pkey.PeerID, password string) ([]byte, error)
	EnsureKey() error

	GetOrFirst(id p2pkey.PeerID) (p2pkey.KeyV2, error)
}

type Solana

type Solana interface {
	Get(id string) (solkey.Key, error)
	GetAll() ([]solkey.Key, error)
	Create() (solkey.Key, error)
	Add(key solkey.Key) error
	Delete(id string) (solkey.Key, error)
	Import(keyJSON []byte, password string) (solkey.Key, error)
	Export(id string, password string) ([]byte, error)
	EnsureKey() error
	Sign(ctx context.Context, id string, msg []byte) (signature []byte, err error)
}

type SolanaSigner added in v2.1.0

type SolanaSigner struct {
	Solana
}

SolanaSigner adapts Solana to loop.Keystore.

func (*SolanaSigner) Accounts added in v2.1.0

func (s *SolanaSigner) Accounts(ctx context.Context) (accounts []string, err error)

type StarkNet

type StarkNet interface {
	Get(id string) (starkkey.Key, error)
	GetAll() ([]starkkey.Key, error)
	Create() (starkkey.Key, error)
	Add(key starkkey.Key) error
	Delete(id string) (starkkey.Key, error)
	Import(keyJSON []byte, password string) (starkkey.Key, error)
	Export(id string, password string) ([]byte, error)
	EnsureKey() error
}

type StarknetLooppSigner added in v2.3.0

type StarknetLooppSigner struct {
	StarkNet
}

StarknetLooppSigner implements github.com/smartcontractkit/chainlink-common/pkg/loop.Keystore interface and the requirements of signature d/encoding of the github.com/smartcontractkit/chainlink-starknet/relayer/pkg/chainlink/txm.NewKeystoreAdapter

func (*StarknetLooppSigner) Accounts added in v2.3.0

func (lk *StarknetLooppSigner) Accounts(ctx context.Context) ([]string, error)

TODO what is this supposed to return for starknet?

func (*StarknetLooppSigner) Sign added in v2.3.0

func (lk *StarknetLooppSigner) Sign(ctx context.Context, id string, hash []byte) ([]byte, error)

Sign implements loop.Keystore hash is expected to be the byte representation of big.Int the returned []byte is an encoded github.com/smartcontractkit/chainlink-common/pkg/loop/adapters/starknet.Signature. this enables compatibility with github.com/smartcontractkit/chainlink-starknet/relayer/pkg/chainlink/txm.NewKeystoreAdapter

type VRF

type VRF interface {
	Get(id string) (vrfkey.KeyV2, error)
	GetAll() ([]vrfkey.KeyV2, error)
	Create() (vrfkey.KeyV2, error)
	Add(key vrfkey.KeyV2) error
	Delete(id string) (vrfkey.KeyV2, error)
	Import(keyJSON []byte, password string) (vrfkey.KeyV2, error)
	Export(id string, password string) ([]byte, error)

	GenerateProof(id string, seed *big.Int) (vrfkey.Proof, error)
}

Jump to

Keyboard shortcuts

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