diff options
author | Elad <theman@elad.im> | 2018-09-05 17:33:07 +0800 |
---|---|---|
committer | Balint Gabor <balint.g@gmail.com> | 2018-09-05 17:33:07 +0800 |
commit | 5918b88a8f8be34f39b8df94d146f77ac9b4fbfc (patch) | |
tree | 4b4bab5fa001e87052ed249e2ed460223ee8ace0 /cmd/swarm/main.go | |
parent | 8711e2b6366109912057e8fb20add325a1051a4e (diff) | |
download | dexon-5918b88a8f8be34f39b8df94d146f77ac9b4fbfc.tar dexon-5918b88a8f8be34f39b8df94d146f77ac9b4fbfc.tar.gz dexon-5918b88a8f8be34f39b8df94d146f77ac9b4fbfc.tar.bz2 dexon-5918b88a8f8be34f39b8df94d146f77ac9b4fbfc.tar.lz dexon-5918b88a8f8be34f39b8df94d146f77ac9b4fbfc.tar.xz dexon-5918b88a8f8be34f39b8df94d146f77ac9b4fbfc.tar.zst dexon-5918b88a8f8be34f39b8df94d146f77ac9b4fbfc.zip |
cmd/swarm: added publisher key assertion to act tests (#17471)
Diffstat (limited to 'cmd/swarm/main.go')
-rw-r--r-- | cmd/swarm/main.go | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/cmd/swarm/main.go b/cmd/swarm/main.go index 637ae06e9..e65440937 100644 --- a/cmd/swarm/main.go +++ b/cmd/swarm/main.go @@ -18,6 +18,7 @@ package main import ( "crypto/ecdsa" + "encoding/hex" "fmt" "io/ioutil" "os" @@ -208,6 +209,10 @@ var ( Name: "data", Usage: "Initializes the resource with the given hex-encoded data. Data must be prefixed by 0x", } + SwarmCompressedFlag = cli.BoolFlag{ + Name: "compressed", + Usage: "Prints encryption keys in compressed form", + } ) //declare a few constant error messages, useful for later error check comparisons in test @@ -253,6 +258,14 @@ func init() { Description: "The output of this command is supposed to be machine-readable", }, { + Action: keys, + CustomHelpTemplate: helpTemplate, + Name: "print-keys", + Flags: []cli.Flag{SwarmCompressedFlag}, + Usage: "Print public key information", + Description: "The output of this command is supposed to be machine-readable", + }, + { Action: upload, CustomHelpTemplate: helpTemplate, Name: "up", @@ -580,6 +593,17 @@ func main() { } } +func keys(ctx *cli.Context) error { + privateKey := getPrivKey(ctx) + pub := hex.EncodeToString(crypto.FromECDSAPub(&privateKey.PublicKey)) + pubCompressed := hex.EncodeToString(crypto.CompressPubkey(&privateKey.PublicKey)) + if !ctx.Bool(SwarmCompressedFlag.Name) { + fmt.Println(fmt.Sprintf("publicKey=%s", pub)) + } + fmt.Println(fmt.Sprintf("publicKeyCompressed=%s", pubCompressed)) + return nil +} + func version(ctx *cli.Context) error { fmt.Println(strings.Title(clientIdentifier)) fmt.Println("Version:", sv.VersionWithMeta) |