Skip to content

Commit

Permalink
chore: signing behind interface (#20)
Browse files Browse the repository at this point in the history
* chore: simplified equal pk check

* feat: add crypto signer wrapper for btcstaking signing functions

* chore: update fpName to keyName in ChainKeyringController

* chore: address naming suggestions CriptoSigner -> Signer, KeyringCriptoSigner -> KeyringSigner, NewLocalKeyringCriptoSigner -> NewKeyringSigner

* chore: add changelog #20

* feat: partial refactory in generating signatures

* chore: removed unused funcs, simplified sort

* fix: unit test sorting of covenant sigs to match expected

* chore: rollback to use pub key with pointer

* chore: rollback to schnorr sig with pointer

* chore: rollback to use covenant sigs as pointer

* chore: rollback to pointer

* chore: refactory signer signature handling

* chore: address gitferry pr comments

* fix: pwd parameter

* chore: modify to call the signed once per each delegation

* chore: remove unecessary sorting of covenant signatures
  • Loading branch information
RafilxTenfen authored Oct 14, 2024
1 parent 5af04ad commit e23e7d1
Show file tree
Hide file tree
Showing 10 changed files with 359 additions and 194 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,8 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)

## Unreleased

### Improvements

* [#20](https://github.com/babylonlabs-io/covenant-emulator/pull/20) Add signing behind
interface.
4 changes: 2 additions & 2 deletions cmd/covd/key.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/urfave/cli"

covcfg "github.com/babylonlabs-io/covenant-emulator/config"
"github.com/babylonlabs-io/covenant-emulator/covenant"
"github.com/babylonlabs-io/covenant-emulator/keyring"
)

type covenantKey struct {
Expand Down Expand Up @@ -71,7 +71,7 @@ func createKey(ctx *cli.Context) error {
return fmt.Errorf("failed to load the config from %s: %w", covcfg.ConfigFile(homePath), err)
}

keyPair, err := covenant.CreateCovenantKey(
keyPair, err := keyring.CreateCovenantKey(
homePath,
chainID,
keyName,
Expand Down
20 changes: 19 additions & 1 deletion cmd/covd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"path/filepath"

covcfg "github.com/babylonlabs-io/covenant-emulator/config"
"github.com/babylonlabs-io/covenant-emulator/keyring"
"github.com/babylonlabs-io/covenant-emulator/log"
"github.com/babylonlabs-io/covenant-emulator/util"

Expand Down Expand Up @@ -57,7 +58,14 @@ func start(ctx *cli.Context) error {
return fmt.Errorf("failed to create rpc client for the consumer chain: %w", err)
}

ce, err := covenant.NewCovenantEmulator(cfg, bbnClient, ctx.String(passphraseFlag), logger)
pwd := ctx.String(passphraseFlag)

signer, err := newSignerFromConfig(cfg, pwd)
if err != nil {
return fmt.Errorf("failed to create signer from config: %w", err)
}

ce, err := covenant.NewCovenantEmulator(cfg, bbnClient, logger, signer)
if err != nil {
return fmt.Errorf("failed to start the covenant emulator: %w", err)
}
Expand All @@ -75,3 +83,13 @@ func start(ctx *cli.Context) error {

return srv.RunUntilShutdown()
}

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,
)
}
Loading

0 comments on commit e23e7d1

Please sign in to comment.