mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
swarm/network: Cleanup after rebase on extract swarm enode new
This commit is contained in:
parent
9a268dab50
commit
5edbf3ce74
1 changed files with 9 additions and 10 deletions
|
|
@ -112,15 +112,15 @@ func (s *Simulation) AddNode(opts ...AddNodeOption) (id enode.ID, err error) {
|
||||||
// for now we have no way of setting bootnodes or lightnodes in sims
|
// for now we have no way of setting bootnodes or lightnodes in sims
|
||||||
// so we just let them be set to false
|
// so we just let them be set to false
|
||||||
// they should perhaps be possible to override them with AddNodeOption
|
// they should perhaps be possible to override them with AddNodeOption
|
||||||
enodeParams := &network.EnodeParams{
|
bzzPrivateKey, err := BzzKeyFromConfig(conf)
|
||||||
PrivateKey: conf.PrivateKey,
|
|
||||||
}
|
|
||||||
record, err := network.NewEnodeRecord(enodeParams)
|
|
||||||
|
|
||||||
bzzPrivateKey, bzzKey, err := BzzKeyFromConfig(conf)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return enode.ID{}, err
|
return enode.ID{}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enodeParams := &network.EnodeParams{
|
||||||
|
PrivateKey: bzzPrivateKey,
|
||||||
|
}
|
||||||
|
record, err := network.NewEnodeRecord(enodeParams)
|
||||||
conf.Record = *record
|
conf.Record = *record
|
||||||
|
|
||||||
// Add the bzz address to the node config
|
// Add the bzz address to the node config
|
||||||
|
|
@ -330,13 +330,12 @@ func init() {
|
||||||
|
|
||||||
// derive a private key for swarm for the node key
|
// derive a private key for swarm for the node key
|
||||||
// returns the private key used to generate the bzz key AND the generated bzz key
|
// returns the private key used to generate the bzz key AND the generated bzz key
|
||||||
func BzzKeyFromConfig(conf *adapters.NodeConfig) (*ecdsa.PrivateKey, []byte, error) {
|
func BzzKeyFromConfig(conf *adapters.NodeConfig) (*ecdsa.PrivateKey, error) {
|
||||||
// ecdsa.GenerateKey takes 40 bytes entropy
|
// ecdsa.GenerateKey takes 40 bytes entropy
|
||||||
privKeyBuf := append(crypto.FromECDSA(conf.PrivateKey), []byte{0x62, 0x7a, 0x7a, 0x62, 0x7a, 0x7a, 0x62, 0x7a}...)
|
privKeyBuf := append(crypto.FromECDSA(conf.PrivateKey), []byte{0x62, 0x7a, 0x7a, 0x62, 0x7a, 0x7a, 0x62, 0x7a}...)
|
||||||
bzzPrivateKey, err := ecdsa.GenerateKey(crypto.S256(), bytes.NewReader(privKeyBuf))
|
bzzPrivateKey, err := ecdsa.GenerateKey(crypto.S256(), bytes.NewReader(privKeyBuf))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
bzzKey := network.PrivateKeyToBzzKey(bzzPrivateKey)
|
return bzzPrivateKey, nil
|
||||||
return bzzPrivateKey, bzzKey, nil
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue