Skip to content

Commit

Permalink
chore: address naming suggestions CriptoSigner -> Signer, KeyringCrip…
Browse files Browse the repository at this point in the history
…toSigner -> KeyringSigner, NewLocalKeyringCriptoSigner -> NewKeyringSigner
  • Loading branch information
RafilxTenfen committed Oct 10, 2024
1 parent 16fe1e6 commit 539dfd5
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 18 deletions.
4 changes: 2 additions & 2 deletions cmd/covd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,6 @@ func start(ctx *cli.Context) error {
return srv.RunUntilShutdown()
}

func NewSignerFromConfig(cfg *covcfg.Config, passphrase string) (*keyring.KeyringCriptoSigner, error) {
return keyring.NewLocalKeyringCriptoSigner(cfg.BabylonConfig.ChainID, cfg.BabylonConfig.Key, cfg.BabylonConfig.KeyDirectory, cfg.BabylonConfig.KeyringBackend, passphrase)
func NewSignerFromConfig(cfg *covcfg.Config, passphrase string) (*keyring.KeyringSigner, error) {
return keyring.NewKeyringSigner(cfg.BabylonConfig.ChainID, cfg.BabylonConfig.Key, cfg.BabylonConfig.KeyDirectory, cfg.BabylonConfig.KeyringBackend, passphrase)
}
8 changes: 4 additions & 4 deletions covenant/covenant.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ type CovenantEmulator struct {

pk *btcec.PublicKey

signer CriptoSigner
signer Signer
cc clientcontroller.ClientController

config *covcfg.Config
Expand All @@ -52,7 +52,7 @@ func NewCovenantEmulator(
cc clientcontroller.ClientController,
passphrase string,
logger *zap.Logger,
signer CriptoSigner,
signer Signer,
) (*CovenantEmulator, error) {
pk, err := signer.PubKey()
if err != nil {
Expand Down Expand Up @@ -253,7 +253,7 @@ func signSlashUnbondingSignatures(
del *types.Delegation,
unbondingTx *wire.MsgTx,
slashUnbondingTx *wire.MsgTx,
signer CriptoSigner,
signer Signer,
params *types.StakingParams,
btcNet *chaincfg.Params,
) ([][]byte, error) {
Expand Down Expand Up @@ -302,7 +302,7 @@ func signSlashAndUnbondSignatures(
stakingTx *wire.MsgTx,
slashingTx *wire.MsgTx,
unbondingTx *wire.MsgTx,
signer CriptoSigner,
signer Signer,
params *types.StakingParams,
btcNet *chaincfg.Params,
) ([][]byte, *schnorr.Signature, error) {
Expand Down
2 changes: 1 addition & 1 deletion covenant/covenant_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func FuzzAddCovenantSig(f *testing.F) {
)
require.NoError(t, err)

signer, err := keyring.NewLocalKeyringCriptoSigner(covenantConfig.BabylonConfig.ChainID, covenantConfig.BabylonConfig.Key, covenantConfig.BabylonConfig.KeyDirectory, covenantConfig.BabylonConfig.KeyringBackend, passphrase)
signer, err := keyring.NewKeyringSigner(covenantConfig.BabylonConfig.ChainID, covenantConfig.BabylonConfig.Key, covenantConfig.BabylonConfig.KeyDirectory, covenantConfig.BabylonConfig.KeyringBackend, passphrase)
require.NoError(t, err)

// create and start covenant emulator
Expand Down
4 changes: 2 additions & 2 deletions covenant/expected_interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (
secp "github.com/decred/dcrd/dcrec/secp256k1/v4"
)

// CriptoSigner wrapper interface to sign messages
type CriptoSigner interface {
// Signer wrapper interface to sign messages
type Signer interface {
// PubKey returns the current secp256k1 public key
PubKey() (*secp.PublicKey, error)
// EncSignTxWithOneScriptSpendInputStrict is encrypted version of
Expand Down
2 changes: 1 addition & 1 deletion itest/test_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func StartManager(t *testing.T) *TestManager {
covbc, err := covcc.NewBabylonController(bbnCfg, &covenantConfig.BTCNetParams, logger)
require.NoError(t, err)

signer, err := covdkeyring.NewLocalKeyringCriptoSigner(covenantConfig.BabylonConfig.ChainID, covenantConfig.BabylonConfig.Key, covenantConfig.BabylonConfig.KeyDirectory, covenantConfig.BabylonConfig.KeyringBackend, passphrase)
signer, err := covdkeyring.NewKeyringSigner(covenantConfig.BabylonConfig.ChainID, covenantConfig.BabylonConfig.Key, covenantConfig.BabylonConfig.KeyDirectory, covenantConfig.BabylonConfig.KeyringBackend, passphrase)
require.NoError(t, err)

ce, err := covenant.NewCovenantEmulator(covenantConfig, covbc, passphrase, logger, signer)
Expand Down
16 changes: 8 additions & 8 deletions keyring/signer.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ import (
secp "github.com/decred/dcrd/dcrec/secp256k1/v4"
)

var _ covenant.CriptoSigner = KeyringCriptoSigner{}
var _ covenant.Signer = KeyringSigner{}

type KeyringCriptoSigner struct {
type KeyringSigner struct {
kc *ChainKeyringController
passphrase string
}

func NewLocalKeyringCriptoSigner(chainId, keyName, keyringDir, keyringBackend, passphrase string) (*KeyringCriptoSigner, error) {
func NewKeyringSigner(chainId, keyName, keyringDir, keyringBackend, passphrase string) (*KeyringSigner, error) {
input := strings.NewReader("")
kr, err := CreateKeyring(keyringDir, chainId, keyringBackend, input)
if err != nil {
Expand All @@ -33,13 +33,13 @@ func NewLocalKeyringCriptoSigner(chainId, keyName, keyringDir, keyringBackend, p
return nil, err
}

return &KeyringCriptoSigner{
return &KeyringSigner{
kc: kc,
passphrase: passphrase,
}, nil
}

func (kcs KeyringCriptoSigner) PubKey() (*secp.PublicKey, error) {
func (kcs KeyringSigner) PubKey() (*secp.PublicKey, error) {
record, err := kcs.kc.KeyRecord()
if err != nil {
return nil, err
Expand All @@ -56,7 +56,7 @@ func (kcs KeyringCriptoSigner) PubKey() (*secp.PublicKey, error) {
// getPrivKey returns the keyring private key
// TODO: update btcstaking functions to avoid receiving private key as parameter
// and only sign it using the kcs.kc.GetKeyring().Sign()
func (kcs KeyringCriptoSigner) getPrivKey() (*btcec.PrivateKey, error) {
func (kcs KeyringSigner) getPrivKey() (*btcec.PrivateKey, error) {
sdkPrivKey, err := kcs.kc.GetChainPrivKey(kcs.passphrase)
if err != nil {
return nil, err
Expand All @@ -69,7 +69,7 @@ func (kcs KeyringCriptoSigner) getPrivKey() (*btcec.PrivateKey, error) {
// EncSignTxWithOneScriptSpendInputStrict is encrypted version of
// SignTxWithOneScriptSpendInputStrict with the output to be encrypted
// by an encryption key (adaptor signature)
func (kcs KeyringCriptoSigner) EncSignTxWithOneScriptSpendInputStrict(
func (kcs KeyringSigner) EncSignTxWithOneScriptSpendInputStrict(
txToSign *wire.MsgTx,
fundingTx *wire.MsgTx,
fundingOutputIdx uint32,
Expand Down Expand Up @@ -99,7 +99,7 @@ func (kcs KeyringCriptoSigner) EncSignTxWithOneScriptSpendInputStrict(
// - fundingTx is not nil
// - fundingTx has one output committing to the provided script
// - txToSign input is pointing to the correct output in fundingTx
func (kcs KeyringCriptoSigner) SignTxWithOneScriptSpendInputStrict(
func (kcs KeyringSigner) SignTxWithOneScriptSpendInputStrict(
txToSign *wire.MsgTx,
fundingTx *wire.MsgTx,
fundingOutputIdx uint32,
Expand Down

0 comments on commit 539dfd5

Please sign in to comment.