Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
ParthDesai committed Feb 2, 2022
0 parents commit abe4fd4
Show file tree
Hide file tree
Showing 9 changed files with 1,780 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.idea/
14 changes: 14 additions & 0 deletions cmd/keys.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package cmd

import (
"github.com/cosmos/cosmos-sdk/client/keys"
"github.com/spf13/cobra"
)

var keysCmd = &cobra.Command{Use: "keys"}

func init() {
keysCmd.AddCommand(keys.AddKeyCommand())
keysCmd.AddCommand(keys.ShowKeysCmd())
rootCmd.AddCommand(keysCmd)
}
106 changes: 106 additions & 0 deletions cmd/kyc_sign.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
package cmd

import (
"bufio"
"encoding/base64"
"encoding/json"
"fmt"
"github.com/archway-network/archway-testnet-signer/types"
cosmosFlag "github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/crypto/keyring"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/spf13/cobra"
"os"
"strings"
)

var signIDCmd = &cobra.Command{
Use: "sign_id [key_name]",
Short: "Sign an id message with your key to prove that you own the key",
Long: `This command asks you some personal details like legal name, email address and github handle,
and uses the key associated with [key_name] to sign the message containing that data and print it`,
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
keyringBackend, err := cmd.Flags().GetString(cosmosFlag.FlagKeyringBackend)
if err != nil {
return err
}

backendDir, err := cmd.Flags().GetString(cosmosFlag.FlagKeyringDir)
if err != nil {
return err
}

kr, err := keyring.New(sdk.KeyringServiceName(), keyringBackend, backendDir, os.Stdin)
if err != nil {
return err
}

keyName := args[0]
keyInfo, err := kr.Key(keyName)
if err != nil {
return err
}

accAddress := sdk.AccAddress(keyInfo.GetPubKey().Address()).String()
fmt.Println("Your Augusta incentivized testnet address is: ", accAddress)

reader := bufio.NewReader(os.Stdin)
fmt.Printf("Please Enter your Full Legal Name:")
fullLegalName, err := reader.ReadString('\n')
if err != nil {
return err
}
fullLegalName = strings.TrimSpace(fullLegalName)

fmt.Printf("Please enter your github handle:")
githubHandle, err := reader.ReadString('\n')
if err != nil {
return err
}
githubHandle = strings.TrimSpace(githubHandle)

fmt.Printf("Please enter your email address (Use same email address, you would use in kyc form):")
emailAddress, err := reader.ReadString('\n')
if err != nil {
return err
}
emailAddress = strings.TrimSpace(emailAddress)

kycID := types.ID{
FullLegalName: fullLegalName,
GithubHandle: githubHandle,
EmailAddress: emailAddress,
AccountAddress: accAddress,
}

marshalledBytes, err := json.Marshal(kycID)
signature, _, err := kr.Sign(keyName, marshalledBytes)
if err != nil {
return err
}

signatureStr := base64.StdEncoding.EncodeToString(signature)

container := types.Container{
ID: kycID,
Signature: signatureStr,
PubKey: keyInfo.GetPubKey().String(),
}

marshalledContainer, err := json.MarshalIndent(container, "", " ")
if err != nil {
return err
}

fmt.Println("Please submit json below the line in the form")
fmt.Println("-----------------------------")
fmt.Println(string(marshalledContainer))

return nil
},
}

func init() {
rootCmd.AddCommand(signIDCmd)
}
30 changes: 30 additions & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package cmd

import (
"context"
"fmt"
"github.com/cosmos/cosmos-sdk/client"
cosmosFlag "github.com/cosmos/cosmos-sdk/client/flags"
"github.com/spf13/cobra"
"github.com/tendermint/tendermint/libs/cli"
"os"
)

var rootCmd = &cobra.Command{Use: "archway-testnet-signer"}

func init() {
rootCmd.PersistentFlags().String(cosmosFlag.FlagKeyringBackend, "os", "Keyring backend to use, default value is: os")
rootCmd.PersistentFlags().String(cosmosFlag.FlagKeyringDir, os.ExpandEnv("$HOME/")+".augusta", "Keyring backend directory")
rootCmd.PersistentFlags().String(cli.OutputFlag, "text", "Output format (text|json)")
}

