Documentation
¶
Overview ¶
Copyright © 2022 Polygon <engineering@polygon.technology>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
Index ¶
Constants ¶
const RSAKeypairBits = 2048
Variables ¶
var NodekeyCmd = &cobra.Command{ Use: "nodekey", Short: "Generate Node Keys", Long: `This is meant to be a simple utility for generating node keys for different block chain clients and protocols. `, RunE: func(cmd *cobra.Command, args []string) error { var nko nodeKeyOut var withSeed bool switch *inputNodeKeyProtocol { case "devp2p": var err error nko, err = generateDevp2pNodeKey() if err != nil { return err } case "seed-libp2p": withSeed = true fallthrough case "libp2p": keyType, err := keyTypeToInt(*inputNodeKeyType) if err != nil { return err } nko, err = generateLibp2pNodeKey(keyType, withSeed) if err != nil { return err } default: return fmt.Errorf("%s is not implemented yet", *inputNodeKeyProtocol) } out, err := json.Marshal(nko) if err != nil { return fmt.Errorf("could not json marshal the key data %w", err) } fmt.Println(string(out)) return nil }, Args: func(cmd *cobra.Command, args []string) error { if len(args) != 0 { return fmt.Errorf("this command expects no arguments") } validProtocols := []string{"devp2p", "libp2p", "seed-libp2p"} ok := slices.Contains(validProtocols, *inputNodeKeyProtocol) if !ok { return fmt.Errorf("the protocol %s is not implemented", *inputNodeKeyProtocol) } if *inputNodeKeyProtocol == "devp2p" { invalidFlags := []string{"key-type", "seed", "marshal-protobuf"} err := validateNodeKeyFlags(cmd, invalidFlags) if err != nil { return err } } if *inputNodeKeyProtocol == "libp2p" { invalidFlags := []string{"file", "ip", "tcp", "udp", "sign", "seed"} err := validateNodeKeyFlags(cmd, invalidFlags) if err != nil { return err } } if *inputNodeKeyProtocol == "seed-libp2p" { invalidFlags := []string{"file", "ip", "tcp", "udp", "sign"} err := validateNodeKeyFlags(cmd, invalidFlags) if err != nil { return err } if *inputNodeKeyType == "rsa" { return fmt.Errorf("the RSA key type doesn't support manual key seeding") } if *inputNodeKeyType == "secp256k1" { return fmt.Errorf("the secp256k1 key type doesn't support manual key seeding") } } return nil }, }
NodekeyCmd represents the nodekey command
Functions ¶
This section is empty.
Types ¶
This section is empty.