Documentation
¶
Overview ¶
Package gcpkms uses the Google Cloud Platform's Key Management Service to provide a signing interface for EVM-compatible transactions.
Rather than directly accessing a private key to sign a transaction, the client makes calls to the remote GCP KMS to do so and the private key never leaves the KMS.
Index ¶
- type Config
- type GoogleKMSClient
- func (c GoogleKMSClient) GetAddress() common.Address
- func (c GoogleKMSClient) GetDefaultEVMTransactor() *bind.TransactOpts
- func (c GoogleKMSClient) GetEVMSignerFn() bind.SignerFn
- func (c GoogleKMSClient) GetPublicKey() (*ecdsa.PublicKey, error)
- func (c GoogleKMSClient) HasSignedTx(tx *types.Transaction) (bool, error)
- func (c GoogleKMSClient) SignHash(digest common.Hash) ([]byte, error)
- func (c *GoogleKMSClient) WithChainID(chainID *big.Int)
- func (c *GoogleKMSClient) WithSigner(signer types.Signer)
- type Key
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { // ProjectID is the ID of the working GCP project. ProjectID string `json:"ProjectID"` // LocationID is the region ID of the project. // // Example: us-west1. LocationID string `json:"LocationID"` // CredentialLocation is the absolute path of the credential file downloaded from the GCP. // // Example: "/Users/SomeUser/.cred/gcp-credential.json". // Leave this field empty if the environment varialbe `GOOGLE_APPLICATION_CREDENTIALS` has been set. CredentialLocation string `json:"CredentialLocation,omitempty"` // Key is the detail of the GCP KMS key. Key Key `json:"Key"` // ChainID is the ID of the target EVM chain. // // See https://chainlist.org. ChainID uint64 `json:"ChainID"` }
Config represents required information to create a Google Cloud KMS client.
func LoadConfigFromFile ¶
LoadConfigFromFile loads the config from the given config file.
type GoogleKMSClient ¶
type GoogleKMSClient struct {
// contains filtered or unexported fields
}
GoogleKMSClient implements basic functionalities of a Google KMS client for signing transactions.
func NewGoogleKMSClient ¶
func NewGoogleKMSClient(ctx context.Context, cfg Config, txSigner ...types.Signer) (*GoogleKMSClient, error)
NewGoogleKMSClient creates a new GCP KMS client with the given config.
If txSigner is not provided, the signer will be initiated as a types.NewLondonSigner(cfg.ChainID). Note that only the first value of txSigner is used.
func (GoogleKMSClient) GetAddress ¶
func (c GoogleKMSClient) GetAddress() common.Address
GetAddress returns the EVM address of the current signer.
func (GoogleKMSClient) GetDefaultEVMTransactor ¶
func (c GoogleKMSClient) GetDefaultEVMTransactor() *bind.TransactOpts
GetDefaultEVMTransactor returns the default KMS-backed instance of bind.TransactOpts. Only `Context`, `From`, and `Signer` fields are set.
func (GoogleKMSClient) GetEVMSignerFn ¶
func (c GoogleKMSClient) GetEVMSignerFn() bind.SignerFn
GetEVMSignerFn returns the EVM signer using the GCP KMS.
func (GoogleKMSClient) GetPublicKey ¶
func (c GoogleKMSClient) GetPublicKey() (*ecdsa.PublicKey, error)
GetPublicKey returns the public Key corresponding to the given keyId.
func (GoogleKMSClient) HasSignedTx ¶
func (c GoogleKMSClient) HasSignedTx(tx *types.Transaction) (bool, error)
HasSignedTx checks if the given tx is signed by the current GoogleKMSClient.
func (GoogleKMSClient) SignHash ¶
func (c GoogleKMSClient) SignHash(digest common.Hash) ([]byte, error)
SignHash calls the remote GCP KMS to sign a given digested message. Although the GCP KMS does not support keccak256 hash function (it uses SHA256 instead), it will not care about which hash function to use if you send the hash of message to the KMS.
func (*GoogleKMSClient) WithChainID ¶ added in v0.2.0
func (c *GoogleKMSClient) WithChainID(chainID *big.Int)
WithChainID assigns given chainID (and updates the corresponding signer) to the GoogleKMSClient.
func (*GoogleKMSClient) WithSigner ¶ added in v0.1.1
func (c *GoogleKMSClient) WithSigner(signer types.Signer)
WithSigner assigns the given signer to the GoogleKMSClient.
type Key ¶
type Key struct { // Keyring is the name of your KMS keyring. Keyring string `json:"Keyring"` // Name is the name of the key in the Keyring. Name string `json:"Name"` // Version is the of the current key. Version string `json:"Version"` }
Key consists of required information to retrieve the CGP KMS Key path.