mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-08 23:18:15 -05:00
Export reverse byte order function (#10040)
* Reverse byte order * Update BUILD.bazel * Go imports Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
This commit is contained in:
@@ -17,6 +17,7 @@ go_library(
|
||||
"//container/trie:go_default_library",
|
||||
"//crypto/bls:go_default_library",
|
||||
"//crypto/hash:go_default_library",
|
||||
"//encoding/bytesutil:go_default_library",
|
||||
"//proto/prysm/v1alpha1:go_default_library",
|
||||
"//time:go_default_library",
|
||||
"@com_github_pkg_errors//:go_default_library",
|
||||
|
||||
@@ -5,6 +5,8 @@ import (
|
||||
"math/big"
|
||||
"sync"
|
||||
|
||||
"github.com/prysmaticlabs/prysm/encoding/bytesutil"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/prysmaticlabs/prysm/async"
|
||||
"github.com/prysmaticlabs/prysm/crypto/bls"
|
||||
@@ -51,7 +53,7 @@ func deterministicallyGenerateKeys(startIndex, numKeys uint64) ([]bls.SecretKey,
|
||||
binary.LittleEndian.PutUint32(enc, uint32(i))
|
||||
hash := hash.Hash(enc)
|
||||
// Reverse byte order to big endian for use with big ints.
|
||||
b := reverseByteOrder(hash[:])
|
||||
b := bytesutil.ReverseByteOrder(hash[:])
|
||||
num := new(big.Int)
|
||||
num = num.SetBytes(b)
|
||||
order := new(big.Int)
|
||||
@@ -76,12 +78,3 @@ func deterministicallyGenerateKeys(startIndex, numKeys uint64) ([]bls.SecretKey,
|
||||
}
|
||||
return privKeys, pubKeys, nil
|
||||
}
|
||||
|
||||
// Switch the endianness of a byte slice by reversing its order.
|
||||
func reverseByteOrder(input []byte) []byte {
|
||||
b := input
|
||||
for i := 0; i < len(b)/2; i++ {
|
||||
b[i], b[len(b)-i-1] = b[len(b)-i-1], b[i]
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user