Commit 789e799e authored by suyanlong's avatar suyanlong

Add cmd flag information

parent b834c03c
Pipeline #8274 failed with stages
...@@ -7,6 +7,7 @@ import ( ...@@ -7,6 +7,7 @@ import (
"github.com/fatih/color" "github.com/fatih/color"
"github.com/urfave/cli" "github.com/urfave/cli"
_ "gitlab.33.cn/link33/sidecar/pkg/crypto/bls"
"gitlab.33.cn/link33/sidecar/pkg/log" "gitlab.33.cn/link33/sidecar/pkg/log"
) )
......
...@@ -6,12 +6,14 @@ import ( ...@@ -6,12 +6,14 @@ import (
"encoding/pem" "encoding/pem"
"fmt" "fmt"
crypto2 "github.com/libp2p/go-libp2p-core/crypto" p2pcrypto "github.com/libp2p/go-libp2p-core/crypto"
"github.com/libp2p/go-libp2p-core/peer" "github.com/libp2p/go-libp2p-core/peer"
"github.com/meshplus/bitxhub-kit/crypto" "github.com/meshplus/bitxhub-kit/crypto"
"github.com/meshplus/bitxhub-kit/crypto/asym" "github.com/meshplus/bitxhub-kit/crypto/asym"
"github.com/urfave/cli" "github.com/urfave/cli"
"gitlab.33.cn/link33/sidecar/internal/repo"
"gitlab.33.cn/link33/sidecar/pkg/crypto/bls"
"gitlab.33.cn/link33/sidecar/tool" "gitlab.33.cn/link33/sidecar/tool"
) )
...@@ -46,7 +48,7 @@ var toolCMD = cli.Command{ ...@@ -46,7 +48,7 @@ var toolCMD = cli.Command{
sdKey, err := asym.PrivKeyToStdKey(k) sdKey, err := asym.PrivKeyToStdKey(k)
tool.Asset(err) tool.Asset(err)
_, pk, err := crypto2.KeyPairFromStdKey(&sdKey) _, pk, err := p2pcrypto.KeyPairFromStdKey(&sdKey)
tool.Asset(err) tool.Asset(err)
id, err := peer.IDFromPublicKey(pk) id, err := peer.IDFromPublicKey(pk)
tool.Asset(err) tool.Asset(err)
...@@ -60,39 +62,49 @@ var toolCMD = cli.Command{ ...@@ -60,39 +62,49 @@ var toolCMD = cli.Command{
Name: "appchain", Name: "appchain",
Usage: "about appchain information", Usage: "about appchain information",
Action: func(ctx *cli.Context) error { Action: func(ctx *cli.Context) error {
privKey, err := asym.GenerateKeyPair(crypto.Secp256k1) gen := func(privKey crypto.PrivateKey) {
dataPrivKey, err := privKey.Bytes()
tool.Asset(err)
c, err := asym.GetCrypto(privKey.Type())
tool.Asset(err)
fmt.Printf("private key type: %s ----------------------------------------\n", c.Name)
fmt.Println("--------user PrivateKey----------begin")
fmt.Println(hex.EncodeToString(dataPrivKey))
fmt.Println("--------user PrivateKey----------end \n")
publicKey, err := privKey.PublicKey().Bytes()
tool.Asset(err)
fmt.Println("--------user PublicKey----------begin")
fmt.Println(hex.EncodeToString(publicKey))
fmt.Println("--------user PublicKey----------end \n")
address, err := privKey.PublicKey().Address()
tool.Asset(err)
fmt.Println("--------user Address----------begin")
fmt.Println(address.String())
fmt.Println("--------user Address----------end \n")
keyStore, err := asym.GenKeyStore(privKey, repo.KeyPassword)
data, err := keyStore.Pretty()
tool.Asset(err)
fmt.Println("--------user keyStore----------begin ")
fmt.Println(data)
fmt.Println("--------user keyStore----------end \n")
}
pk, err := asym.GenerateKeyPair(crypto.Secp256k1)
tool.Asset(err) tool.Asset(err)
gen(pk)
dataPrivKey, err := privKey.Bytes() pk, err = asym.GenerateKeyPair(bls.BlsEth)
tool.Asset(err) tool.Asset(err)
gen(pk)
fmt.Println("--------user PrivateKey----------begin")
fmt.Println(hex.EncodeToString(dataPrivKey))
fmt.Println("--------user PrivateKey----------end \n")
publicKey, err := privKey.PublicKey().Bytes()
tool.Asset(err)
fmt.Println("--------user PublicKey----------begin")
fmt.Println(hex.EncodeToString(publicKey))
fmt.Println("--------user PublicKey----------end \n")
address, err := privKey.PublicKey().Address()
tool.Asset(err)
fmt.Println("--------user Address----------begin")
fmt.Println(address.String())
fmt.Println("--------user Address----------end \n")
keyStore, err := asym.GenKeyStore(privKey, "link33")
data, err := keyStore.Pretty()
tool.Asset(err)
fmt.Println("--------user keyStore----------begin ")
fmt.Println(data)
fmt.Println("--------user keyStore----------end \n")
return nil return nil
}, },
}, },
}, },
} }
//key.json -> user private key|-> id
// |-> address
...@@ -43,6 +43,7 @@ func NewSidecar(repoRoot string, config *repo.Config) (internal.Launcher, error) ...@@ -43,6 +43,7 @@ func NewSidecar(repoRoot string, config *repo.Config) (internal.Launcher, error)
store, err := leveldb.New(filepath.Join(config.RepoRoot, "store")) store, err := leveldb.New(filepath.Join(config.RepoRoot, "store"))
tool.Asset(err) tool.Asset(err)
logger := loggers.Logger(loggers.App) logger := loggers.Logger(loggers.App)
//TODO add bls sign
privateKey, err := repo.LoadPrivateKey(repoRoot) privateKey, err := repo.LoadPrivateKey(repoRoot)
tool.Asset(err) tool.Asset(err)
addr, err := privateKey.PublicKey().Address() addr, err := privateKey.PublicKey().Address()
...@@ -61,6 +62,7 @@ func NewSidecar(repoRoot string, config *repo.Config) (internal.Launcher, error) ...@@ -61,6 +62,7 @@ func NewSidecar(repoRoot string, config *repo.Config) (internal.Launcher, error)
persister := manger.NewPersister(addr.String(), store, loggers.Logger(loggers.Manger)) persister := manger.NewPersister(addr.String(), store, loggers.Logger(loggers.Manger))
appchainMgr := appchainmgr.New(persister) appchainMgr := appchainmgr.New(persister)
// TODO hub client // TODO hub client
// privateKey DH
cryptor := txcrypto.NewCryptor(nil, appchainMgr, privateKey) cryptor := txcrypto.NewCryptor(nil, appchainMgr, privateKey)
clientPort := appchain.NewPorts(clients, cryptor, logger) clientPort := appchain.NewPorts(clients, cryptor, logger)
r.Adds(clientPort) r.Adds(clientPort)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment