-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added derive_operatorid command to egnkey (#247)
* added derive_operatorid command to egnkey also refactored commands to be in their own packages to prevent var/flag conflicts * update pkg name: derive_operatorid -> operatorid
- Loading branch information
Showing
4 changed files
with
49 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package operatorid | ||
|
||
import ( | ||
"encoding/hex" | ||
"fmt" | ||
|
||
"github.com/Layr-Labs/eigensdk-go/crypto/bls" | ||
"github.com/Layr-Labs/eigensdk-go/types" | ||
"github.com/urfave/cli/v2" | ||
) | ||
|
||
var ( | ||
PrivateKey = &cli.StringFlag{ | ||
Name: "private-key", | ||
Usage: "(bn254) private key from which to derive operatorId from", | ||
Required: true, | ||
} | ||
) | ||
|
||
var Command = &cli.Command{ | ||
Name: "derive-operator-id", | ||
Aliases: []string{"d"}, | ||
Description: `Given a private key, output its associated operatorId (hash of bn254 G1 pubkey).`, | ||
Action: derive, | ||
Flags: []cli.Flag{ | ||
PrivateKey, | ||
}, | ||
} | ||
|
||
func derive(c *cli.Context) error { | ||
sk := c.String(PrivateKey.Name) | ||
keypair, err := bls.NewKeyPairFromString(sk) | ||
if err != nil { | ||
return err | ||
} | ||
operatorId := types.OperatorIdFromKeyPair(keypair) | ||
fmt.Println("0x" + hex.EncodeToString(operatorId[:])) | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters