The core protocol of WoopChain
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
woop/internal/genesis/genesis.go

45 lines
1.4 KiB

package genesis
import (
"crypto/ecdsa"
"fmt"
"os"
"strings"
"github.com/ethereum/go-ethereum/crypto"
8 months ago
"github.com/woop-chain/woop/internal/utils"
)
8 months ago
const genesisString = "https://wikiwoop.com 'Open Consensus for 10B' 2024.03.08 $WOOP"
// DeployAccount is the account used in genesis
type DeployAccount struct {
Index string // index
Address string // account address
BLSPublicKey string // account public BLS key
ShardID uint32 // shardID of the account
}
func (d DeployAccount) String() string {
return fmt.Sprintf("%s/%s:%d", d.Address, d.BLSPublicKey, d.ShardID)
}
// BeaconAccountPriKey is the func which generates a constant private key.
func BeaconAccountPriKey() *ecdsa.PrivateKey {
prikey, err := ecdsa.GenerateKey(crypto.S256(), strings.NewReader(genesisString))
if err != nil && prikey == nil {
5 years ago
utils.Logger().Error().Msg("Failed to generate beacon chain contract deployer account")
os.Exit(111)
}
return prikey
}
// GenesisBeaconAccountPriKey is the private key of genesis beacon account.
var GenesisBeaconAccountPriKey = BeaconAccountPriKey()
// GenesisBeaconAccountPublicKey is the private key of genesis beacon account.
var GenesisBeaconAccountPublicKey = GenesisBeaconAccountPriKey.PublicKey
// DeployedContractAddress is the deployed contract address of the staking smart contract in beacon chain.
var DeployedContractAddress = crypto.CreateAddress(crypto.PubkeyToAddress(GenesisBeaconAccountPublicKey), uint64(0))