Skip to content

Instantly share code, notes, and snippets.

@paralin
Created June 3, 2021 01:31
Show Gist options
  • Select an option

  • Save paralin/34e5d3416fd544fbfb0fb1a4c4146b45 to your computer and use it in GitHub Desktop.

Select an option

Save paralin/34e5d3416fd544fbfb0fb1a4c4146b45 to your computer and use it in GitHub Desktop.
extract go-bee ethereum key from dir
package main
import (
"fmt"
"github.com/ethersphere/bee/pkg/crypto"
filekeystore "github.com/ethersphere/bee/pkg/keystore/file"
)
func main() {
keystore := filekeystore.New("./keys")
password := "my-password-here"
swarmPrivateKey, created, err := keystore.Key("swarm", password)
if err != nil {
panic(err)
}
_ = created
signer := crypto.NewDefaultSigner(swarmPrivateKey)
// publicKey := &swarmPrivateKey.PublicKey
overlayEthAddress, err := signer.EthereumAddress()
if err != nil {
panic(err)
}
fmt.Printf("got ethereum address: %x\n", overlayEthAddress)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment