mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-25 12:57:18 +00:00
3fb78ff575
* Add GenValRoot dbs * Test genvalroot * Fix names * Add overwrite rejection * validate metadata genesis validator root * remove env * fix database functions * fix tests * raul feedback Co-authored-by: Ivan Martinez <ivanthegreatdev@gmail.com> Co-authored-by: Raul Jordan <raul@prysmaticlabs.com> Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
39 lines
876 B
Go
39 lines
876 B
Go
package interchangeformat
|
|
|
|
import (
|
|
"encoding/hex"
|
|
"fmt"
|
|
"strconv"
|
|
"strings"
|
|
)
|
|
|
|
func uint64FromString(str string) (uint64, error) {
|
|
return strconv.ParseUint(str, 10, 64)
|
|
}
|
|
|
|
func pubKeyFromHex(str string) ([48]byte, error) {
|
|
pubKeyBytes, err := hex.DecodeString(strings.TrimPrefix(str, "0x"))
|
|
if err != nil {
|
|
return [48]byte{}, err
|
|
}
|
|
if len(pubKeyBytes) != 48 {
|
|
return [48]byte{}, fmt.Errorf("public key is not correct, 48-byte length: %s", str)
|
|
}
|
|
var pk [48]byte
|
|
copy(pk[:], pubKeyBytes[:48])
|
|
return pk, nil
|
|
}
|
|
|
|
func rootFromHex(str string) ([32]byte, error) {
|
|
rootHexBytes, err := hex.DecodeString(strings.TrimPrefix(str, "0x"))
|
|
if err != nil {
|
|
return [32]byte{}, err
|
|
}
|
|
if len(rootHexBytes) != 32 {
|
|
return [32]byte{}, fmt.Errorf("wrong root length, 32-byte length: %s", str)
|
|
}
|
|
var root [32]byte
|
|
copy(root[:], rootHexBytes[:32])
|
|
return root, nil
|
|
}
|