func Execute() {
initClientCtx := client.Context{}.WithInput(os.Stdin)
ctx := context.Background()
ctx = context.WithValue(ctx, client.ClientContextKey, &initClientCtx)

if err := rootCmd.ExecuteContext(ctx); err != nil {
_, _ = fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
}
101 changes: 101 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
module github.com/archway-network/archway-testnet-signer

go 1.17

require (
github.com/cosmos/cosmos-sdk v0.45.0
github.com/spf13/cobra v1.3.0
github.com/tendermint/tendermint v0.34.14
)

require (
filippo.io/edwards25519 v1.0.0-beta.2 // indirect
github.com/99designs/keyring v1.1.6 // indirect
github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d // indirect
github.com/DataDog/zstd v1.4.5 // indirect
github.com/armon/go-metrics v0.3.10 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bgentry/speakeasy v0.1.0 // indirect
github.com/btcsuite/btcd v0.22.0-beta // indirect
github.com/cespare/xxhash v1.1.0 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/confio/ics23/go v0.6.6 // indirect
github.com/cosmos/btcutil v1.0.4 // indirect
github.com/cosmos/go-bip39 v1.0.0 // indirect
github.com/cosmos/iavl v0.17.3 // indirect
github.com/cosmos/ledger-cosmos-go v0.11.1 // indirect
github.com/cosmos/ledger-go v0.9.2 // indirect
github.com/danieljoos/wincred v1.0.2 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/dgraph-io/badger/v2 v2.2007.2 // indirect
github.com/dgraph-io/ristretto v0.0.3 // indirect
github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 // indirect
github.com/dustin/go-humanize v1.0.0 // indirect
github.com/dvsekhvalnov/jose2go v0.0.0-20200901110807-248326c1351b // indirect
github.com/fsnotify/fsnotify v1.5.1 // indirect
github.com/go-kit/kit v0.10.0 // indirect
github.com/go-logfmt/logfmt v0.5.0 // indirect
github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 // indirect
github.com/gogo/protobuf v1.3.3 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/golang/snappy v0.0.3 // indirect
github.com/google/btree v1.0.0 // indirect
github.com/gorilla/websocket v1.4.2 // indirect
github.com/grpc-ecosystem/grpc-gateway v1.16.0 // indirect
github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c // indirect
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/hcl v1.0.0 // indirect
github.com/hdevalence/ed25519consensus v0.0.0-20210204194344-59a8610d2b87 // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/jmhodges/levigo v1.0.0 // indirect
github.com/keybase/go-keychain v0.0.0-20190712205309-48d3d31d256d // indirect
github.com/libp2p/go-buffer-pool v0.0.2 // indirect
github.com/magiconair/properties v1.8.5 // 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/mitchellh/go-homedir v1.1.0 // indirect
github.com/mitchellh/mapstructure v1.4.3 // indirect
github.com/mtibben/percent v0.2.1 // indirect
github.com/pelletier/go-toml v1.9.4 // 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.11.0 // indirect
github.com/prometheus/client_model v0.2.0 // indirect
github.com/prometheus/common v0.29.0 // indirect
github.com/prometheus/procfs v0.6.0 // indirect
github.com/rcrowley/go-metrics v0.0.0-20200313005456-10cdbea86bc0 // indirect
github.com/sasha-s/go-deadlock v0.2.1-0.20190427202633-1595213edefa // indirect
github.com/spf13/afero v1.6.0 // indirect
github.com/spf13/cast v1.4.1 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/spf13/viper v1.10.0 // indirect
github.com/stretchr/testify v1.7.0 // indirect
github.com/subosito/gotenv v1.2.0 // indirect
github.com/syndtr/goleveldb v1.0.1-0.20200815110645-5c35d600f0ca // indirect
github.com/tecbot/gorocksdb v0.0.0-20191217155057-f0fad39f321c // 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/tendermint/tm-db v0.6.4 // indirect
github.com/zondax/hid v0.9.0 // indirect
go.etcd.io/bbolt v1.3.5 // indirect
golang.org/x/crypto v0.0.0-20210817164053-32db794688a5 // indirect
golang.org/x/net v0.0.0-20210903162142-ad29c8ab022f // indirect
golang.org/x/sys v0.0.0-20211205182925-97ca703d548d // indirect
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1 // indirect
golang.org/x/text v0.3.7 // indirect
google.golang.org/genproto v0.0.0-20211208223120-3a66f561d7aa // indirect
google.golang.org/grpc v1.42.0 // indirect
google.golang.org/protobuf v1.27.1 // indirect
gopkg.in/ini.v1 v1.66.2 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
)

replace github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1
Loading

0 comments on commit abe4fd4

Please sign in to comment.