-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(contracts/script): fix registerValidators script
- Loading branch information
Showing
6 changed files
with
111 additions
and
16 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module bolt-contracts | ||
|
||
go 1.22.7 | ||
|
||
require github.com/supranational/blst v0.3.11 |
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,2 @@ | ||
github.com/supranational/blst v0.3.11 h1:LyU6FolezeWAhvQk0k6O/d49jqgO52MSDDfYgbeoEm4= | ||
github.com/supranational/blst v0.3.11/go.mod h1:jZJtfjgudtNl4en1tzwPIV3KjUnQUvG3/j+w+fVonLw= |
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,41 @@ | ||
package main | ||
|
||
import ( | ||
"encoding/hex" | ||
"fmt" | ||
"os" | ||
"strings" | ||
|
||
blst "github.com/supranational/blst/bindings/go" | ||
) | ||
|
||
type blsPublicKey = blst.P1Affine | ||
|
||
func main() { | ||
if len(os.Args) != 2 { | ||
fmt.Println("Usage: pubkey_to_g1 <pubkey>") | ||
os.Exit(1) | ||
} | ||
|
||
pubkey := strings.TrimPrefix(os.Args[1], "0x") | ||
|
||
pubkeyBytes, err := hex.DecodeString(pubkey) | ||
if err != nil { | ||
fmt.Println("Failed to decode pubkey:", err) | ||
os.Exit(1) | ||
} | ||
|
||
if len(pubkeyBytes) != 48 { | ||
fmt.Println("Invalid pubkey length") | ||
os.Exit(1) | ||
} | ||
|
||
G1 := new(blsPublicKey).Uncompress(pubkeyBytes) | ||
|
||
serialized := G1.Serialize() | ||
|
||
x := serialized[0:48] | ||
y := serialized[48:] | ||
|
||
fmt.Printf("0x%x,0x%x\n", x, y) | ||
} |
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
Binary file not shown.
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,23 @@ | ||
#!/bin/bash | ||
|
||
# Only works on Linux | ||
arch=$(uname -i 2>/dev/null) || arch=$(uname -p) | ||
if [[ $OSTYPE == linux* ]]; then | ||
if [[ $arch == x86_64 ]]; then | ||
./script/pubkey_to_g1-linux-amd64 "$1" | ||
elif [[ $arch == aarch64 ]]; then | ||
./script/pubkey_to_g1-linux-arm64 "$1" | ||
else | ||
exit 1 | ||
fi | ||
elif [[ $OSTYPE == darwin* ]]; then | ||
if [[ $arch == arm* ]]; then | ||
./script/pubkey_to_g1-darwin-arm64 "$1" | ||
elif [[ $arch == x86_64 ]]; then | ||
./script/pubkey_to_g1-darwin-amd64 "$1" | ||
else | ||
exit 1 | ||
fi | ||
else | ||
exit 1 | ||
fi |