Skip to content

Commit

Permalink
Merge pull request #336 from hypersign-protocol/release/v0.1.x
Browse files Browse the repository at this point in the history
`v0.1.6` release
  • Loading branch information
arnabghose997 authored Feb 9, 2023
2 parents 7913651 + c8ec063 commit b9d66f4
Show file tree
Hide file tree
Showing 50 changed files with 1,414 additions and 1,037 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,4 @@ dist/
# Misc
.cache/
__pycache__
artifacts
12 changes: 9 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ COMMIT := $(shell git rev-parse --short HEAD)

BUILD_DIR ?= $(CURDIR)/build
HIDNODE_CMD_DIR := $(CURDIR)/cmd/hid-noded
E2E_SSI_TESTS_DIR := $(CURDIR)/tests/e2e/ssi_tests
GO_MINOR_VERSION = $(shell go version | cut -c 14- | cut -d' ' -f1 | cut -d'.' -f2)

GOBIN = $(shell go env GOPATH)/bin
GOOS = $(shell go env GOOS)
Expand All @@ -31,14 +31,20 @@ export GO111MODULE=on

all: proto-gen swagger-docs-gen build

go-version-check:
ifneq ($(GO_MINOR_VERSION),18)
@echo "ERROR: Go version 1.18 is required for this version of hid-node"
exit 1
endif

go.sum: go.mod
@echo "--> Ensure dependencies have not been modified"
@go mod verify

install: go.sum
install: go-version-check go.sum
go install -mod=readonly $(BUILD_FLAGS) $(HIDNODE_CMD_DIR)

build:
build: go-version-check
go build -mod=readonly $(BUILD_FLAGS) -o $(BUILD_DIR)/hid-noded $(HIDNODE_CMD_DIR)

###############################################################################
Expand Down
5 changes: 5 additions & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,11 @@ func New(
return fromVM, nil
})

app.UpgradeKeeper.SetUpgradeHandler("v016", func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
ctx.Logger().Info("v0.1.6 upgrade")
return fromVM, nil
})

