2018-12-28 11:37:22 +00:00
|
|
|
package account
|
|
|
|
|
|
|
|
import (
|
2019-12-19 16:03:00 +00:00
|
|
|
"github.com/status-im/status-go/eth-node/crypto"
|
2019-11-23 17:57:05 +00:00
|
|
|
"github.com/status-im/status-go/eth-node/types"
|
2018-12-28 11:37:22 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func CreateAddress() (address, pubKey, privKey string, err error) {
|
|
|
|
key, err := crypto.GenerateKey()
|
|
|
|
if err != nil {
|
|
|
|
return "", "", "", err
|
|
|
|
}
|
|
|
|
|
|
|
|
privKeyBytes := crypto.FromECDSA(key)
|
|
|
|
pubKeyBytes := crypto.FromECDSAPub(&key.PublicKey)
|
|
|
|
addressBytes := crypto.PubkeyToAddress(key.PublicKey)
|
|
|
|
|
2019-11-23 17:57:05 +00:00
|
|
|
privKey = types.EncodeHex(privKeyBytes)
|
|
|
|
pubKey = types.EncodeHex(pubKeyBytes)
|
2018-12-28 11:37:22 +00:00
|
|
|
address = addressBytes.Hex()
|
|
|
|
|
|
|
|
return
|
|
|
|
}
|