Documentation ¶
Index ¶
- Variables
- func NewCSAORM(db *gorm.DB) csaORM
- type CSA
- type CSAKeystoreInterface
- type Eth
- func (ks *Eth) AddKey(key *ethkey.Key) error
- func (ks *Eth) AllKeys() (keys []ethkey.Key, err error)
- func (ks *Eth) CreateNewKey() (k ethkey.Key, err error)
- func (ks *Eth) EnsureFundingKey() (k ethkey.Key, didExist bool, err error)
- func (ks *Eth) ExportKey(address common.Address, newPassword string) ([]byte, error)
- func (ks *Eth) FundingKeys() (keys []ethkey.Key, err error)
- func (ks *Eth) GetKeyByAddress(address common.Address) (ethkey.Key, error)
- func (ks *Eth) GetRoundRobinAddress(whitelist ...common.Address) (address common.Address, err error)
- func (ks *Eth) HasDBSendingKeys() (exists bool, err error)
- func (ks *Eth) HasSendingKeyWithAddress(address common.Address) (bool, error)
- func (ks *Eth) ImportKey(keyJSON []byte, oldPassword string) (key ethkey.Key, err error)
- func (ks *Eth) ImportKeyFileToDB(keyPath string) (k ethkey.Key, err error)
- func (ks *Eth) KeyByAddress(address common.Address) (ethkey.Key, error)
- func (ks *Eth) RemoveKey(address common.Address, hardDelete bool) (removedKey ethkey.Key, err error)
- func (ks *Eth) SendingKeys() (keys []ethkey.Key, err error)
- func (ks *Eth) SignTx(fromAddress common.Address, tx *types.Transaction, chainID *big.Int) (*types.Transaction, error)
- func (ks *Eth) SubscribeToKeyChanges() (ch chan struct{}, unsubscribe func())
- func (ks *Eth) Unlock(password string) (merr error)
- type EthKeyStoreInterface
- type InMemoryKeyStore
- type Master
- type OCR
- func (ks OCR) ArchiveEncryptedOCRKeyBundle(key *ocrkey.EncryptedKeyBundle) error
- func (ks OCR) ArchiveEncryptedP2PKey(key *p2pkey.EncryptedP2PKey) error
- func (ks OCR) CreateEncryptedOCRKeyBundle(encryptedKey *ocrkey.EncryptedKeyBundle) error
- func (ks OCR) DecryptedOCRKey(hash models.Sha256Hash) (ocrkey.KeyBundle, bool)
- func (ks OCR) DecryptedP2PKey(peerID p2ppeer.ID) (p2pkey.Key, bool)
- func (ks OCR) DecryptedP2PKeys() (keys []p2pkey.Key)
- func (ks OCR) DeleteEncryptedOCRKeyBundle(key *ocrkey.EncryptedKeyBundle) error
- func (ks OCR) DeleteEncryptedP2PKey(key *p2pkey.EncryptedP2PKey) error
- func (ks OCR) ExportOCRKeyBundle(id models.Sha256Hash, newPassword string) ([]byte, error)
- func (ks OCR) ExportP2PKey(ID int32, newPassword string) ([]byte, error)
- func (ks OCR) FindEncryptedOCRKeyBundleByID(id models.Sha256Hash) (ocrkey.EncryptedKeyBundle, error)
- func (ks OCR) FindEncryptedOCRKeyBundles() (keys []ocrkey.EncryptedKeyBundle, err error)
- func (ks OCR) FindEncryptedP2PKeyByID(id int32) (*p2pkey.EncryptedP2PKey, error)
- func (ks OCR) FindEncryptedP2PKeys() (keys []p2pkey.EncryptedP2PKey, err error)
- func (ks OCR) GenerateEncryptedOCRKeyBundle() (ocrkey.KeyBundle, ocrkey.EncryptedKeyBundle, error)
- func (ks OCR) GenerateEncryptedP2PKey() (p2pkey.Key, p2pkey.EncryptedP2PKey, error)
- func (ks OCR) ImportOCRKeyBundle(keyJSON []byte, oldPassword string) (*ocrkey.EncryptedKeyBundle, error)
- func (ks OCR) ImportP2PKey(keyJSON []byte, oldPassword string) (*p2pkey.EncryptedP2PKey, error)
- func (ks *OCR) Unlock(password string) error
- func (ks OCR) UpsertEncryptedOCRKeyBundle(encryptedKey *ocrkey.EncryptedKeyBundle) error
- func (ks OCR) UpsertEncryptedP2PKey(k *p2pkey.EncryptedP2PKey) error
- type VRF
- func (ks *VRF) Archive(key secp256k1.PublicKey) (err error)
- func (ks *VRF) CreateAndUnlockWeakInMemoryEncryptedKeyXXXTestingOnly(phrase string) (*vrfkey.EncryptedVRFKey, error)
- func (ks *VRF) CreateKey() (secp256k1.PublicKey, error)
- func (ks *VRF) Delete(key secp256k1.PublicKey) (err error)
- func (ks *VRF) Export(pk secp256k1.PublicKey, newPassword string) ([]byte, error)
- func (ks *VRF) Forget(k secp256k1.PublicKey) error
- func (ks *VRF) GenerateProof(k secp256k1.PublicKey, seed *big.Int) (vrfkey.Proof, error)
- func (ks *VRF) Get(k ...secp256k1.PublicKey) ([]*vrfkey.EncryptedVRFKey, error)
- func (ks *VRF) GetSpecificKey(k secp256k1.PublicKey) (*vrfkey.EncryptedVRFKey, error)
- func (ks *VRF) Import(keyjson []byte, auth string) (vrfkey.EncryptedVRFKey, error)
- func (ks *VRF) ListKeys() (publicKeys []*secp256k1.PublicKey, err error)
- func (ks *VRF) ListKeysIncludingArchived() (publicKeys []*secp256k1.PublicKey, err error)
- func (ks *VRF) Store(key *vrfkey.PrivateKey, phrase string, scryptParams utils.ScryptParams) error
- func (ks *VRF) StoreInMemoryXXXTestingOnly(key *vrfkey.PrivateKey)
- func (ks *VRF) Unlock(password string) (keysUnlocked []secp256k1.PublicKey, merr error)
- type VRFORM
Constants ¶
This section is empty.
Variables ¶
var ErrAttemptToDeleteNonExistentKeyFromDB = errors.New("key is not present in DB")
ErrAttemptToDeleteNonExistentKeyFromDB is returned when Delete is asked to delete a key it can't find in the DB.
var (
ErrCSAKeyExists = errors.New("a csa key already exists")
)
var ErrKeyStoreLocked = errors.New("keystore is locked (HINT: did you forget to call keystore.Unlock?)")
ErrKeyStoreLocked is returned if you call a method that requires unlocked keys before you unlocked the keystore
var ErrMatchingVRFKey = errors.New(
`key with matching public key already stored in DB`)
ErrMatchingVRFKey is returned when Import attempts to import key with a PublicKey matching one already in the database
Functions ¶
Types ¶
type CSA ¶
type CSA struct {
// contains filtered or unexported fields
}
func (*CSA) CountCSAKeys ¶
CountCSAKeys counts the total number of CSA keys.
func (*CSA) CreateCSAKey ¶
CreateCSAKey creates a new CSA key
func (*CSA) ListCSAKeys ¶
ListCSAKeys lists all CSA keys.
func (*CSA) Unsafe_GetUnlockedPrivateKey ¶
Unsafe_GetUnlockedKey gets the unlocked private key in the keystore.
Ideally we do not want to expose private keys outside of the keystore, however we need to pass this priv key to the wsrpc library in order to dial the server. When wsrpc is updated to allow an interface to be passed in, we can implement that interface here to provide the private key.
type CSAKeystoreInterface ¶
type Eth ¶
type Eth struct {
// contains filtered or unexported fields
}
EthKeyStore manages an in-memory key list backed by a database table It never exposes private keys to consumers
func (*Eth) AddKey ¶
AddKey inserts the key to the database and adds it to the keystore's memory keys It modifies the given key (adding created_at etc)
func (*Eth) CreateNewKey ¶
CreateNewKey adds an account to the underlying geth keystore (which writes the file to disk) and inserts the new key to the database
func (*Eth) EnsureFundingKey ¶
EnsureFundingKey ensures that a funding account exists, and returns it
func (*Eth) FundingKeys ¶
FundingKeys will return only the keys that are is_funding=true
func (*Eth) GetKeyByAddress ¶
GetKeyByAddress returns the account matching the address provided, or an error if it is missing
func (*Eth) GetRoundRobinAddress ¶
func (ks *Eth) GetRoundRobinAddress(whitelist ...common.Address) (address common.Address, err error)
GetRoundRobinAddress gets the address of the "next" available sending key (i.e. the least recently used key) This takes an optional param for a slice of addresses it should pick from. Leave empty to pick from all addresses in the keystore.
func (*Eth) HasDBSendingKeys ¶
HasDBSendingKeys returns true if any key in the database is a sending key
func (*Eth) HasSendingKeyWithAddress ¶
HasSendingKeyWithAddress returns true if keystore has an account with the given address
func (*Eth) ImportKeyFileToDB ¶
ImportKeyFileToDB reads a file and writes the key to the database
func (*Eth) KeyByAddress ¶
KeyByAddress returns the key matching provided address
func (*Eth) RemoveKey ¶
func (ks *Eth) RemoveKey(address common.Address, hardDelete bool) (removedKey ethkey.Key, err error)
RemoveKey removes a key from the keystore If hard delete is set to true, removes the key from the database. If false, the key has its deleted_at set to a non-null value.
func (*Eth) SendingKeys ¶
SendingKeys will return only the keys that are is_funding=false
func (*Eth) SignTx ¶
func (ks *Eth) SignTx(fromAddress common.Address, tx *types.Transaction, chainID *big.Int) (*types.Transaction, error)
SignTx uses the unlocked account to sign the given transaction.
func (*Eth) SubscribeToKeyChanges ¶
func (ks *Eth) SubscribeToKeyChanges() (ch chan struct{}, unsubscribe func())
SubscribeToKeyChanges returns a channel that will fire if a key is added or removed Consumers should call unsubscribe when they are done to close the channel
type EthKeyStoreInterface ¶
type EthKeyStoreInterface interface { Unlock(password string) error // Requires Unlock CreateNewKey() (ethkey.Key, error) EnsureFundingKey() (key ethkey.Key, didExist bool, err error) ImportKey(keyJSON []byte, oldPassword string) (ethkey.Key, error) ExportKey(address common.Address, newPassword string) ([]byte, error) AddKey(key *ethkey.Key) error RemoveKey(address common.Address, hardDelete bool) (deletedKey ethkey.Key, err error) SubscribeToKeyChanges() (ch chan struct{}, unsub func()) SignTx(fromAddress common.Address, tx *types.Transaction, chainID *big.Int) (*types.Transaction, error) AllKeys() (keys []ethkey.Key, err error) SendingKeys() (keys []ethkey.Key, err error) FundingKeys() (keys []ethkey.Key, err error) KeyByAddress(address common.Address) (ethkey.Key, error) HasSendingKeyWithAddress(address common.Address) (bool, error) GetRoundRobinAddress(addresses ...common.Address) (address common.Address, err error) // Does not require Unlock HasDBSendingKeys() (bool, error) ImportKeyFileToDB(keyPath string) (ethkey.Key, error) }
EthKeyStoreInterface is the external interface for EthKeyStore
type InMemoryKeyStore ¶
type InMemoryKeyStore = map[secp256k1.PublicKey]vrfkey.PrivateKey
type OCR ¶
func (OCR) ArchiveEncryptedOCRKeyBundle ¶
func (ks OCR) ArchiveEncryptedOCRKeyBundle(key *ocrkey.EncryptedKeyBundle) error
ArchiveEncryptedOCRKeyBundle deletes the provided encrypted OCR key bundle
func (OCR) ArchiveEncryptedP2PKey ¶
func (ks OCR) ArchiveEncryptedP2PKey(key *p2pkey.EncryptedP2PKey) error
func (OCR) CreateEncryptedOCRKeyBundle ¶
func (ks OCR) CreateEncryptedOCRKeyBundle(encryptedKey *ocrkey.EncryptedKeyBundle) error
CreateEncryptedOCRKeyBundle creates an encrypted OCR private key record
func (OCR) DecryptedOCRKey ¶
func (OCR) DecryptedP2PKeys ¶
func (OCR) DeleteEncryptedOCRKeyBundle ¶
func (ks OCR) DeleteEncryptedOCRKeyBundle(key *ocrkey.EncryptedKeyBundle) error
DeleteEncryptedOCRKeyBundle deletes the provided encrypted OCR key bundle
func (OCR) DeleteEncryptedP2PKey ¶
func (ks OCR) DeleteEncryptedP2PKey(key *p2pkey.EncryptedP2PKey) error
func (OCR) ExportOCRKeyBundle ¶
ExportOCRKeyBundle exports an OCR key bundle from the database
func (OCR) ExportP2PKey ¶
ExportP2PKey exports a p2p key from the database
func (OCR) FindEncryptedOCRKeyBundleByID ¶
func (ks OCR) FindEncryptedOCRKeyBundleByID(id models.Sha256Hash) (ocrkey.EncryptedKeyBundle, error)
FindEncryptedOCRKeyBundleByID finds an EncryptedKeyBundle bundle by its ID
func (OCR) FindEncryptedOCRKeyBundles ¶
func (ks OCR) FindEncryptedOCRKeyBundles() (keys []ocrkey.EncryptedKeyBundle, err error)
FindEncryptedOCRKeyBundles finds all the encrypted OCR key records
func (OCR) FindEncryptedP2PKeyByID ¶
func (ks OCR) FindEncryptedP2PKeyByID(id int32) (*p2pkey.EncryptedP2PKey, error)
func (OCR) FindEncryptedP2PKeys ¶
func (ks OCR) FindEncryptedP2PKeys() (keys []p2pkey.EncryptedP2PKey, err error)
func (OCR) GenerateEncryptedOCRKeyBundle ¶
func (OCR) GenerateEncryptedP2PKey ¶
func (OCR) ImportOCRKeyBundle ¶
func (ks OCR) ImportOCRKeyBundle(keyJSON []byte, oldPassword string) (*ocrkey.EncryptedKeyBundle, error)
ImportOCRKeyBundle imports an OCR key bundle to the database
func (OCR) ImportP2PKey ¶
ImportP2PKey imports a p2p key to the database
func (OCR) UpsertEncryptedOCRKeyBundle ¶
func (ks OCR) UpsertEncryptedOCRKeyBundle(encryptedKey *ocrkey.EncryptedKeyBundle) error
func (OCR) UpsertEncryptedP2PKey ¶
func (ks OCR) UpsertEncryptedP2PKey(k *p2pkey.EncryptedP2PKey) error
type VRF ¶
type VRF struct {
// contains filtered or unexported fields
}
The VRF keystore tracks auxiliary VRF secret keys, and generates their VRF proofs
VRF proofs need access to the actual secret key, which geth does not expose. Similar to the way geth's KeyStore exposes signing capability, VRF exposes VRF proof generation without the caller needing explicit knowledge of the secret key.
func (*VRF) Archive ¶
Archive soft-deletes keys with this public key from the keystore and the DB, if present.
func (*VRF) CreateAndUnlockWeakInMemoryEncryptedKeyXXXTestingOnly ¶
func (ks *VRF) CreateAndUnlockWeakInMemoryEncryptedKeyXXXTestingOnly(phrase string) (*vrfkey.EncryptedVRFKey, error)
CreateAndUnlockWeakInMemoryEncryptedKeyXXXTestingOnly is for testing only! It returns an encrypted key which is fast to unlock, but correspondingly easy to brute force. It is not persisted to the DB, because no one should be keeping such keys lying around.
func (*VRF) CreateKey ¶
CreateKey returns a public key which is immediately unlocked in memory, and saved in DB encrypted with the password.
func (*VRF) Delete ¶
Delete removes keys with this public key from the keystore and the DB, if present.
func (*VRF) GenerateProof ¶
GenerateProof is marshaled randomness proof given k and VRF input seed computed from the SeedData
Key must have already been unlocked in ks, as constructing the VRF proof requires the secret key.
func (*VRF) Get ¶
Get retrieves all vrfkey.EncryptedVRFKey's associated with k, or all encrypted keys if k is nil, or errors
func (*VRF) GetSpecificKey ¶
func (*VRF) Import ¶
Import adds this encrypted key to the DB and unlocks it in in-memory store with passphrase auth, and returns any resulting errors
func (*VRF) ListKeysIncludingArchived ¶
ListKeysIncludingArchived lists the public keys contained in the db
func (*VRF) Store ¶
func (ks *VRF) Store(key *vrfkey.PrivateKey, phrase string, scryptParams utils.ScryptParams) error
Store saves key to ks (in memory), and to the DB, encrypted with phrase
func (*VRF) StoreInMemoryXXXTestingOnly ¶
func (ks *VRF) StoreInMemoryXXXTestingOnly(key *vrfkey.PrivateKey)
StoreInMemoryXXXTestingOnly memorizes key, only in in-memory store.
type VRFORM ¶
type VRFORM interface { FirstOrCreateEncryptedSecretVRFKey(k *vrfkey.EncryptedVRFKey) error ArchiveEncryptedSecretVRFKey(k *vrfkey.EncryptedVRFKey) error DeleteEncryptedSecretVRFKey(k *vrfkey.EncryptedVRFKey) error FindEncryptedSecretVRFKeys(where ...vrfkey.EncryptedVRFKey) ([]*vrfkey.EncryptedVRFKey, error) FindEncryptedSecretVRFKeysIncludingArchived(where ...vrfkey.EncryptedVRFKey) ([]*vrfkey.EncryptedVRFKey, error) }