// register the staking hooks
// NOTE: stakingKeeper above is passed by reference, so that it will contain these hooks
app.StakingKeeper = *stakingKeeper.SetHooks(
Expand Down
62 changes: 57 additions & 5 deletions cmd/hid-noded/cmd/debug_extensions.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ import (
"crypto/ed25519"
"crypto/rand"
"encoding/base64"
"encoding/hex"
"encoding/json"
"fmt"

"github.com/btcsuite/btcutil/base58"
"github.com/cosmos/cosmos-sdk/client"
"github.com/hypersign-protocol/hid-node/x/ssi/types"
ethercrypto "github.com/ethereum/go-ethereum/crypto"
hidnodecli "github.com/hypersign-protocol/hid-node/x/ssi/client/cli"
"github.com/hypersign-protocol/hid-node/x/ssi/types"
"github.com/multiformats/go-multibase"
"github.com/spf13/cobra"
secp256k1 "github.com/tendermint/tendermint/crypto/secp256k1"
Expand All @@ -33,6 +35,7 @@ func secp256k1Cmd() *cobra.Command {

cmd.AddCommand(
secp256k1RandomCmd(),
secp256k1EthRandomCmd(),
)

return cmd
Expand Down Expand Up @@ -76,6 +79,45 @@ func secp256k1RandomCmd() *cobra.Command {
return cmd
}

func secp256k1EthRandomCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "eth-hex-random",
Short: "Generate random Ethereum hex-encoded secp256k1 keypair",
RunE: func(cmd *cobra.Command, args []string) error {
privateKeyObj := secp256k1.GenPrivKey()
privateKey := privateKeyObj.Bytes()

publicKeyCompressed := privateKeyObj.PubKey().Bytes()

publicKeyUncompressed, err := ethercrypto.DecompressPubkey(publicKeyCompressed)
if err != nil {
return err
}
ethereumAddress := ethercrypto.PubkeyToAddress(*publicKeyUncompressed).Hex()

keyInfo := struct {
PubKeyBase64 string `json:"pub_key_hex"`
PrivKeyBase64 string `json:"priv_key_hex"`
EthereumAddress string `json:"ethereum_address"`
}{
PubKeyBase64: hex.EncodeToString(publicKeyCompressed),
PrivKeyBase64: hex.EncodeToString(privateKey),
EthereumAddress: ethereumAddress,
}

keyInfoJson, err := json.Marshal(keyInfo)
if err != nil {
return err
}

_, err = fmt.Fprintln(cmd.OutOrStdout(), string(keyInfoJson))
return err
},
}

return cmd
}

// ed25519Cmd returns cobra Command.
func ed25519Cmd() *cobra.Command {
cmd := &cobra.Command{
Expand Down Expand Up @@ -108,7 +150,7 @@ func signSSIDocCmd() *cobra.Command {

func signSchemaDocCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "schema-doc [doc] [base64 encoded private-key] [signing-algo]",
Use: "schema-doc [doc] [private-key] [signing-algo]",
Short: "Schema Document signature",
Args: cobra.ExactArgs(3),
RunE: func(cmd *cobra.Command, args []string) error {
Expand Down Expand Up @@ -142,8 +184,13 @@ func signSchemaDocCmd() *cobra.Command {
if err != nil {
return err
}
case "recover-eth":
signature, err = hidnodecli.GetEthRecoverySignature(argPrivateKey, schemaDocBytes)
if err != nil {
return err
}
default:
panic("recieved unsupported signing-algo. Supported algorithms are: ['ed25519', 'secp256k1']")
panic("recieved unsupported signing-algo. Supported algorithms are: ['ed25519', 'secp256k1', 'recover-eth']")
}

_, err = fmt.Fprintln(cmd.OutOrStdout(), signature)
Expand All @@ -155,7 +202,7 @@ func signSchemaDocCmd() *cobra.Command {

func signCredStatusDocCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "cred-status-doc [doc] [base64 encoded private-key] [signing-algo]",
Use: "cred-status-doc [doc] [private-key] [signing-algo]",
Short: "Credential Status Document signature",
Args: cobra.ExactArgs(3),
RunE: func(cmd *cobra.Command, args []string) error {
Expand Down Expand Up @@ -189,8 +236,13 @@ func signCredStatusDocCmd() *cobra.Command {
if err != nil {
return err
}
case "recover-eth":
signature, err = hidnodecli.GetEthRecoverySignature(argPrivateKey, credStatusDocBytes)
if err != nil {
return err
}
default:
panic("recieved unsupported signing-algo. Supported algorithms are: ['ed25519', 'secp256k1']")
panic("recieved unsupported signing-algo. Supported algorithms are: ['ed25519', 'secp256k1', 'recover-eth']")
}

_, err = fmt.Fprintln(cmd.OutOrStdout(), signature)
Expand Down
14 changes: 13 additions & 1 deletion cmd/hid-noded/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (

"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/config"
"github.com/cosmos/cosmos-sdk/client/debug"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/client/keys"
Expand Down Expand Up @@ -50,12 +51,23 @@ func NewRootCmd() (*cobra.Command, params.EncodingConfig) {
WithInput(os.Stdin).
WithAccountRetriever(types.AccountRetriever{}).
WithBroadcastMode(flags.BroadcastBlock).
WithHomeDir(hidnode.DefaultNodeHome)
WithHomeDir(hidnode.DefaultNodeHome).
WithViper("")

rootCmd := &cobra.Command{
Use: "hid-noded",
Short: "Hypersign Identity Network (hid-noded) CLI",
PersistentPreRunE: func(cmd *cobra.Command, _ []string) error {
initClientCtx, err := client.ReadPersistentCommandFlags(initClientCtx, cmd.Flags())
if err != nil {
return err
}

initClientCtx, err = config.ReadFromClientConfig(initClientCtx)
if err != nil {
return err
}

if err := client.SetCmdClientContextHandler(initClientCtx, cmd); err != nil {
return err
}
Expand Down
5 changes: 4 additions & 1 deletion cmd/hid-noded/cmd/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ func readCosmConfig(homeDir string) (cosmcfg.Config, error) {
return cosmcfg.Config{}, fmt.Errorf("failed to read in app.toml: %w", err)
}

config := cosmcfg.GetConfig(v)
config, err := cosmcfg.GetConfig(v)
if err != nil {
return cosmcfg.Config{}, fmt.Errorf("failed to read in app.toml: %w", err)
}

return config, nil
}
Expand Down
65 changes: 34 additions & 31 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,20 @@ module github.com/hypersign-protocol/hid-node
go 1.18

require (
github.com/cosmos/cosmos-sdk v0.45.7
github.com/cosmos/ibc-go/v3 v3.1.0
github.com/cosmos/cosmos-sdk v0.45.11
github.com/cosmos/ibc-go/v3 v3.3.0
github.com/ethereum/go-ethereum v1.10.17
github.com/gogo/protobuf v1.3.3
github.com/gorilla/mux v1.8.0
github.com/grpc-ecosystem/grpc-gateway v1.16.0
github.com/spf13/cast v1.5.0
github.com/spf13/cobra v1.5.0
github.com/spf13/cobra v1.6.0
github.com/stretchr/testify v1.8.0
github.com/tendermint/spm v0.1.9
github.com/tendermint/tendermint v0.34.20
github.com/tendermint/tendermint v0.34.23
github.com/tendermint/tm-db v0.6.7
google.golang.org/genproto v0.0.0-20220822174746-9e6da59bd2fc
google.golang.org/grpc v1.48.0
google.golang.org/genproto v0.0.0-20221014213838-99cd37c6964a
google.golang.org/grpc v1.50.1
)

require (
Expand All @@ -28,18 +29,21 @@ require (
github.com/beorn7/perks v1.0.1 // indirect
github.com/bgentry/speakeasy v0.1.0 // indirect
github.com/btcsuite/btcd v0.22.1 // indirect
github.com/btcsuite/btcd/btcec/v2 v2.1.2 // indirect
github.com/cespare/xxhash v1.1.0 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/coinbase/rosetta-sdk-go v0.7.0 // indirect
github.com/confio/ics23/go v0.7.0 // indirect
github.com/cosmos/btcutil v1.0.4 // indirect
github.com/cosmos/go-bip39 v1.0.0 // indirect
github.com/cosmos/gorocksdb v1.2.0 // indirect
github.com/cosmos/iavl v0.19.0 // indirect
github.com/cosmos/iavl v0.19.4 // indirect
github.com/cosmos/ledger-cosmos-go v0.11.1 // indirect
github.com/cosmos/ledger-go v0.9.2 // indirect
github.com/creachadair/taskgroup v0.3.2 // indirect
github.com/danieljoos/wincred v1.0.2 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 // indirect
github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f // indirect
github.com/dgraph-io/badger/v2 v2.2007.2 // indirect
github.com/dgraph-io/ristretto v0.0.3 // indirect
Expand All @@ -51,10 +55,9 @@ require (
github.com/go-kit/kit v0.12.0 // indirect
github.com/go-kit/log v0.2.1 // indirect
github.com/go-logfmt/logfmt v0.5.1 // indirect
github.com/go-playground/validator/v10 v10.4.1 // indirect
github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 // indirect
github.com/gogo/gateway v1.1.0 // indirect
github.com/golang/snappy v0.0.3 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/google/btree v1.0.0 // indirect
github.com/google/orderedcode v0.0.1 // indirect
github.com/gorilla/handlers v1.5.1 // indirect
Expand All @@ -64,21 +67,21 @@ require (
github.com/gtank/merlin v0.1.1 // indirect
github.com/gtank/ristretto255 v0.1.2 // indirect
github.com/hashicorp/go-immutable-radix v1.3.1 // indirect
github.com/hashicorp/golang-lru v0.5.4 // indirect
github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/hdevalence/ed25519consensus v0.0.0-20210204194344-59a8610d2b87 // indirect
github.com/improbable-eng/grpc-web v0.14.1 // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/inconshreveable/mousetrap v1.0.1 // indirect
github.com/jmhodges/levigo v1.0.0 // indirect
github.com/keybase/go-keychain v0.0.0-20190712205309-48d3d31d256d // indirect
github.com/klauspost/compress v1.15.1 // indirect
github.com/klauspost/compress v1.15.11 // indirect
github.com/lib/pq v1.10.6 // indirect
github.com/libp2p/go-buffer-pool v0.1.0 // indirect
github.com/magiconair/properties v1.8.6 // indirect
github.com/mattn/go-colorable v0.1.12 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
github.com/mimoo/StrobeGo v0.0.0-20181016162300-f8f6d4d2b643 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.16 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect
github.com/mimoo/StrobeGo v0.0.0-20210601165009-122bf33a46e0 // indirect
github.com/minio/highwayhash v1.0.2 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
Expand All @@ -87,36 +90,37 @@ require (
github.com/multiformats/go-base32 v0.0.3 // indirect
github.com/multiformats/go-base36 v0.1.0 // indirect
github.com/pelletier/go-toml v1.9.5 // indirect
github.com/pelletier/go-toml/v2 v2.0.2 // indirect
github.com/pelletier/go-toml/v2 v2.0.5 // indirect
github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_golang v1.12.2 // indirect
github.com/prometheus/client_model v0.2.0 // indirect
github.com/prometheus/common v0.34.0 // indirect
github.com/prometheus/procfs v0.7.3 // indirect
github.com/prometheus/procfs v0.8.0 // indirect
github.com/rakyll/statik v0.1.7 // indirect
github.com/rcrowley/go-metrics v0.0.0-20200313005456-10cdbea86bc0 // indirect
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect
github.com/regen-network/cosmos-proto v0.3.1 // indirect
github.com/rs/cors v1.8.2 // indirect
github.com/rs/zerolog v1.27.0 // indirect
github.com/sasha-s/go-deadlock v0.2.1-0.20190427202633-1595213edefa // indirect
github.com/sasha-s/go-deadlock v0.3.1 // indirect
github.com/spf13/afero v1.8.2 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/subosito/gotenv v1.4.0 // indirect
github.com/syndtr/goleveldb v1.0.1-0.20200815110645-5c35d600f0ca // indirect
github.com/subosito/gotenv v1.4.1 // indirect
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 // indirect
github.com/tendermint/btcd v0.1.1 // indirect
github.com/tendermint/crypto v0.0.0-20191022145703-50d29ede1e15 // indirect
github.com/tendermint/go-amino v0.16.0 // indirect
github.com/zondax/hid v0.9.0 // indirect
go.etcd.io/bbolt v1.3.6 // indirect
golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e // indirect
golang.org/x/sys v0.0.0-20220615213510-4f61da869c0c // indirect
golang.org/x/term v0.0.0-20220526004731-065cf7ba2467 // indirect
golang.org/x/text v0.3.7 // indirect
google.golang.org/protobuf v1.28.1 // indirect
gopkg.in/ini.v1 v1.66.6 // indirect
golang.org/x/crypto v0.1.0 // indirect
golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e // indirect
golang.org/x/sys v0.1.0 // indirect
golang.org/x/term v0.1.0 // indirect
golang.org/x/text v0.4.0 // indirect
google.golang.org/protobuf v1.28.2-0.20220831092852-f930b1dc76e8 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
nhooyr.io/websocket v1.8.6 // indirect
)
Expand All @@ -125,14 +129,13 @@ require (
github.com/btcsuite/btcutil v1.0.3-0.20201208143702-a53e38424cce
github.com/golang/protobuf v1.5.2
github.com/multiformats/go-multibase v0.0.3
github.com/spf13/viper v1.12.0
golang.org/x/net v0.0.0-20220624214902-1bab6f366d9e // indirect
github.com/spf13/viper v1.13.0
golang.org/x/net v0.1.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
)

replace (
github.com/confio/ics23/go => github.com/cosmos/cosmos-sdk/ics23/go v0.8.0
github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1
github.com/keybase/go-keychain => github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4
google.golang.org/grpc => google.golang.org/grpc v1.33.2
)
Loading

0 comments on commit b9d66f4

Please sign in to comment.