Skip to content

Commit

Permalink
change commons for more clear
Browse files Browse the repository at this point in the history
  • Loading branch information
fyInALT committed Jun 7, 2024
1 parent 42cff9e commit a21c528
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
11 changes: 7 additions & 4 deletions pkg/operator/keys/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ It will only list keys created in the default folder (./operator_keys/)
return err
}
fmt.Println("Public Key: " + pubKey)
operatorIdStr, err := GetOperatorIdFromPubKey(pubKey)
operatorIdStr, err := GetOperatorIdFromBLSPubKey(pubKey)
if err != nil {
return err
}
Expand Down Expand Up @@ -101,16 +101,19 @@ func GetPubKey(keyStoreFile string) (string, error) {
}
}

func GetOperatorIdFromPubKey(pubKey string) (string, error) {
// From:
func GetOperatorIdFromBLSPubKey(pubKey string) (string, error) {
// The pubkey 's string is generated from this code:
// ```go
// func (p *G1Affine) String() string {
// if p.IsInfinity() {
// return "O"
// }
// return "E([" + p.X.String() + "," + p.Y.String() + "])"
// }
// ````
// ```
//
// This code just parser this string:
// E([498211989701534593628498974128726712526336918939770789545660245177948853517,19434346619705907282579203143605058653932187676054178921788041096426532277474])

if pubKey == "O" {
return "", fmt.Errorf("pubKey is Infinity")
Expand Down
2 changes: 1 addition & 1 deletion pkg/operator/keys/list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func TestGetOperatorIdFromPubKey(t *testing.T) {
}

for i, key := range keys {
id, err := GetOperatorIdFromPubKey(key)
id, err := GetOperatorIdFromBLSPubKey(key)
assert.NoError(t, err, "get operator id from pubkey for %s", key)
assert.Equal(t, operatorIds[i], id, "operator id from pubkey for %s should eq", key)
}
Expand Down

0 comments on commit a21c528

Please sign in to comment.