Documentation ¶
Index ¶
Constants ¶
View Source
const RSAKeypairBits = 2048
Variables ¶
View Source
var NodekeyCmd = &cobra.Command{ Use: "nodekey", Short: "Generate node keys for different blockchain clients and protocols.", Long: usage, 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.
Click to show internal directories.
Click to hide internal directories.