Documentation
¶
Index ¶
Constants ¶
View Source
const ( PrivKeyName = "comet/PrivKeySecp256k1Uncompressed" PubKeyName = "comet/PubKeySecp256k1Uncompressed" KeyType = "secp256k1" PrivKeySize = 32 // PubKeySize (uncompressed) is composed of 65 bytes for two field elements (x and y) // and a prefix byte (0x04) to indicate that it is uncompressed. PubKeySize = 65 // SigSize is the size of the ECDSA signature. SigSize = 65 )
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, PersistentPreRun: func(cmd *cobra.Command, args []string) { inputNodeKeyPrivateKey = flag_loader.GetRpcUrlFlagValue(cmd) }, RunE: func(cmd *cobra.Command, args []string) error { var nko nodeKeyOut var withSeed bool switch *inputNodeKeyProtocol { case "devp2p": switch *inputNodeKeyType { case "ed25519": var err error nko, err = generateDevp2pNodeKey() if err != nil { return err } case "secp256k1": secret := []byte(strings.TrimPrefix(*inputNodeKeyPrivateKey, "0x")) secp256k1PrivateKey := generateSecp256k1PrivateKey(secret) if err := displayHeimdallV2PrivValidatorKey(secp256k1PrivateKey); err != nil { return err } return nil } 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{"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 ¶
type PrivKey ¶ added in v0.1.69
type PrivKey []byte
func (PrivKey) Equals ¶ added in v0.1.69
Equals - you probably don't need to use this. Runs in constant time based on length of the keys.
func (PrivKey) PubKey ¶ added in v0.1.69
PubKey performs the point-scalar multiplication from the privKey on the generator point to get the pubkey.
Click to show internal directories.
Click to hide internal directories.