mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2025-01-08 10:41:19 +00:00
798bbbdc82
* coldstart flags for validator * WIP beacon node flags * wip beacon chain, flag fix in validator, arg fix in validator * checkpoint * Added interop service * working on mock chainstart * save the state lol * fix tests * Save genesis validators * gaz * fix validator help flags * WaitForChainStart actually waits for genesis time * cold start fixes * cache * change back * allow for genesis state too * remove logs * increase mmap size * dont process if head doesn't exist * add 10ms tolerance * enable libp2p debug at debug, fix pubsub * works with checkpt * initialize justified and finalized in db * Removed preloadStatePath from blockchain service * Clean up * Write to disk for now post state * revert b466dd536f8eadbdae2264a545a755370223d917 * Builds * Only RPC test fails now * use minimal config, no demo config * clean up branch * Lint * resolve lint * more lint fixes * lint * fix viz * Fixing RPC test * skip before epoch 2 * RPC time out * Fixed ordering * rename * remove some dbg statements * ensure index is correct * fix some panics * getting closer * fix tests * Fix private key * Fixed RPC test * Fixed beacon chain build for docker * Add interop.go to validator go_image * Fixed docker build * handle errors * skip test, skip disconnecting peers * Fixed docker build * tolerance for attestation processing * revert copy * clearer err message parse * fix launching from dep contract
55 lines
1.7 KiB
Go
55 lines
1.7 KiB
Go
package interop
|
|
|
|
import (
|
|
"encoding/binary"
|
|
"math/big"
|
|
|
|
"github.com/pkg/errors"
|
|
"github.com/prysmaticlabs/prysm/shared/bls"
|
|
"github.com/prysmaticlabs/prysm/shared/hashutil"
|
|
)
|
|
|
|
const (
|
|
blsWithdrawalPrefixByte = byte(0)
|
|
)
|
|
|
|
// DeterministicallyGenerateKeys creates BLS private keys using a fixed curve order according to
|
|
// the algorithm specified in the Eth2.0-Specs interop mock start section found here:
|
|
// https://github.com/ethereum/eth2.0-pm/blob/a085c9870f3956d6228ed2a40cd37f0c6580ecd7/interop/mocked_start/README.md
|
|
func DeterministicallyGenerateKeys(startIndex, numKeys uint64) ([]*bls.SecretKey, []*bls.PublicKey, error) {
|
|
privKeys := make([]*bls.SecretKey, numKeys)
|
|
pubKeys := make([]*bls.PublicKey, numKeys)
|
|
for i := startIndex; i < startIndex+numKeys; i++ {
|
|
enc := make([]byte, 32)
|
|
binary.LittleEndian.PutUint32(enc, uint32(i))
|
|
hash := hashutil.Hash(enc)
|
|
// Reverse byte order to big endian for use with big ints.
|
|
b := reverseByteOrder(hash[:])
|
|
num := new(big.Int)
|
|
num = num.SetBytes(b)
|
|
order := new(big.Int)
|
|
var ok bool
|
|
order, ok = order.SetString(bls.CurveOrder, 10)
|
|
if !ok {
|
|
return nil, nil, errors.New("could not set bls curve order as big int")
|
|
}
|
|
num = num.Mod(num, order)
|
|
priv, err := bls.SecretKeyFromBytes(num.Bytes())
|
|
if err != nil {
|
|
return nil, nil, errors.Wrap(err, "could not create bls secret key from raw bytes")
|
|
}
|
|
privKeys[i-startIndex] = priv
|
|
pubKeys[i-startIndex] = priv.PublicKey()
|
|
}
|
|
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
|
|
}
|