Skip to content

Commit

Permalink
Problem: no command to show current pubkey in e2ee
Browse files Browse the repository at this point in the history
  • Loading branch information
yihuang committed Jul 10, 2024
1 parent ec2dc9e commit ec65c88
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

* (store) [#1510](https://github.com/crypto-org-chain/cronos/pull/1510) Upgrade rocksdb to `v9.1.1`.
* (store) [#1511](https://github.com/crypto-org-chain/cronos/pull/1511) Upgrade rocksdb to `v9.2.1`.
* (e2ee) [#]() Add pubkey subcommand to e2ee cli.

*Jul 7, 2024*

Expand Down
1 change: 1 addition & 0 deletions x/e2ee/client/cli/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ func E2EECommand() *cobra.Command {
EncryptCommand(),
DecryptCommand(),
EncryptToValidatorsCommand(),
PubKeyCommand(),
)

return cmd
Expand Down
53 changes: 53 additions & 0 deletions x/e2ee/client/cli/pubkey.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package cli

import (
"fmt"
"os"

"filippo.io/age"
"github.com/cosmos/cosmos-sdk/client"
"github.com/crypto-org-chain/cronos/v2/x/e2ee/keyring"
"github.com/crypto-org-chain/cronos/v2/x/e2ee/types"
"github.com/spf13/cobra"
)

func PubKeyCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "pubkey",
Short: "Show the recipient of current identity stored in keyring",
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx, err := client.GetClientQueryContext(cmd)
if err != nil {
return err
}

krName, err := cmd.Flags().GetString(FlagKeyringName)
if err != nil {
return err
}

kr, err := keyring.New("cronosd", clientCtx.Keyring.Backend(), clientCtx.HomeDir, os.Stdin)
if err != nil {
return err
}

bz, err := kr.Get(krName)
if err != nil {
return err
}

k, err := age.ParseX25519Identity(string(bz))
if err != nil {
return err
}

fmt.Println(k.Recipient())
return nil
},
}

cmd.Flags().String(FlagKeyringName, types.DefaultKeyringName, "The keyring name to use")

return cmd
}

0 comments on commit ec65c88

Please sign in to comment.