From 51861455e8ce0fc4877ed434bda8c4a939025b41 Mon Sep 17 00:00:00 2001 From: Wigy Date: Tue, 13 Dec 2016 15:01:23 +0100 Subject: [PATCH 1/5] Added Ed25519 key type --- main.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index b81e896..ff2e496 100644 --- a/main.go +++ b/main.go @@ -11,7 +11,7 @@ import ( func main() { size := flag.Int("bitsize", 2048, "select the bitsize of the key to generate") - typ := flag.String("type", "RSA", "select type of key to generate") + typ := flag.String("type", "RSA", "select type of key to generate (RSA or Ed25519)") flag.Parse() @@ -19,6 +19,8 @@ func main() { switch *typ { case "RSA": atyp = ci.RSA + case "Ed25519": + atyp = ci.Ed25519 default: fmt.Fprintln(os.Stderr, "unrecognized key type: ", *typ) os.Exit(1) From d5853103ff852fdf2722cdc7c680c9bc267d4373 Mon Sep 17 00:00:00 2001 From: Wigy Date: Tue, 13 Dec 2016 15:07:39 +0100 Subject: [PATCH 2/5] Key type is now case insensitive --- main.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/main.go b/main.go index ff2e496..f9e6912 100644 --- a/main.go +++ b/main.go @@ -7,6 +7,7 @@ import ( ci "github.com/libp2p/go-libp2p-crypto" peer "github.com/libp2p/go-libp2p-peer" + "strings" ) func main() { @@ -16,10 +17,10 @@ func main() { flag.Parse() var atyp int - switch *typ { - case "RSA": + switch strings.ToLower(*typ) { + case "rsa": atyp = ci.RSA - case "Ed25519": + case "ed25519": atyp = ci.Ed25519 default: fmt.Fprintln(os.Stderr, "unrecognized key type: ", *typ) From d7404b100fdd931a67197a8c6356e3849f33b991 Mon Sep 17 00:00:00 2001 From: Wigy Date: Tue, 13 Dec 2016 15:14:21 +0100 Subject: [PATCH 3/5] Conventions, conventions. --- main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.go b/main.go index f9e6912..bdd0c52 100644 --- a/main.go +++ b/main.go @@ -4,10 +4,10 @@ import ( "flag" "fmt" "os" + "strings" ci "github.com/libp2p/go-libp2p-crypto" peer "github.com/libp2p/go-libp2p-peer" - "strings" ) func main() { From ceb6bf1326d88aab13e2f6068fa846b13baf9380 Mon Sep 17 00:00:00 2001 From: Wigy Date: Tue, 20 Dec 2016 12:52:00 +0100 Subject: [PATCH 4/5] Fixing the README.md based on review comments --- README.md | 35 +++++++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 23a1cc2..d3a3948 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,39 @@ # ipfs-key -A tool for easily generating ipfs keypairs. When run, it will write the bytes of -the serialized private key to stdout. By default, a 2048 bit RSA key will be -generated. The keysize can be changed by specifying the `-bitsize` option, and the -key type can be changed by specifying the `-type` option (currently only RSA is -implemented). + +[![standard-readme compliant](https://img.shields.io/badge/readme%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/RichardLitt/standard-readme) + +> A tool for easily generating ipfs keypairs + +## Table of Contents + +- [Installation](#installation) +- [Usage](#usage) +- [Contribute](#contribute) +- [License](#license) ## Installation + ``` $ go get github.com/whyrusleeping/ipfs-key ``` ## Usage + +When run, it will write the bytes of +the serialized private key to stdout. By default, a 2048 bit RSA key will be +generated. In this case the key size can be changed by specifying the `-bitsize` +option. The key type can be changed by specifying the `-type` option (rsa or +ed25519). Currently only the RSA uses the -bitsize option. + ``` -$ ipfs-key -bitsize=4096 > my.key +$ ipfs-key -bitsize=4096 > my-rsa4096.key +$ ipfs-key -type=ed25519 > my-ed.key ``` + +## Contribute + +PRs accepted. + +## License + +[MIT](LICENSE) Copyright (c) 2016 [Jeromy Johnson](http://github.com/whyrusleeping) \ No newline at end of file From e3f6055850af941a5be86d832b735ad8648df2ab Mon Sep 17 00:00:00 2001 From: wigy Date: Tue, 20 Dec 2016 20:41:10 +0100 Subject: [PATCH 5/5] Removed the superfluous sentence --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index d3a3948..09c4b8f 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ When run, it will write the bytes of the serialized private key to stdout. By default, a 2048 bit RSA key will be generated. In this case the key size can be changed by specifying the `-bitsize` option. The key type can be changed by specifying the `-type` option (rsa or -ed25519). Currently only the RSA uses the -bitsize option. +ed25519). ``` $ ipfs-key -bitsize=4096 > my-rsa4096.key @@ -36,4 +36,4 @@ PRs accepted. ## License -[MIT](LICENSE) Copyright (c) 2016 [Jeromy Johnson](http://github.com/whyrusleeping) \ No newline at end of file +[MIT](LICENSE) Copyright (c) 2016 [Jeromy Johnson](http://github.com/whyrusleeping)